[resumes][feat] Filter comments

pull/320/head
Terence Ho 3 years ago
parent 17c68852c2
commit 84af917ef3

@ -6,6 +6,8 @@ import { trpc } from '~/utils/trpc';
import CommentsListButton from './CommentsListButton';
import { COMMENTS_SECTIONS } from './constants';
import type { ResumeComment } from '~/types/resume-comments';
type CommentsListProps = Readonly<{
resumeId: string;
setShowCommentsForm: (show: boolean) => void;
@ -16,12 +18,19 @@ export default function CommentsList({
setShowCommentsForm,
}: CommentsListProps) {
const [tab, setTab] = useState(COMMENTS_SECTIONS[0].value);
const [comments, setComments] = useState<Array<ResumeComment>>([]);
const onFetchComments = (data: Array<ResumeComment>) => {
const filteredComments = data.filter((comment) => {
return comment.section === tab;
});
const commentsQuery = trpc.useQuery(['resumes.reviews.list', { resumeId }]);
setComments(filteredComments);
};
/* eslint-disable no-console */
console.log(commentsQuery.data);
/* eslint-enable no-console */
trpc.useQuery(['resumes.reviews.list', { resumeId }], {
onSuccess: onFetchComments,
});
return (
<div className="space-y-3">

Loading…
Cancel
Save