From 3f16447d32921fff9f31d888f86319db054cf50a Mon Sep 17 00:00:00 2001 From: mxmlnwbr <71628027+mxmlnwbr@users.noreply.github.com> Date: Wed, 13 Dec 2023 11:02:57 +0100 Subject: [PATCH] fix(app): supervisedBy unassigned resolved (#18) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Roland Schläfli --- src/components/ProposalMeta.tsx | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/components/ProposalMeta.tsx b/src/components/ProposalMeta.tsx index 3543b20..ee6d4c7 100644 --- a/src/components/ProposalMeta.tsx +++ b/src/components/ProposalMeta.tsx @@ -1,7 +1,9 @@ import { IconDefinition, faFilePdf } from '@fortawesome/free-regular-svg-icons' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { format, parseISO } from 'date-fns' +import { useSession } from 'next-auth/react' import Link from 'next/link' +import { useMemo } from 'react' import { ProposalDetails } from 'src/types/app' interface ProposalMetaProps { @@ -12,7 +14,20 @@ const FileTypeIconMap: Record = { 'application/pdf': faFilePdf, } export default function ProposalMeta({ proposalDetails }: ProposalMetaProps) { + const { data: session } = useSession() + + const supervisedBy = useMemo(() => { + if (session?.user?.email && proposalDetails?.supervisedBy?.length > 0) { + return proposalDetails.supervisedBy[0].supervisor.name + } else if (proposalDetails?.supervisedBy.name) { + return proposalDetails.supervisedBy.name + } else { + return 'Unassigned' + } + }, [session, proposalDetails]) + if (!proposalDetails) return null + return (

{proposalDetails.title}

@@ -51,7 +66,7 @@ export default function ProposalMeta({ proposalDetails }: ProposalMetaProps) { )}
Supervised By
-
{proposalDetails.supervisedBy?.name ?? 'Unassigned'}
+
{supervisedBy}
{proposalDetails.typeKey === 'STUDENT' && ( @@ -68,7 +83,7 @@ export default function ProposalMeta({ proposalDetails }: ProposalMetaProps) {
{proposalDetails.typeKey === 'STUDENT' && ( -
+
{proposalDetails.attachments.map((attachment: any) => (