|
1 | 1 | import { FC, memo, useCallback } from 'react';
|
2 | 2 | import { useDispatch, useSelector } from 'react-redux';
|
3 |
| -import { useHistory } from 'react-router-dom'; |
| 3 | +import { useHistory, NavLink } from 'react-router-dom'; |
4 | 4 | import { formatDistance } from 'date-fns';
|
5 | 5 |
|
6 | 6 | import type { State } from 'types/state';
|
7 | 7 |
|
8 |
| -import config, { RegPeriod } from 'config'; |
| 8 | +import config, { RegPeriod, RegPeriodType } from 'config'; |
9 | 9 | import { dismissModregNotification } from 'actions/settings';
|
10 | 10 | import { openNotification } from 'actions/app';
|
11 | 11 | import { getRounds } from 'selectors/modreg';
|
@@ -39,6 +39,16 @@ const NotificationText: FC<{
|
39 | 39 | );
|
40 | 40 | };
|
41 | 41 |
|
| 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 | + |
42 | 52 | const ModRegNotification: FC<{
|
43 | 53 | // True only on the settings page since we don't want
|
44 | 54 | // users accidentally dismissing the preview notification
|
@@ -77,11 +87,11 @@ const ModRegNotification: FC<{
|
77 | 87 | <div className={styles.container}>
|
78 | 88 | {rounds.map((round) => (
|
79 | 89 | <div className={styles.notificationWrapper} key={round.type}>
|
80 |
| - <ExternalLink href={MOD_REG_URL}> |
| 90 | + <NotificationLink roundType={round.type}> |
81 | 91 | <div className={styles.notification}>
|
82 | 92 | <NotificationText useLineBreaks round={round} now={forceTimer() || new Date()} />
|
83 | 93 | </div>
|
84 |
| - </ExternalLink> |
| 94 | + </NotificationLink> |
85 | 95 |
|
86 | 96 | {!dismissible && <CloseButton className={styles.close} onClick={() => dismiss(round)} />}
|
87 | 97 | </div>
|
|
0 commit comments