Skip to content

Commit

Permalink
daedline field for notice containing opening tag
Browse files Browse the repository at this point in the history
  • Loading branch information
sandeep14k committed Oct 9, 2024
1 parent 6e21620 commit d28f37e
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
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
20 changes: 19 additions & 1 deletion components/Modals/ViewNotice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<Box sx={boxStyle} className="modalScroll">
<Stack spacing={3}>
Expand Down Expand Up @@ -55,6 +62,17 @@ function ViewNotice({ currentNotice }: { currentNotice: NoticeParams }) {
readOnly: true,
}}
/>
{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 @@ -140,6 +140,7 @@ function Index() {
created_by: "",
CreatedAt: "",
last_reminder_at: 0,
deadline: "",
});

const [openView, setOpenView] = useState(false);
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 @@ -60,6 +60,7 @@ function Notices() {
created_by: "",
CreatedAt: "",
last_reminder_at: 0,
deadline: "",
});

useEffect(() => {
Expand Down

0 comments on commit d28f37e

Please sign in to comment.