Skip to content

Commit

Permalink
133 find the expert broken (#136)
Browse files Browse the repository at this point in the history
* fix unable to see answer in find the expert

* remove db:deploy
  • Loading branch information
JurreBrandsenInfoSupport authored May 28, 2024
1 parent eeabae9 commit a116394
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 38 deletions.
1 change: 0 additions & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
48 changes: 11 additions & 37 deletions src/server/api/routers/survey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) => {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit a116394

Please sign in to comment.