diff --git a/src/pages/treff.js b/src/pages/treff.js index ad7a82f..a76c944 100644 --- a/src/pages/treff.js +++ b/src/pages/treff.js @@ -1,14 +1,20 @@ import React, { useEffect, useState } from "react" import Layout from "../components/layout" +const roomStateData = { + loading: { text: "ladeā€¦", color: "white" }, + open: { text: "OFFEN", color: "forestgreen" }, + closed: { text: "GESCHLOSSEN", color: "firebrick" }, +} + export default () => { - const [opened, setOpened] = useState(false) + const [openState, setOpenState] = useState("loading") useEffect(() => { async function fetchState() { const response = await fetch("https://status.ctdo.de/api/simple/v2") const json = await response.json() - setOpened(json.state) + setOpenState(json.state ? "open" : "closed") } fetchState() }, []) @@ -17,8 +23,8 @@ export default () => {

Raumstatus:{" "} - - {opened ? "OFFEN" : "GESCHLOSSEN"} + + {roomStateData[openState].text}