From d28f37ef2869915b2f99d2b7f1f9009becaeaf88 Mon Sep 17 00:00:00 2001 From: sandeep14k Date: Wed, 9 Oct 2024 11:44:45 +0530 Subject: [PATCH] daedline field for notice containing opening tag --- callbacks/admin/rc/notice.ts | 1 + components/Modals/ViewNotice.tsx | 20 +++++++++++++++++++- pages/admin/rc/[rcid]/notice.tsx | 1 + pages/student/rc/[rcid]/notices.tsx | 1 + 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/callbacks/admin/rc/notice.ts b/callbacks/admin/rc/notice.ts index 5b233ddf..94636f2c 100644 --- a/callbacks/admin/rc/notice.ts +++ b/callbacks/admin/rc/notice.ts @@ -19,6 +19,7 @@ export interface NoticeParams { created_by: string; CreatedAt: string; last_reminder_at: number; + deadline: string; } export interface NoticeResponse { title: string; diff --git a/components/Modals/ViewNotice.tsx b/components/Modals/ViewNotice.tsx index 8413bb1c..d607fab9 100644 --- a/components/Modals/ViewNotice.tsx +++ b/components/Modals/ViewNotice.tsx @@ -20,10 +20,17 @@ const boxStyle = { maxHeight: "90vh", }; function ViewNotice({ currentNotice }: { currentNotice: NoticeParams }) { - let value = currentNotice.CreatedAt; + const value = currentNotice.CreatedAt; const publishedDateAndTime = `${new Date(value).toLocaleDateString( "en-GB" )} ${new Date(value).toLocaleTimeString()}`; + const isOpeningTag = currentNotice.tags.includes("opening"); + function formatDeadline(deadline: string): string { + return deadline === "0001-01-01T00:00:00Z" + ? "N/A" + : new Date(deadline).toLocaleString(); + } + const deadlineDate = formatDeadline(currentNotice.deadline); return ( @@ -55,6 +62,17 @@ function ViewNotice({ currentNotice }: { currentNotice: NoticeParams }) { readOnly: true, }} /> + {isOpeningTag && ( + + )} Description {