From f7733a59f4c8dc155074bbc61ac681f4c563ff9f Mon Sep 17 00:00:00 2001 From: Andrew <74398819+AndrewDTR@users.noreply.github.com> Date: Mon, 23 Sep 2024 21:56:41 -0500 Subject: [PATCH] add "check our hours" when doors closed --- src/components/DoorStatus.jsx | 55 ++++++++++++++------------ src/components/Header.astro | 74 ++++++++++++----------------------- 2 files changed, 55 insertions(+), 74 deletions(-) diff --git a/src/components/DoorStatus.jsx b/src/components/DoorStatus.jsx index ddb4076..42760b6 100644 --- a/src/components/DoorStatus.jsx +++ b/src/components/DoorStatus.jsx @@ -11,7 +11,7 @@ const DoorStatus = () => { const data = await response.json(); const { door1, door2 } = data.status; - // determine if the UPL is open + // Determine if the UPL is open if (door1 === "open" && door2 === "open") { setIsOpen(true); } else { @@ -19,40 +19,45 @@ const DoorStatus = () => { } } catch (error) { console.error("Error fetching door status:", error); - setIsOpen(false); // default to closed + setIsOpen(false); // Default to closed } }; useEffect(() => { fetchDoorStatus(); - const interval = setInterval(fetchDoorStatus, 500); // fetch every 10 seconds + const interval = setInterval(fetchDoorStatus, 10000); // Fetch every 10 seconds return () => clearInterval(interval); }, []); return ( - -
- +
+
+
+ +
+

+ The doors are{" "} + + {isOpen === null ? "loading..." : isOpen ? "open" : "closed"} + + ! +

-

- The doors are{" "} - - {isOpen === null ? "loading..." : isOpen ? "open" : "closed"} - - ! -

-
+ {!isOpen && isOpen !== null && ( + + Check our hours here. + + )} +
); }; -export default DoorStatus; \ No newline at end of file +export default DoorStatus; diff --git a/src/components/Header.astro b/src/components/Header.astro index 86b1c9d..cb6b14a 100644 --- a/src/components/Header.astro +++ b/src/components/Header.astro @@ -1,37 +1,14 @@ --- import HeaderLink from "./HeaderLink.astro"; -import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; -import { faDoorOpen, faDoorClosed } from "@fortawesome/free-solid-svg-icons"; import DoorStatus from "./DoorStatus.jsx"; -const ROUTES: { - path: string; - name: string; -}[] = [ - { - path: "/", - name: "Home", - }, - { - path: "/events", - name: "Events", - }, - { - path: "/blog", - name: "Blog", - }, - { - path: "/resources", - name: "Resources", - }, - { - path: "/about", - name: "About Us", - }, - { - path: "/hours", - name: "Hours", - }, +const ROUTES = [ + { path: "/", name: "Home" }, + { path: "/events", name: "Events" }, + { path: "/blog", name: "Blog" }, + { path: "/resources", name: "Resources" }, + { path: "/about", name: "About Us" }, + { path: "/hours", name: "Hours" }, ]; --- @@ -45,41 +22,40 @@ const ROUTES: { fill="none" viewBox="0 0 24 24" stroke="currentColor" - > + + d="M4 6h16M4 12h8m-8 6h16" + > +
UPLUPL @@ -88,4 +64,4 @@ const ROUTES: { - + \ No newline at end of file