Skip to content

Commit

Permalink
export fn to check for new data announcements, add link to FAQ
Browse files Browse the repository at this point in the history
  • Loading branch information
junnjiee committed Jan 24, 2025
1 parent 2a23610 commit 9a6c34e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
11 changes: 9 additions & 2 deletions website/src/views/components/notfications/Announcements.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import styles from './Announcements.scss';
/**
* If false, hides announcement.
*/
export const enableAnnouncements = true;
const enableAnnouncements = true;

/**
* Unique key for the current announcement. If the announcement is not
Expand All @@ -31,7 +31,14 @@ export const enableAnnouncements = true;
* - 'ay201819-new-data' - AY2018/19 data is available
* - 'ay201819-s2-new-data' - S2 data available
*/
export const key = announcementKey('ay202425-new-data');
const key = announcementKey('ay202425-new-data');

export const isNewCourseDataAnnoucement = () => {
if (key) {
return enableAnnouncements && key.includes('new-data');
}
return false;

Check warning on line 40 in website/src/views/components/notfications/Announcements.tsx

View check run for this annotation

Codecov / codecov/patch

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

Added line #L40 was not covered by tests
};

const Announcements = memo(() => {
const [isOpen, setIsOpen] = useState(() => {
Expand Down
12 changes: 5 additions & 7 deletions website/src/views/modules/ReportError.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ import type { Module } from 'types/modules';
import Modal from 'views/components/Modal';
import CloseButton from 'views/components/CloseButton';
import ExternalLink from 'views/components/ExternalLink';
import {
enableAnnouncements,
key as announcementKey,
} from 'views/components/notfications/Announcements';
import { isNewCourseDataAnnoucement } from 'views/components/notfications/Announcements';
import facultyEmails from 'data/facultyEmail';
import appConfig from 'config';
import useGlobalDebugValue from '../hooks/useGlobalDebugValue';
Expand Down Expand Up @@ -119,8 +116,7 @@ const enhanceReportVisibility =
isWithinInterval(new Date(), {
start: addWeeks(roundOneStartDate, -2),
end: addWeeks(roundOneStartDate, 2),
}) ||
(enableAnnouncements && announcementKey?.slice(-8, announcementKey.length) === 'new-data');
}) || isNewCourseDataAnnoucement();

/**
* Module error reporting component. Posts to a serverless script that then emails the relevant
Expand Down Expand Up @@ -194,7 +190,9 @@ const ReportError = memo<Props>(({ module }) => {
Report errors
</button>
{enhanceReportVisibility && (
<p className={styles.infoText}>For issues related to course data, submit a report.</p>
<p className={styles.infoText}>
For clarifications on how we handle issues, read our <a href="/faq">FAQ</a>.
</p>
)}

<Modal
Expand Down
8 changes: 4 additions & 4 deletions website/src/views/static/FaqContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ const FaqContainer: React.FC = () => (
<li>You have refreshed NUSMods after step 2.</li>
</ol>
<p>
After you have done all the above and the error persists, please use the "Report Error"
button on the course page to report an issue to the course's department or faculty. If the
department or faculty for this course cannot be found on this list, please refer to
CourseReg's contact list for{' '}
After you have done all the above and the error persists, please use the{' '}
<b>"Report Error"</b> button on the course page to report an issue to the course's
department or faculty. If the department or faculty for this course cannot be found on this
list, please refer to CourseReg's contact list for{' '}
<ExternalLink href="https://www.nus.edu.sg/coursereg/docs/UGFac_Contacts.pdf">
undergraduate
</ExternalLink>{' '}
Expand Down

0 comments on commit 9a6c34e

Please sign in to comment.