mirror of
https://github.com/yangshun/tech-interview-handbook.git
synced 2025-07-18 03:31:58 +08:00
[resumes][refactor] Filter comments on FE (#336)
* [resumes][fix] Fix fetch id * [resumes][refactor] Change to filtering on FE for comments * [resumes][fix] Fix lint errors
This commit is contained in:
@ -21,10 +21,7 @@ export default function CommentsList({
|
|||||||
const { data: session } = useSession();
|
const { data: session } = useSession();
|
||||||
|
|
||||||
// Fetch the most updated comments to render
|
// Fetch the most updated comments to render
|
||||||
const commentsQuery = trpc.useQuery([
|
const commentsQuery = trpc.useQuery(['resumes.reviews.list', { resumeId }]);
|
||||||
'resumes.reviews.list',
|
|
||||||
{ resumeId, section: tab },
|
|
||||||
]);
|
|
||||||
|
|
||||||
// TODO: Add loading prompt
|
// TODO: Add loading prompt
|
||||||
|
|
||||||
@ -39,15 +36,17 @@ export default function CommentsList({
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<div className="m-2 flow-root h-[calc(100vh-20rem)] w-full flex-col space-y-3 overflow-y-scroll">
|
<div className="m-2 flow-root h-[calc(100vh-20rem)] w-full flex-col space-y-3 overflow-y-scroll">
|
||||||
{commentsQuery.data?.map((comment) => {
|
{commentsQuery.data
|
||||||
return (
|
?.filter((c) => c.section === tab)
|
||||||
<Comment
|
.map((comment) => {
|
||||||
key={comment.id}
|
return (
|
||||||
comment={comment}
|
<Comment
|
||||||
userId={session?.user?.id}
|
key={comment.id}
|
||||||
/>
|
comment={comment}
|
||||||
);
|
userId={session?.user?.id}
|
||||||
})}
|
/>
|
||||||
|
);
|
||||||
|
})}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@ -36,7 +36,7 @@ export const resumesResumeProtectedTabsRouter = createProtectedRouter()
|
|||||||
additionalInfo: rs.resume.additionalInfo,
|
additionalInfo: rs.resume.additionalInfo,
|
||||||
createdAt: rs.resume.createdAt,
|
createdAt: rs.resume.createdAt,
|
||||||
experience: rs.resume.experience,
|
experience: rs.resume.experience,
|
||||||
id: rs.id,
|
id: rs.resume.id,
|
||||||
location: rs.resume.location,
|
location: rs.resume.location,
|
||||||
numComments: rs.resume._count.comments,
|
numComments: rs.resume._count.comments,
|
||||||
numStars: rs.resume._count.stars,
|
numStars: rs.resume._count.stars,
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
import { ResumesSection } from '@prisma/client';
|
|
||||||
|
|
||||||
import { createRouter } from './context';
|
import { createRouter } from './context';
|
||||||
|
|
||||||
@ -8,11 +7,10 @@ import type { ResumeComment } from '~/types/resume-comments';
|
|||||||
export const resumeReviewsRouter = createRouter().query('list', {
|
export const resumeReviewsRouter = createRouter().query('list', {
|
||||||
input: z.object({
|
input: z.object({
|
||||||
resumeId: z.string(),
|
resumeId: z.string(),
|
||||||
section: z.nativeEnum(ResumesSection),
|
|
||||||
}),
|
}),
|
||||||
async resolve({ ctx, input }) {
|
async resolve({ ctx, input }) {
|
||||||
const userId = ctx.session?.user?.id;
|
const userId = ctx.session?.user?.id;
|
||||||
const { resumeId, section } = input;
|
const { resumeId } = input;
|
||||||
|
|
||||||
// For this resume, we retrieve every comment's information, along with:
|
// For this resume, we retrieve every comment's information, along with:
|
||||||
// The user's name and image to render
|
// The user's name and image to render
|
||||||
@ -42,7 +40,6 @@ export const resumeReviewsRouter = createRouter().query('list', {
|
|||||||
},
|
},
|
||||||
where: {
|
where: {
|
||||||
resumeId,
|
resumeId,
|
||||||
section,
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user