From 3f6ae58374329db1098e0529bbef52c657132f68 Mon Sep 17 00:00:00 2001 From: Terence <45381509+Vielheim@users.noreply.github.com> Date: Mon, 24 Oct 2022 16:02:41 +0800 Subject: [PATCH] [resumes][refactor] Update resume review page UI (#418) * [resumes][refactor] update comments ui * [resumes][refactor] change comment border color * [resumes][refactor] update review ui * [resumes][refactor] rearrange review page * update add review button Co-authored-by: Terence Ho <> --- .../comments/ResumeCommentListItem.tsx | 37 +++--- .../resumes/comments/ResumeCommentsForm.tsx | 2 +- .../resumes/comments/ResumeCommentsList.tsx | 69 ++++++------ .../comments/ResumeCommentsSection.tsx | 40 ------- .../comment/ResumeCommentVoteButtons.tsx | 2 +- .../resumes/shared/ResumeSignInButton.tsx | 2 +- apps/portal/src/pages/resumes/[resumeId].tsx | 106 +++++++++++++----- 7 files changed, 138 insertions(+), 120 deletions(-) delete mode 100644 apps/portal/src/components/resumes/comments/ResumeCommentsSection.tsx diff --git a/apps/portal/src/components/resumes/comments/ResumeCommentListItem.tsx b/apps/portal/src/components/resumes/comments/ResumeCommentListItem.tsx index dd44d4b4..98384595 100644 --- a/apps/portal/src/components/resumes/comments/ResumeCommentListItem.tsx +++ b/apps/portal/src/components/resumes/comments/ResumeCommentListItem.tsx @@ -1,4 +1,5 @@ import clsx from 'clsx'; +import { formatDistanceToNow } from 'date-fns'; import { useState } from 'react'; import { ChevronUpIcon } from '@heroicons/react/20/solid'; import { FaceSmileIcon } from '@heroicons/react/24/outline'; @@ -26,12 +27,7 @@ export default function ResumeCommentListItem({ const [showReplies, setShowReplies] = useState(true); return ( -
+
{/* Image Icon */} {comment.user.image ? ( @@ -58,7 +54,7 @@ export default function ResumeCommentListItem({

{comment.user.name ?? 'Reviewer ABC'} @@ -72,9 +68,8 @@ export default function ResumeCommentListItem({

- {comment.createdAt.toLocaleString('en-US', { - dateStyle: 'medium', - timeStyle: 'short', + {formatDistanceToNow(comment.createdAt, { + addSuffix: true, })}
@@ -86,10 +81,12 @@ export default function ResumeCommentListItem({ setIsEditingComment={setIsEditingComment} /> ) : ( - +
+ +
)} {/* Upvote and edit */} @@ -143,7 +140,15 @@ export default function ResumeCommentListItem({ !showReplies && 'rotate-180 transform', )} /> - {showReplies ? 'Hide replies' : 'Show replies'} + + {showReplies + ? `Hide ${ + comment.children.length === 1 ? 'reply' : 'replies' + }` + : `Show ${comment.children.length} ${ + comment.children.length === 1 ? 'reply' : 'replies' + }`} + {showReplies && ( @@ -152,7 +157,7 @@ export default function ResumeCommentListItem({
-
+
{comment.children.map((child) => { return ( +

Add your review

Please fill in at least one section to submit your review diff --git a/apps/portal/src/components/resumes/comments/ResumeCommentsList.tsx b/apps/portal/src/components/resumes/comments/ResumeCommentsList.tsx index b0435cda..b7cf69af 100644 --- a/apps/portal/src/components/resumes/comments/ResumeCommentsList.tsx +++ b/apps/portal/src/components/resumes/comments/ResumeCommentsList.tsx @@ -1,7 +1,9 @@ +import clsx from 'clsx'; import { useSession } from 'next-auth/react'; import { BookOpenIcon, BriefcaseIcon, + ChatBubbleLeftRightIcon, CodeBracketSquareIcon, FaceSmileIcon, IdentificationIcon, @@ -9,24 +11,20 @@ import { } 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'; import { RESUME_COMMENTS_SECTIONS } from './resumeCommentConstants'; import ResumeCommentListItem from './ResumeCommentListItem'; -import ResumeSignInButton from '../shared/ResumeSignInButton'; import type { ResumeComment } from '~/types/resume-comments'; type ResumeCommentsListProps = Readonly<{ resumeId: string; - setShowCommentsForm: (show: boolean) => void; }>; export default function ResumeCommentsList({ resumeId, - setShowCommentsForm, }: ResumeCommentsListProps) { const { data: sessionData } = useSession(); @@ -50,31 +48,14 @@ export default function ResumeCommentsList({ } }; - const renderButton = () => { - if (sessionData === null) { - return ; - } - return ( - -

+
{commentVotesQuery.data?.numVotes ?? 0}
diff --git a/apps/portal/src/components/resumes/shared/ResumeSignInButton.tsx b/apps/portal/src/components/resumes/shared/ResumeSignInButton.tsx index c02fac75..c470dffb 100644 --- a/apps/portal/src/components/resumes/shared/ResumeSignInButton.tsx +++ b/apps/portal/src/components/resumes/shared/ResumeSignInButton.tsx @@ -8,7 +8,7 @@ type Props = Readonly<{ export default function ResumeSignInButton({ text, className }: Props) { return ( -
+

{ if (session?.user?.id == null) { @@ -81,6 +83,32 @@ export default function ResumeReviewPage() { setIsEditMode(true); }; + const renderReviewButton = () => { + if (session === null) { + return ( +

+ ); + } + return ( + + )} + - {userIsOwner && ( - - )} + +
{renderReviewButton()}
-
+
-
+
-
+
-
+
{detailsQuery.data.additionalInfo && ( -
+
)} -
-
+ +
+
- +
+ + +
{renderReviewButton()}
+ + {showCommentsForm ? ( + + ) : ( + + )}