Skip to content

Commit 7494d84

Browse files
authored
Add CPEx notifications (#3665)
* Add CPEx notifications * Show minutes in notification text
1 parent d99218b commit 7494d84

File tree

3 files changed

+29
-6
lines changed

3 files changed

+29
-6
lines changed

website/src/config/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export const regPeriods = [
1212
'Select Tutorials / Labs',
1313
'Add / Swap Tutorials',
1414
'Submit Course Requests',
15+
'Course Planning Exercise (CPEx)',
1516
] as const;
1617
export type RegPeriodType = (typeof regPeriods)[number];
1718

@@ -75,8 +76,8 @@ export function convertModRegDates(roundData: (typeof modRegData)[ScheduleType])
7576
return roundData.map((data) => ({
7677
...data,
7778
type: data.type as RegPeriodType,
78-
start: format(new Date(data.start), 'EEEE do LLLL, haaaa'),
79-
end: format(new Date(data.end), 'EEEE do LLLL, haaaa'),
79+
start: format(new Date(data.start), 'EEEE do LLLL, h:mm aaaa'),
80+
end: format(new Date(data.end), 'EEEE do LLLL, h:mm aaaa'),
8081
startDate: new Date(data.start),
8182
endDate: new Date(data.end),
8283
}));

website/src/data/modreg-schedule.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@
4141
"name": "",
4242
"start": "2024-01-22T09:00:00+08:00",
4343
"end": "2024-01-23T17:00:00+08:00"
44+
},
45+
{
46+
"type": "Course Planning Exercise (CPEx)",
47+
"name": "",
48+
"start": "2024-03-11T00:00:00+08:00",
49+
"end": "2024-03-15T23:59:59+08:00"
4450
}
4551
],
4652
"Graduate": [
@@ -85,6 +91,12 @@
8591
"name": "",
8692
"start": "2024-01-22T09:00:00+08:00",
8793
"end": "2024-01-23T17:00:00+08:00"
94+
},
95+
{
96+
"type": "Course Planning Exercise (CPEx)",
97+
"name": "",
98+
"start": "2024-03-11T00:00:00+08:00",
99+
"end": "2024-03-15T23:59:59+08:00"
88100
}
89101
]
90102
}

website/src/views/components/notfications/ModRegNotification.tsx

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { FC, memo, useCallback } from 'react';
22
import { useDispatch, useSelector } from 'react-redux';
3-
import { useHistory } from 'react-router-dom';
3+
import { useHistory, NavLink } from 'react-router-dom';
44
import { formatDistance } from 'date-fns';
55

66
import type { State } from 'types/state';
77

8-
import config, { RegPeriod } from 'config';
8+
import config, { RegPeriod, RegPeriodType } from 'config';
99
import { dismissModregNotification } from 'actions/settings';
1010
import { openNotification } from 'actions/app';
1111
import { getRounds } from 'selectors/modreg';
@@ -39,6 +39,16 @@ const NotificationText: FC<{
3939
);
4040
};
4141

42+
const NotificationLink: FC<{
43+
roundType: RegPeriodType;
44+
children: React.ReactNode;
45+
}> = ({ roundType, children }) =>
46+
roundType === 'Course Planning Exercise (CPEx)' ? (
47+
<NavLink to="/cpex">{children}</NavLink>
48+
) : (
49+
<ExternalLink href={MOD_REG_URL}>{children}</ExternalLink>
50+
);
51+
4252
const ModRegNotification: FC<{
4353
// True only on the settings page since we don't want
4454
// users accidentally dismissing the preview notification
@@ -77,11 +87,11 @@ const ModRegNotification: FC<{
7787
<div className={styles.container}>
7888
{rounds.map((round) => (
7989
<div className={styles.notificationWrapper} key={round.type}>
80-
<ExternalLink href={MOD_REG_URL}>
90+
<NotificationLink roundType={round.type}>
8191
<div className={styles.notification}>
8292
<NotificationText useLineBreaks round={round} now={forceTimer() || new Date()} />
8393
</div>
84-
</ExternalLink>
94+
</NotificationLink>
8595

8696
{!dismissible && <CloseButton className={styles.close} onClick={() => dismiss(round)} />}
8797
</div>

0 commit comments

Comments
 (0)