diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index b309970..fbd29b4 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -29,7 +29,6 @@ jobs: npm ci cp .env.example .env # an env file is needed for `build` npm run db:generate - npm run db:deploy npm run build npm ci --prod rm .env diff --git a/src/server/api/routers/survey.ts b/src/server/api/routers/survey.ts index 35c855a..c89a407 100644 --- a/src/server/api/routers/survey.ts +++ b/src/server/api/routers/survey.ts @@ -63,29 +63,6 @@ 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, - // }, - // }); - // }), - setDefaultRole: protectedProcedure .input(z.object({ userId: z.string(), roleIds: z.array(z.string()) })) .mutation(async ({ ctx, input }) => { @@ -324,25 +301,22 @@ export const surveyRouter = createTRPCRouter({ }); if (existingAnswer) { - // update the existing answer - await ctx.db.questionResult.update({ + // delete the existing answer + await ctx.db.questionResult.delete({ where: { id: existingAnswer.id, }, - data: { - answerId, - }, - }); - } else { - // create a new answer - await ctx.db.questionResult.create({ - data: { - userId, - questionId, - answerId, - }, }); } + + // create a new answer + await ctx.db.questionResult.create({ + data: { + userId, + questionId, + answerId, + }, + }); }), ); } catch (error) { diff --git a/src/utils/data-manipulation.ts b/src/utils/data-manipulation.ts index 8561a0f..163e9fe 100644 --- a/src/utils/data-manipulation.ts +++ b/src/utils/data-manipulation.ts @@ -122,9 +122,7 @@ const pushUserData = ( userMap[entry.userId]!.communicationPreferences?.length > 0 ? userMap[entry.userId]?.communicationPreferences : ["Do not contact"], - answer: - (answerOptionMap[entry.answerId] as { answer?: string })?.answer ?? - "Unknown Answer", + answer: answerOptionMap[entry.answerId] ?? "Unknown Answer", }); };