Skip to content

Commit e7b9527

Browse files
junnjieejloh02
andauthored
website: Enhance report course error button visibility during coursereg/course update periods (#3963)
* enhance error button visibility during coursereg and new course info periods * export fn to check for new data announcements, add link to FAQ --------- Co-authored-by: Jonathan Loh <[email protected]>
1 parent d4a51e2 commit e7b9527

File tree

5 files changed

+48
-7
lines changed

5 files changed

+48
-7
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ const enableAnnouncements = true;
3333
*/
3434
const key = announcementKey('ay202425-new-data');
3535

36+
export const isNewCourseDataAnnoucement = () => {
37+
if (key) {
38+
return enableAnnouncements && key.includes('new-data');
39+
}
40+
return false;
41+
};
42+
3643
const Announcements = memo(() => {
3744
const [isOpen, setIsOpen] = useState(() => {
3845
if (!enableAnnouncements) return false;

website/src/views/modules/ModulePageContent.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,9 +258,9 @@ const ModulePageContent: React.FC<Props> = ({ module, archiveYear }) => {
258258
</>
259259
)}
260260

261-
<p>
261+
<div>
262262
<ReportError module={module} />
263-
</p>
263+
</div>
264264
</div>
265265
</section>
266266
</div>

website/src/views/modules/ReportError.scss

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@
66
}
77
}
88

9+
.enhanceButton {
10+
justify-content: center;
11+
padding: 0.5em 0;
12+
}
13+
14+
.infoText {
15+
padding-top: 0.5em;
16+
font-style: italic;
17+
font-size: 0.9em;
18+
}
19+
920
.heading {
1021
font-weight: bold;
1122
font-size: 1.4rem;

website/src/views/modules/ReportError.tsx

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import { produce } from 'immer';
55
import axios from 'axios';
66
import { AlertTriangle } from 'react-feather';
77
import * as Sentry from '@sentry/browser';
8+
import { addWeeks, isWithinInterval } from 'date-fns';
9+
import modregData from 'data/modreg-schedule.json';
810

911
import type {
1012
DepartmentMatch,
@@ -18,6 +20,7 @@ import type { Module } from 'types/modules';
1820
import Modal from 'views/components/Modal';
1921
import CloseButton from 'views/components/CloseButton';
2022
import ExternalLink from 'views/components/ExternalLink';
23+
import { isNewCourseDataAnnoucement } from 'views/components/notfications/Announcements';
2124
import facultyEmails from 'data/facultyEmail';
2225
import appConfig from 'config';
2326
import useGlobalDebugValue from '../hooks/useGlobalDebugValue';
@@ -104,6 +107,17 @@ function matchModule(module: Module) {
104107
);
105108
}
106109

110+
const roundOneStartDate = new Date(
111+
modregData.Undergraduate.filter(
112+
(data) => data.type === 'Select Courses' && data.name === '1',
113+
)[0].start,
114+
);
115+
const enhanceReportVisibility =
116+
isWithinInterval(new Date(), {
117+
start: addWeeks(roundOneStartDate, -2),
118+
end: addWeeks(roundOneStartDate, 2),
119+
}) || isNewCourseDataAnnoucement();
120+
107121
/**
108122
* Module error reporting component. Posts to a serverless script that then emails the relevant
109123
* faculty / department with the issue.
@@ -165,12 +179,21 @@ const ReportError = memo<Props>(({ module }) => {
165179
<>
166180
<button
167181
type="button"
168-
className={classnames('btn btn-link', styles.button)}
182+
className={classnames(
183+
'btn',
184+
styles.button,
185+
enhanceReportVisibility ? ['btn-primary btn-block', styles.enhanceButton] : 'btn-link',
186+
)}
169187
onClick={() => setIsOpen(!isOpen)}
170188
>
171189
<AlertTriangle className={styles.icon} />
172190
Report errors
173191
</button>
192+
{enhanceReportVisibility && (
193+
<p className={styles.infoText}>
194+
For clarifications on how we handle issues, read our <a href="/faq">FAQ</a>.
195+
</p>
196+
)}
174197

175198
<Modal
176199
isOpen={isOpen}

website/src/views/static/FaqContainer.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ const FaqContainer: React.FC = () => (
7878
<li>You have refreshed NUSMods after step 2.</li>
7979
</ol>
8080
<p>
81-
After you have done all the above and the error persists, please use the "Report Error"
82-
button on the course page to report an issue to the course's department or faculty. If the
83-
department or faculty for this course cannot be found on this list, please refer to
84-
CourseReg's contact list for{' '}
81+
After you have done all the above and the error persists, please use the{' '}
82+
<b>"Report Error"</b> button on the course page to report an issue to the course's
83+
department or faculty. If the department or faculty for this course cannot be found on this
84+
list, please refer to CourseReg's contact list for{' '}
8585
<ExternalLink href="https://www.nus.edu.sg/coursereg/docs/UGFac_Contacts.pdf">
8686
undergraduate
8787
</ExternalLink>{' '}

0 commit comments

Comments
 (0)