Skip to content

Commit

Permalink
disabled opt-in (#96)
Browse files Browse the repository at this point in the history
  • Loading branch information
JurreBrandsenInfoSupport committed Apr 22, 2024
1 parent 52c0602 commit 1a3ed2e
Show file tree
Hide file tree
Showing 11 changed files with 100 additions and 110 deletions.
36 changes: 18 additions & 18 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
name: Playwright Tests
on:
push:
branches: [ main, master ]
branches: [main, master]
pull_request:
branches: [ main, master ]
branches: [main, master]
jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Install dependencies
run: npm ci
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Run Playwright tests
run: npx playwright test
- uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30
- uses: actions/checkout@v4
# - uses: actions/setup-node@v4
# with:
# node-version: lts/*
# - name: Install dependencies
# run: npm ci
# - name: Install Playwright Browsers
# run: npx playwright install --with-deps
# - name: Run Playwright tests
# run: npx playwright test
# - uses: actions/upload-artifact@v4
# if: always()
# with:
# name: playwright-report
# path: playwright-report/
# retention-days: 30
1 change: 0 additions & 1 deletion prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ model User {
email String? @unique
emailVerified DateTime?
image String?
findExpertOptIn Boolean @default(false)
roles Role[] @relation("UserRole")
accounts Account[]
questionResults QuestionResult[]
Expand Down
6 changes: 0 additions & 6 deletions src/app/find-the-expert/[role]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,8 @@ const FindTheExpertPage = async () => {
};

const ShowTableWrapper = async () => {
// Only retrieve the question results for users that have opted in (findExpertOptIn)
const userAnswersForRole: QuestionResult[] = await db.questionResult.findMany(
{
where: {
user: {
findExpertOptIn: true,
},
},
include: {
question: {
include: {
Expand Down
2 changes: 1 addition & 1 deletion src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ const Home: React.FC = async () => {
Knowledge Academy).
</li>
<li className="mb-4">
<strong>&apos;Find the Expert&apos; (opt in):</strong> Gain
<strong>&apos;Find the Expert&apos;:</strong> Gain
access to a powerful search functionality that empowers you
to pinpoint experts in specific technologies at Info
Support. This feature proves invaluable when clients have
Expand Down
102 changes: 51 additions & 51 deletions src/components/opt-in.tsx
Original file line number Diff line number Diff line change
@@ -1,58 +1,58 @@
"use client";
// "use client";

import type { Session } from "next-auth";
import { api } from "~/trpc/react";
import { useState } from "react";
// import type { Session } from "next-auth";
// import { api } from "~/trpc/react";
// import { useState } from "react";

export default function OptIn({ session }: { session: Session }) {
const { mutate: setOptInMutate } = api.survey.setOptIn.useMutation();
const [optIn, setOptIn] = useState(session.user.findExpertOptIn);
const handleOptInToggle = () => {
setOptInMutate({
userId: session.user.id,
});
setOptIn(!optIn);
};
// export default function OptIn({ session }: { session: Session }) {
// const { mutate: setOptInMutate } = api.survey.setOptIn.useMutation();
// const [optIn, setOptIn] = useState(session.user.findExpertOptIn);
// const handleOptInToggle = () => {
// setOptInMutate({
// userId: session.user.id,
// });
// setOptIn(!optIn);
// };

return (
<div className="mt-8">
<h2 id="select-roles" className="mb-4 text-2xl font-bold">
Appear anonymous?
</h2>
If you appear anonymous, colleagues will not be able to find you based on
your expertise. So if you want to be helpful, please select
&quot;no&quot;. Your answers will always be stored together with your
account info.
<ul className="mt-4 grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-3">
<li
className={`cursor-pointer rounded-lg border p-4`}
onClick={() => handleOptInToggle()}
>
<input
// return (
// <div className="mt-8">
// <h2 id="select-roles" className="mb-4 text-2xl font-bold">
// Appear anonymous?
// </h2>
// If you appear anonymous, colleagues will not be able to find you based on
// your expertise. So if you want to be helpful, please select
// &quot;no&quot;. Your answers will always be stored together with your
// account info.
// <ul className="mt-4 grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-3">
// <li
// className={`cursor-pointer rounded-lg border p-4`}
// onClick={() => handleOptInToggle()}
// >
// <input

type="radio"
className={`mr-2 cursor-pointer `}
// type="radio"
// className={`mr-2 cursor-pointer `}

checked={!optIn}
onChange={() => handleOptInToggle()}
/>
<label className={"cursor-pointer"}>Yes</label>
</li>
<li
className={`cursor-pointer rounded-lg border p-4`}
onClick={() => handleOptInToggle()}
>
<input
// checked={!optIn}
// onChange={() => handleOptInToggle()}
// />
// <label className={"cursor-pointer"}>Yes</label>
// </li>
// <li
// className={`cursor-pointer rounded-lg border p-4`}
// onClick={() => handleOptInToggle()}
// >
// <input

type="radio"
className={`mr-2 cursor-pointer `}
// type="radio"
// className={`mr-2 cursor-pointer `}

checked={optIn}
onChange={() => handleOptInToggle()}
/>
<label className={"cursor-pointer"}>No</label>
</li>
</ul>
</div>
);
}
// checked={optIn}
// onChange={() => handleOptInToggle()}
// />
// <label className={"cursor-pointer"}>No</label>
// </li>
// </ul>
// </div>
// );
// }
5 changes: 3 additions & 2 deletions src/components/select-role.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Button } from "~/components/ui/button";
import { ArrowRight } from "./svg";
import { toast } from "./ui/use-toast";
import { ToastAction } from "./ui/toast";
import OptIn from "./opt-in";
// import OptIn from "./opt-in";

export default function SelectRoles({
session,
Expand Down Expand Up @@ -122,7 +122,8 @@ export default function SelectRoles({
))}
</ul>

<OptIn session={session} />
{/* Disabled until further notice. */}
{/* <OptIn session={session} /> */}

<div className="mt-5 flex justify-center">
<div className="mt-5 flex flex-col items-center gap-6 md:flex-row">
Expand Down
4 changes: 0 additions & 4 deletions src/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ export const env = createEnv({
AZURE_AD_CLIENT_ID: z.string(),
AZURE_AD_CLIENT_SECRET: z.string(),
AZURE_AD_TENANT_ID: z.string(),
GITHUB_ID: z.string(),
GITHUB_SECRET: z.string(),
NEXTAUTH_SECRET: z.string(),
NEXTAUTH_URL: z.string(),
FRESH_RUN: z.string(),
Expand All @@ -38,8 +36,6 @@ export const env = createEnv({
AZURE_AD_CLIENT_ID: process.env.AZURE_AD_CLIENT_ID,
AZURE_AD_CLIENT_SECRET: process.env.AZURE_AD_CLIENT_SECRET,
AZURE_AD_TENANT_ID: process.env.AZURE_AD_TENANT_ID,
GITHUB_ID: process.env.GITHUB_ID,
GITHUB_SECRET: process.env.GITHUB_SECRET,
NEXTAUTH_SECRET: process.env.NEXTAUTH_SECRET,
NEXTAUTH_URL: process.env.NEXTAUTH_URL,
FRESH_RUN: process.env.FRESH_RUN,
Expand Down
2 changes: 1 addition & 1 deletion src/models/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export interface PdfTransformedData {

export interface User {
id: string;
findExpertOptIn: boolean;
// findExpertOptIn: boolean;
}

export interface Section {
Expand Down
44 changes: 22 additions & 22 deletions src/server/api/routers/survey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,28 +62,28 @@ export const surveyRouter = createTRPCRouter({
return userAnswers;
}),

setOptIn: protectedProcedure
.input(z.object({ userId: z.string() }))
.mutation(async ({ ctx, input }) => {
const user = await ctx.db.user.findUnique({
where: {
id: input.userId,
},
});

if (!user) {
throw new TRPCClientError("User not found");
}

await ctx.db.user.update({
where: {
id: input.userId,
},
data: {
findExpertOptIn: !user.findExpertOptIn,
},
});
}),
// setOptIn: protectedProcedure
// .input(z.object({ userId: z.string() }))
// .mutation(async ({ ctx, input }) => {
// const user = await ctx.db.user.findUnique({
// where: {
// id: input.userId,
// },
// });

// if (!user) {
// throw new TRPCClientError("User not found");
// }

// await ctx.db.user.update({
// where: {
// id: input.userId,
// },
// data: {
// findExpertOptIn: !user.findExpertOptIn,
// },
// });
// }),

setDefaultRole: protectedProcedure
.input(z.object({ userId: z.string() }))
Expand Down
6 changes: 3 additions & 3 deletions src/server/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ declare module "next-auth" {
interface Session extends DefaultSession {
user: {
id: string;
findExpertOptIn: boolean;
// findExpertOptIn: boolean;
} & DefaultSession["user"];
}

interface User {
id: string;
findExpertOptIn: boolean;
// findExpertOptIn: boolean;
}
}

Expand All @@ -42,7 +42,7 @@ export const authOptions: NextAuthOptions = {
user: {
...session.user,
id: user.id,
findExpertOptIn: user.findExpertOptIn,
// findExpertOptIn: user.findExpertOptIn,
},
}),
},
Expand Down
2 changes: 1 addition & 1 deletion src/utils/stress-test-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export async function createNewUserAndSession(): Promise<Session | null> {
id: randomUser?.id ?? "",
email: randomUser?.email,
name: randomUser?.name,
findExpertOptIn: true,
// findExpertOptIn: true,
},
expires: "2025-12-31T23:59:59Z",
};
Expand Down

0 comments on commit 1a3ed2e

Please sign in to comment.