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

weeks of classes checking on today dashboard #3814

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
15 changes: 13 additions & 2 deletions website/src/views/today/TodayContainer/TodayContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,19 @@ export class TodayContainerComponent extends React.PureComponent<Props, State> {

export const mapStateToProps = (state: StoreState, ownProps: OwnProps) => {
const { modules } = state.moduleBank;
const lastDay = addDays(ownProps.currentTime, DAYS);
const weekInfo = NUSModerator.academicCalendar.getAcadWeekInfo(lastDay);

const lastDay = addDays(ownProps.currentTime, DAYS); // current date plus 7 days
const todayWeekInfo = NUSModerator.academicCalendar.getAcadWeekInfo(new Date());
const nextWeekInfo = NUSModerator.academicCalendar.getAcadWeekInfo(lastDay);

var todaySemester = semesterNameMap[todayWeekInfo.sem];
var nextWeekSemester = semesterNameMap[nextWeekInfo.sem];

// On week -1 of semester 2, the semester should be 2, not 1
const weekBeforeSem2 = (todaySemester === 1 && nextWeekSemester === 2);
// If it's the week before semester 2, use sem2's week info, otherwise use current date's week info
const weekInfo = weekBeforeSem2 ? nextWeekInfo : todayWeekInfo;

const semester = semesterNameMap[weekInfo.sem];
const timetable = getSemesterTimetableLessons(state)(semester);
const colors = getSemesterTimetableColors(state)(semester);
Expand Down