Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance report course error button visibility during coursereg/course update periods #3963

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions website/src/views/components/notfications/Announcements.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@
*/
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
};

junnjiee marked this conversation as resolved.
Show resolved Hide resolved
const Announcements = memo(() => {
const [isOpen, setIsOpen] = useState(() => {
if (!enableAnnouncements) return false;
Expand Down
4 changes: 2 additions & 2 deletions website/src/views/modules/ModulePageContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,9 @@ const ModulePageContent: React.FC<Props> = ({ module, archiveYear }) => {
</>
)}

<p>
<div>
<ReportError module={module} />
</p>
</div>
</div>
</section>
</div>
Expand Down
11 changes: 11 additions & 0 deletions website/src/views/modules/ReportError.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@
}
}

.enhanceButton {
justify-content: center;
padding: 0.5em 0;
}

.infoText {
padding-top: 0.5em;
font-style: italic;
font-size: 0.9em;
}

.heading {
font-weight: bold;
font-size: 1.4rem;
Expand Down
25 changes: 24 additions & 1 deletion website/src/views/modules/ReportError.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { produce } from 'immer';
import axios from 'axios';
import { AlertTriangle } from 'react-feather';
import * as Sentry from '@sentry/browser';
import { addWeeks, isWithinInterval } from 'date-fns';
import modregData from 'data/modreg-schedule.json';

import type {
DepartmentMatch,
Expand All @@ -18,6 +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 { isNewCourseDataAnnoucement } from 'views/components/notfications/Announcements';
import facultyEmails from 'data/facultyEmail';
import appConfig from 'config';
import useGlobalDebugValue from '../hooks/useGlobalDebugValue';
Expand Down Expand Up @@ -104,6 +107,17 @@ function matchModule(module: Module) {
);
}

const roundOneStartDate = new Date(
modregData.Undergraduate.filter(
(data) => data.type === 'Select Courses' && data.name === '1',
)[0].start,
);
const enhanceReportVisibility =
isWithinInterval(new Date(), {
start: addWeeks(roundOneStartDate, -2),
end: addWeeks(roundOneStartDate, 2),
}) || isNewCourseDataAnnoucement();

/**
* Module error reporting component. Posts to a serverless script that then emails the relevant
* faculty / department with the issue.
Expand Down Expand Up @@ -165,12 +179,21 @@ const ReportError = memo<Props>(({ module }) => {
<>
<button
type="button"
className={classnames('btn btn-link', styles.button)}
className={classnames(
'btn',
styles.button,
enhanceReportVisibility ? ['btn-primary btn-block', styles.enhanceButton] : 'btn-link',
)}
onClick={() => setIsOpen(!isOpen)}
>
<AlertTriangle className={styles.icon} />
Report errors
</button>
{enhanceReportVisibility && (
<p className={styles.infoText}>
For clarifications on how we handle issues, read our <a href="/faq">FAQ</a>.
</p>
)}

<Modal
isOpen={isOpen}
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