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