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

MS1.5 Fix an issue where the site is wrong #51

Merged
merged 6 commits into from
Feb 28, 2021
Merged
Show file tree
Hide file tree
Changes from 5 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
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.2",
"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
18 changes: 13 additions & 5 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 @@ -92,7 +94,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 @@ -138,6 +141,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 @@ -158,10 +165,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);
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 @@ -251,6 +258,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"
};