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

Frontend refactor: typescript added, updated packages, directory structure and functional components #55

Merged
merged 15 commits into from
Jun 9, 2024
Merged
8 changes: 4 additions & 4 deletions first-year-scraper/generate_schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ def format_cell(original_value):
return [x for sub in original_value.split("\n") for j in sub.split(" ") for x in j.split(",") if x]

def generate_schedule(valid_sheets, workbook, subjects_dict):
with open("../frontend/src/schedule.json", "r") as json_data:
with open("../frontend/src/data/schedule.json", "r") as json_data:
schedule_dict = json.load(json_data)
with open("../frontend/src/empty_schedule.json", "r") as json_data:
with open("../frontend/src/data/empty_schedule.json", "r") as json_data:
empty_schedule_dict = json.load(json_data)

for sheet in valid_sheets:
Expand All @@ -42,10 +42,10 @@ def generate_schedule(valid_sheets, workbook, subjects_dict):
if(room in empty_schedule_dict[i][j]):
empty_schedule_dict[i][j].remove(room)

with open("../frontend/src/schedule.json", "w") as outfile:
with open("../frontend/src/data/schedule.json", "w") as outfile:
json.dump(schedule_dict, outfile, indent=2)

with open("../frontend/src/empty_schedule.json", "w") as outfile:
with open("../frontend/src/data/empty_schedule.json", "w") as outfile:
json.dump(empty_schedule_dict, outfile, indent=2)


Expand Down
4 changes: 2 additions & 2 deletions first-year-scraper/generate_subjectDetails.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ def generate_subjectDetails():
get_cell_value(5, i+4).upper()+" TUTORIAL",
]

with open("../frontend/src/subjectDetails.json", "r") as json_data:
with open("../frontend/src/data/subjectDetails.json", "r") as json_data:
subject_details = json.load(json_data)

for key in subjects_dict.keys():
subject_details[subjects_dict[key][0]] = subjects_dict[key][1]

with open("../frontend/src/subjectDetails.json", "w") as outfile:
with open("../frontend/src/data/subjectDetails.json", "w") as outfile:
json.dump(subject_details, outfile, indent=2)

return subjects_dict
Expand Down
22 changes: 14 additions & 8 deletions frontend/src/App.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React, { Component, useEffect, useState } from "react";
import React, { useEffect, useState } from "react";
import "./App.css";
import CustomTable from "./CustomTable.js";
import CustomTable from "./components/CustomTable/CustomTable.js";
import PropTypes from "prop-types";
import EmptyRoomsTable from "./EmptyRoomsTable.js";
import TwoSlotDisplay from "./TwoSlotDisplay.js";
import EmptyRoomsTable from "./components/EmptyRoomTable/EmptyRoomsTable.js";
import TwoSlotDisplay from "./components/TwoSlotDisplay.js";
import Logo from "./navbar-icon.svg";
import { isInsideCampusNetwork } from "./Utilities.js";
import { isInsideCampusNetwork } from "./util/utilities.js";

function App({ schedule, empty_schedule }) {
const [loading, setLoading] = useState(true);
Expand All @@ -23,14 +23,20 @@ function App({ schedule, empty_schedule }) {
if (loading)
return (
<div className="message-banner">
<iframe src="https://lottie.host/?file=ca9a3787-e6db-4878-a0d3-d10dde95b225/MjnHw4B5gw.json"></iframe>
<iframe
src="https://lottie.host/?file=ca9a3787-e6db-4878-a0d3-d10dde95b225/MjnHw4B5gw.json"
title="Loader"
></iframe>
<div className="message">Chillzone is loading</div>
</div>
);
else if (!show)
return (
<div className="message-banner">
<iframe src="https://lottie.host/?file=46b58d32-043e-4268-94cd-4d7817565000/xNnhIYFoYA.json"></iframe>
<iframe
src="https://lottie.host/?file=46b58d32-043e-4268-94cd-4d7817565000/xNnhIYFoYA.json"
title="Campus Network Error"
></iframe>
<div className="message">
Please connect to IIT Kharagpur campus network to access this site!
</div>
Expand All @@ -44,7 +50,7 @@ function App({ schedule, empty_schedule }) {
<h3>Find a place to chill, NOW!</h3>
</header>

<TwoSlotDisplay date={new Date()} schedule={empty_schedule} />
<TwoSlotDisplay schedule={empty_schedule} />

<EmptyRoomsTable schedule={empty_schedule} />
{Object.keys(schedule).map((key) => {
Expand Down
40 changes: 0 additions & 40 deletions frontend/src/CustomTable.js

This file was deleted.

115 changes: 0 additions & 115 deletions frontend/src/EmptyRooms.js

This file was deleted.

39 changes: 0 additions & 39 deletions frontend/src/EmptyRoomsTable.js

This file was deleted.

55 changes: 0 additions & 55 deletions frontend/src/GenerateCustomTR.js

This file was deleted.

41 changes: 0 additions & 41 deletions frontend/src/GenerateEmptyRoomsTR.js

This file was deleted.

Loading