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..667222f1 100644 --- a/components/Modals/ViewNotice.tsx +++ b/components/Modals/ViewNotice.tsx @@ -19,11 +19,22 @@ const boxStyle = { overflowY: "scroll", 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 +66,20 @@ function ViewNotice({ currentNotice }: { currentNotice: NoticeParams }) { readOnly: true, }} /> + + {/* Conditionally render the deadline field if "opening" is present in tags */} + {isOpeningTag && ( + + )} + Description