diff --git a/frontend/src/components/SkipButton.tsx b/frontend/src/components/SkipButton.tsx new file mode 100644 index 0000000..3e41ffa --- /dev/null +++ b/frontend/src/components/SkipButton.tsx @@ -0,0 +1,35 @@ +import Button from "@mui/material/Button"; +import { useNavigate } from "react-router-dom"; + +export default function SkipButton() { + const navigate = useNavigate(); + if (sessionStorage.getItem("campusSolutions") === undefined) { + return ( + + Modify Timetable + + ); + } else { + return ( + navigate("/timetablemod")} + variant="contained" + sx={{ + backgroundColor: "#f05a22", + "&:hover": { + backgroundColor: "#f05a22", + }, + marginTop: "20px" + }} + > + Modify Timetable + + ); + } +} diff --git a/frontend/src/pages/Enrolment.tsx b/frontend/src/pages/Enrolment.tsx index 995336e..bb81ce0 100644 --- a/frontend/src/pages/Enrolment.tsx +++ b/frontend/src/pages/Enrolment.tsx @@ -4,6 +4,10 @@ import UploadPopUp from "../components/UploadPopUp.tsx"; import Header from "../components/Header.tsx"; import Footer from "../components/Footer.tsx"; import Photo from "../assets/frontpage.jpg"; +import { useEffect } from "react"; +import { LOCAL_API_URL, TimetableSolution } from "../scripts/api.ts"; +import { useAuthContext } from "../security/AuthContext.tsx"; +import SkipButton from "../components/SkipButton.tsx"; /** * Renders the Starter Page component with specific time and tabler styles. @@ -20,6 +24,26 @@ export default function StarterPage() { const tablerStyle = { color: "black", }; + const { authHeader } = useAuthContext(); + useEffect(() => { + fetch(LOCAL_API_URL + "/timetabling/view", { + headers: { Authorization: authHeader }, + }) + .then((response) => { + if (!response.ok) { + throw new Error("Network response was not ok"); + } + return response.json(); + }) + .then((data) => { + const timetableSolutions: TimetableSolution[] = + data as TimetableSolution[]; + sessionStorage.setItem( + "campusSolutions", + JSON.stringify(timetableSolutions) + ); + }); + }, []); return ( @@ -31,6 +55,7 @@ export default function StarterPage() { A timetabling website for the Victorian Institute of Technology -Team JetEdge +
A timetabling website for the Victorian Institute of Technology
-Team JetEdge