From cc462ab6ab0d1cfd38d2cde148c54b694e524414 Mon Sep 17 00:00:00 2001 From: Su Yin <53945359+tnsyn@users.noreply.github.com> Date: Mon, 10 Oct 2022 14:09:01 +0800 Subject: [PATCH] [resumes][feat] Add sign in buttons on browse page (#350) * [resumes][fix] Add gap between sections in resume list item * [resumes][refactor] Abstract out sign in button * [resumes][feat] Add sign in buttons on browse page --- .../src/components/resumes/SignInButton.tsx | 24 ++++++++++ .../resumes/browse/ResumeListItem.tsx | 2 +- .../resumes/browse/ResumeListItems.tsx | 22 ++++----- .../resumes/comments/CommentsList.tsx | 20 +++++++- .../resumes/comments/CommentsListButton.tsx | 48 ------------------- apps/portal/src/pages/resumes/index.tsx | 35 ++++++++++---- 6 files changed, 80 insertions(+), 71 deletions(-) create mode 100644 apps/portal/src/components/resumes/SignInButton.tsx delete mode 100644 apps/portal/src/components/resumes/comments/CommentsListButton.tsx diff --git a/apps/portal/src/components/resumes/SignInButton.tsx b/apps/portal/src/components/resumes/SignInButton.tsx new file mode 100644 index 00000000..8718e588 --- /dev/null +++ b/apps/portal/src/components/resumes/SignInButton.tsx @@ -0,0 +1,24 @@ +import { signIn } from 'next-auth/react'; + +type Props = Readonly<{ + text: string; +}>; + +export default function SignInButton({ text }: Props) { + return ( +
+

+ { + event.preventDefault(); + signIn(); + }}> + Sign in + {' '} + {text} +

+
+ ); +} diff --git a/apps/portal/src/components/resumes/browse/ResumeListItem.tsx b/apps/portal/src/components/resumes/browse/ResumeListItem.tsx index a76a503a..53c33e78 100644 --- a/apps/portal/src/components/resumes/browse/ResumeListItem.tsx +++ b/apps/portal/src/components/resumes/browse/ResumeListItem.tsx @@ -14,7 +14,7 @@ type Props = Readonly<{ export default function BrowseListItem({ href, resumeInfo }: Props) { return ( -
+
{resumeInfo.title}
diff --git a/apps/portal/src/components/resumes/browse/ResumeListItems.tsx b/apps/portal/src/components/resumes/browse/ResumeListItems.tsx index 9e1203a5..5e834665 100644 --- a/apps/portal/src/components/resumes/browse/ResumeListItems.tsx +++ b/apps/portal/src/components/resumes/browse/ResumeListItems.tsx @@ -19,17 +19,15 @@ export default function ResumeListItems({ isLoading, resumes }: Props) { } return ( -
-
    - {resumes.map((resumeObj: Resume) => ( -
  • - -
  • - ))} -
-
+
    + {resumes.map((resumeObj: Resume) => ( +
  • + +
  • + ))} +
); } diff --git a/apps/portal/src/components/resumes/comments/CommentsList.tsx b/apps/portal/src/components/resumes/comments/CommentsList.tsx index d40b500a..e3d9f532 100644 --- a/apps/portal/src/components/resumes/comments/CommentsList.tsx +++ b/apps/portal/src/components/resumes/comments/CommentsList.tsx @@ -1,11 +1,13 @@ +import { useSession } from 'next-auth/react'; import { useState } from 'react'; import { Tabs } from '@tih/ui'; +import { Button } from '@tih/ui'; import { trpc } from '~/utils/trpc'; import CommentListItems from './CommentListItems'; -import CommentsListButton from './CommentsListButton'; import { COMMENTS_SECTIONS } from './constants'; +import SignInButton from '../SignInButton'; type CommentsListProps = Readonly<{ resumeId: string; @@ -16,13 +18,27 @@ export default function CommentsList({ resumeId, setShowCommentsForm, }: CommentsListProps) { + const { data: sessionData } = useSession(); const [tab, setTab] = useState(COMMENTS_SECTIONS[0].value); const commentsQuery = trpc.useQuery(['resumes.reviews.list', { resumeId }]); + const renderButton = () => { + if (sessionData === null) { + return ; + } + return ( +
- +
+ {renderSignInButton && } + +