Skip to content

Commit

Permalink
MS1.5 Fix an issue where the site is wrong (#51)
Browse files Browse the repository at this point in the history
Fix #50 to ensure the site works:
Issue was that we told the site to go forward 1 week on Sundays and Saturdays, which resulted in it skipping a week forward. This is because the algorithm works by rewinding to the last Sunday and going from there, so on Sundays it obviously stays on the current Sunday, and it was programmed to jump forward 7 days on Sundays

Also adds a alert on Lateral Flow Testing & version bump

Commits:
* Change alert

* Setup separate KECHG and KECHB alerts

* Fixed an issue where date was wrong #50
Added alerts to holiday page

* Bump version number

* Remove date fiddling
  • Loading branch information
Gum-Joe committed Mar 2, 2021
1 parent 8bddb71 commit d2b6b4c
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 11 deletions.
23 changes: 23 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch Edge",
"request": "launch",
"type": "pwa-msedge",
"url": "http://localhost:3000",
"webRoot": "${workspaceFolder}/frontend"
},
{
"name": "Attach to Edge",
"port": 9222,
"request": "attach",
"type": "pwa-msedge",
"webRoot": "${workspaceFolder}/frontend"
}

]
}
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "frontend",
"version": "1.0.0-beta.3",
"version": "1.0.0-beta.4",
"private": true,
"dependencies": {
"@fortawesome/fontawesome-svg-core": "^1.2.34",
Expand Down
8 changes: 8 additions & 0 deletions frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import Cookies from "js-cookie";
import { COOKIE_SCHOOL_PREFERENCE } from "./utils/constants";
import { KECHBEvents, KECHGEvents } from "./data/events-mock";
import Footer from "./components/Footer";
import { KECHBAlerts, KECHGAlerts } from "./data/alerts";

/*function App() {
return (
Expand Down Expand Up @@ -79,6 +80,9 @@ class App extends Component<Record<string, never>> {
eventsFetcher={
async () => KECHBEvents
}
alertsFetcher={
async () => KECHBAlerts
}
/>
),
},
Expand All @@ -91,6 +95,10 @@ class App extends Component<Record<string, never>> {
eventsFetcher={
async () => KECHGEvents
}

alertsFetcher={
async () => KECHGAlerts
}
/>
),
},
Expand Down
20 changes: 13 additions & 7 deletions frontend/src/components/SiteContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ export interface SiteProps {
weekMarkerDate: GregorianDay;
/** Events data - eventually replaced with state */
eventsFetcher: () => Promise<EventData>;
/** Fetches site alert */
alertsFetcher: () => Promise<AlertResponce>;
}

const baseEventImageStyle = {
Expand Down Expand Up @@ -100,7 +102,8 @@ export default class SiteContainer extends Component<SiteProps, TheState> {

// const response: AlertResponce = await baseResponse.json();

const response = KECHBAlerts;
//const response = KECHBAlerts;
const response = await this.props.alertsFetcher();

this.setState({
alert: response,
Expand Down Expand Up @@ -146,6 +149,10 @@ export default class SiteContainer extends Component<SiteProps, TheState> {
forwardOrRewindToDay(d: Date, goTo: GregorianDay, forwardList: number[]) {
const dhere = new Date(d);
const day = dhere.getUTCDay();
//console.log(day);
//console.log(dhere.getUTCDate());
//console.log(forwardList);
//console.log(goTo);
// Sunday is day 0
// Sat is Day 6
// If Sun or Sat go to next week
Expand All @@ -167,12 +174,10 @@ export default class SiteContainer extends Component<SiteProps, TheState> {
async getCalendar() {
const inputDate = new Date();
// Used for fiddling:
// inputDate.setDate(1);
// inputDate.setMonth(0);
// inputDate.setFullYear(2021);

// THis is where we get the date in the calendar to look for (i.e. go back to the last or next Monday)
const weekStart = this.forwardOrRewindToDay(inputDate, this.props.weekMarkerDate, [0, 6]);
//inputDate.setDate(1);
//inputDate.setMonth(2);
//inputDate.setFullYear(2021);
const weekStart = this.forwardOrRewindToDay(inputDate, this.props.weekMarkerDate, [6]);
weekStart.setUTCHours(0, 0, 0, 0); // Set to start of day
const weekEnd = new Date(weekStart);
weekEnd.setUTCDate(weekEnd.getUTCDate() + 1);
Expand Down Expand Up @@ -263,6 +268,7 @@ export default class SiteContainer extends Component<SiteProps, TheState> {
// NOTE: getScrollDownWithAdditional was originally fed 150 instead of 0
return (
<>
{this.state.alert.showAlert ? <AlertBanner alert={this.state.alert} /> : null}
<h2>It is neither Week A nor B.</h2>
<h3>This means it&#39;s probably a holiday.</h3>
<Button style={{ marginRight: "auto" }} className="forward" onClick={getScrollDownWithAdditional(0)}><div>events</div></Button>
Expand Down
16 changes: 13 additions & 3 deletions frontend/src/data/alerts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,18 @@ export const KECHBAlerts: AlertResponce = {
showAlert: true,
//message: "BREAKING: Student Council Chair Adeen Irfan has resigned, triggering an election.",
// alertLevel: ThreatLevels.CRITICAL,
message: "NEWS: KECHB team \"The Standard Solutions\" wins the Cambridge Chemistry Race, beating 48 other schools from across the country",
message: "Lateral Flow Testing: Please keep an eye on your parent/guardian's emails. You should have been already been sent some information.",
alertLevel: ThreatLevels.SEVERE,
//linkText: "more info",
//linkTo: "https://twitter.com/KEVICHB/status/1359153991104557064?s=20"
};

export const KECHGAlerts: AlertResponce = {
showAlert: false,
//message: "BREAKING: Student Council Chair Adeen Irfan has resigned, triggering an election.",
// alertLevel: ThreatLevels.CRITICAL,
message: "Welcome to IsItWeekA! We'll use these banner for important alerts in the future.",
alertLevel: ThreatLevels.LOW,
linkText: "more info",
linkTo: "https://twitter.com/KEVICHB/status/1359153991104557064?s=20"
//linkText: "more info",
//linkTo: "https://twitter.com/KEVICHB/status/1359153991104557064?s=20"
};

0 comments on commit d2b6b4c

Please sign in to comment.