diff --git a/apps/portal/src/components/resumes/comments/ResumeCommentListItem.tsx b/apps/portal/src/components/resumes/comments/ResumeCommentListItem.tsx index 66fd6004..a313a228 100644 --- a/apps/portal/src/components/resumes/comments/ResumeCommentListItem.tsx +++ b/apps/portal/src/components/resumes/comments/ResumeCommentListItem.tsx @@ -16,7 +16,7 @@ import type { ResumeComment } from '~/types/resume-comments'; type ResumeCommentListItemProps = { comment: ResumeComment; - userId?: string; + userId: string | undefined; }; type ICommentInput = { @@ -78,8 +78,8 @@ export default function ResumeCommentListItem({ }; return ( -
-
+
+
{comment.user.image ? ( {comment.user.name
-
+
{comment.createdAt.toLocaleString('en-US', { dateStyle: 'medium', timeStyle: 'short', @@ -123,7 +123,7 @@ export default function ResumeCommentListItem({ defaultValue={comment.description} disabled={commentUpdateMutation.isLoading} errorMessage={errors.description?.message} - label="Edit comment" + label="" placeholder="Leave your comment here" onChange={setFormValue} /> diff --git a/apps/portal/src/components/resumes/comments/ResumeCommentsList.tsx b/apps/portal/src/components/resumes/comments/ResumeCommentsList.tsx index 5b50f0ad..12e564a9 100644 --- a/apps/portal/src/components/resumes/comments/ResumeCommentsList.tsx +++ b/apps/portal/src/components/resumes/comments/ResumeCommentsList.tsx @@ -1,6 +1,14 @@ import { useSession } from 'next-auth/react'; -import { useState } from 'react'; -import { Spinner, Tabs } from '@tih/ui'; +import { + BookOpenIcon, + BriefcaseIcon, + CodeBracketSquareIcon, + FaceSmileIcon, + IdentificationIcon, + SparklesIcon, +} from '@heroicons/react/24/outline'; +import { ResumesSection } from '@prisma/client'; +import { Spinner } from '@tih/ui'; import { Button } from '@tih/ui'; import { trpc } from '~/utils/trpc'; @@ -21,23 +29,26 @@ export default function ResumeCommentsList({ setShowCommentsForm, }: ResumeCommentsListProps) { const { data: sessionData } = useSession(); - const [tab, setTab] = useState(RESUME_COMMENTS_SECTIONS[0].value); - const [tabs, setTabs] = useState(RESUME_COMMENTS_SECTIONS); - const commentsQuery = trpc.useQuery(['resumes.comments.list', { resumeId }], { - onSuccess: (data: Array) => { - const updatedTabs = RESUME_COMMENTS_SECTIONS.map(({ label, value }) => { - const count = data.filter(({ section }) => section === value).length; - const updatedLabel = count > 0 ? `${label} (${count})` : label; - return { - label: updatedLabel, - value, - }; - }); + const commentsQuery = trpc.useQuery(['resumes.comments.list', { resumeId }]); - setTabs(updatedTabs); - }, - }); + const renderIcon = (section: ResumesSection) => { + const className = 'h-8 w-8'; + switch (section) { + case ResumesSection.GENERAL: + return ; + case ResumesSection.EDUCATION: + return ; + case ResumesSection.EXPERIENCE: + return ; + case ResumesSection.PROJECTS: + return ; + case ResumesSection.SKILLS: + return ; + default: + return ; + } + }; const renderButton = () => { if (sessionData === null) { @@ -57,28 +68,44 @@ export default function ResumeCommentsList({
{renderButton()} - setTab(value)} - /> - {commentsQuery.isFetching ? (
) : ( -
- {(commentsQuery.data?.filter((c) => c.section === tab) ?? []).map( - (comment) => ( - - ), - )} +
+ {RESUME_COMMENTS_SECTIONS.map(({ label, value }) => { + const comments = commentsQuery.data + ? commentsQuery.data.filter((comment: ResumeComment) => { + return (comment.section as string) === value; + }) + : []; + const commentCount = comments.length; + + return ( +
+
+ {renderIcon(value)} + +
{label}
+
+ + {commentCount > 0 ? ( + comments.map((comment) => { + return ( + + ); + }) + ) : ( +
There are no comments for this section yet!
+ )} +
+ ); + })}
)}