mirror of
https://github.com/yangshun/tech-interview-handbook.git
synced 2025-07-29 13:13:54 +08:00
[resumes][refactor] Change to ResumesProfile schema (#318)
* [resumes][chore] Update TODOs * [resumes][refactor] Change to new schema * [resumes][refactor] Change query to findUniqueOrThrow Co-authored-by: Terence Ho <>
This commit is contained in:
@ -7,10 +7,7 @@ type ICommentsSectionProps = {
|
||||
resumeId: string;
|
||||
};
|
||||
|
||||
// TODO: Retrieve resumeId for CommentsSection
|
||||
export default function CommentsSection({
|
||||
resumeId = '',
|
||||
}: ICommentsSectionProps) {
|
||||
export default function CommentsSection({ resumeId }: ICommentsSectionProps) {
|
||||
const [showCommentsForm, setShowCommentsForm] = useState(false);
|
||||
|
||||
return showCommentsForm ? (
|
||||
|
@ -73,7 +73,8 @@ export default function ResumeReviewPage() {
|
||||
<ResumePdf />
|
||||
</div>
|
||||
<div className="mx-8 w-1/2">
|
||||
<CommentsSection resumeId="" />
|
||||
{/* TODO: Update resumeId */}
|
||||
<CommentsSection resumeId="cl8y6gtez0009yedbne9qp5zi" />
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
@ -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.findUniqueOrThrow({
|
||||
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,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -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.findUniqueOrThrow({
|
||||
select: {
|
||||
resumesProfileId: true,
|
||||
},
|
||||
where: {
|
||||
id: resumeId,
|
||||
},
|
||||
});
|
||||
|
||||
// For each section, convert them into ResumesComment model if provided
|
||||
const comments: Array<IResumeCommentInput> = [
|
||||
{ description: education, section: ResumesSection.EDUCATION },
|
||||
@ -41,8 +50,8 @@ export const resumesReviewsUserRouter = createProtectedRouter().mutation(
|
||||
return {
|
||||
description,
|
||||
resumeId,
|
||||
resumesProfileId,
|
||||
section,
|
||||
userId,
|
||||
};
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user