Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deadline #341

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions callbacks/admin/rc/notice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export interface NoticeParams {
created_by: string;
CreatedAt: string;
last_reminder_at: number;
deadline: string;
}
export interface NoticeResponse {
title: string;
Expand Down
27 changes: 26 additions & 1 deletion components/Modals/ViewNotice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<Box sx={boxStyle} className="modalScroll">
<Stack spacing={3}>
Expand Down Expand Up @@ -55,6 +66,20 @@ function ViewNotice({ currentNotice }: { currentNotice: NoticeParams }) {
readOnly: true,
}}
/>

{/* Conditionally render the deadline field if "opening" is present in tags */}
{isOpeningTag && (
<TextField
multiline
label="Deadline"
defaultValue={deadlineDate}
variant="standard"
InputProps={{
readOnly: true,
}}
/>
)}

<small style={{ fontWeight: 300 }}>Description</small>
<RichText
// eslint-disable-next-line @typescript-eslint/no-empty-function
Expand Down
1 change: 1 addition & 0 deletions pages/admin/rc/[rcid]/notice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ function Index() {
attachment: "",
created_by: "",
CreatedAt: "",
deadline: "",
last_reminder_at: 0,
});

Expand Down
1 change: 1 addition & 0 deletions pages/student/rc/[rcid]/notices.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ function Notices() {
attachment: "",
created_by: "",
CreatedAt: "",
daedline: "",
last_reminder_at: 0,
});

Expand Down
Loading