diff --git a/apps/portal/src/pages/resumes/review.tsx b/apps/portal/src/pages/resumes/review.tsx index 78bec672..f75ae519 100644 --- a/apps/portal/src/pages/resumes/review.tsx +++ b/apps/portal/src/pages/resumes/review.tsx @@ -74,7 +74,7 @@ export default function ResumeReviewPage() {
{/* TODO: Update resumeId */} - +
diff --git a/apps/portal/src/server/router/resumes-reviews-router.ts b/apps/portal/src/server/router/resumes-reviews-router.ts index 8e681326..7657e4fc 100644 --- a/apps/portal/src/server/router/resumes-reviews-router.ts +++ b/apps/portal/src/server/router/resumes-reviews-router.ts @@ -7,9 +7,18 @@ export const resumeReviewsRouter = createRouter().query('list', { resumeId: z.string(), }), async resolve({ ctx, input }) { - const userId = ctx.session?.user?.id; const { resumeId } = input; + const { resumesProfileId } = + await ctx.prisma.resumesResume.findFirstOrThrow({ + select: { + resumesProfileId: true, + }, + where: { + id: resumeId, + }, + }); + // For this resume, we retrieve every comment's information, along with: // The user's name and image to render // Number of votes, and whether the user (if-any) has voted @@ -20,16 +29,20 @@ export const resumeReviewsRouter = createRouter().query('list', { votes: true, }, }, - user: { - select: { - image: true, - name: true, + resumesProfile: { + include: { + user: { + select: { + image: true, + name: true, + }, + }, }, }, votes: { take: 1, where: { - userId, + resumesProfileId, }, }, }, diff --git a/apps/portal/src/server/router/resumes-reviews-user-router.ts b/apps/portal/src/server/router/resumes-reviews-user-router.ts index ec42a36b..ca6d5d45 100644 --- a/apps/portal/src/server/router/resumes-reviews-user-router.ts +++ b/apps/portal/src/server/router/resumes-reviews-user-router.ts @@ -6,8 +6,8 @@ import { createProtectedRouter } from './context'; type IResumeCommentInput = Readonly<{ description: string; resumeId: string; + resumesProfileId: string; section: ResumesSection; - userId: string; }>; export const resumesReviewsUserRouter = createProtectedRouter().mutation( @@ -22,10 +22,19 @@ export const resumesReviewsUserRouter = createProtectedRouter().mutation( skills: z.string(), }), async resolve({ ctx, input }) { - const userId = ctx.session?.user.id; const { resumeId, education, experience, general, projects, skills } = input; + const { resumesProfileId } = + await ctx.prisma.resumesResume.findFirstOrThrow({ + select: { + resumesProfileId: true, + }, + where: { + id: resumeId, + }, + }); + // For each section, convert them into ResumesComment model if provided const comments: Array = [ { description: education, section: ResumesSection.EDUCATION }, @@ -41,8 +50,8 @@ export const resumesReviewsUserRouter = createProtectedRouter().mutation( return { description, resumeId, + resumesProfileId, section, - userId, }; });