[resumes][refactor] Change to filtering on FE for comments

pull/336/head
Tan Su Yin 3 years ago
parent b8b779f943
commit cbdebf1c70

@ -21,10 +21,7 @@ export default function CommentsList({
const { data: session } = useSession();
// Fetch the most updated comments to render
const commentsQuery = trpc.useQuery([
'resumes.reviews.list',
{ resumeId, section: tab },
]);
const commentsQuery = trpc.useQuery(['resumes.reviews.list', { resumeId }]);
// TODO: Add loading prompt
@ -39,7 +36,9 @@ export default function CommentsList({
/>
<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
?.filter((c) => c.section === tab)
.map((comment) => {
return (
<Comment
key={comment.id}

@ -8,11 +8,10 @@ import type { ResumeComment } from '~/types/resume-comments';
export const resumeReviewsRouter = createRouter().query('list', {
input: z.object({
resumeId: z.string(),
section: z.nativeEnum(ResumesSection),
}),
async resolve({ ctx, input }) {
const userId = ctx.session?.user?.id;
const { resumeId, section } = input;
const { resumeId } = input;
// For this resume, we retrieve every comment's information, along with:
// The user's name and image to render
@ -42,7 +41,6 @@ export const resumeReviewsRouter = createRouter().query('list', {
},
where: {
resumeId,
section,
},
});

Loading…
Cancel
Save