fetch actual room state
This commit is contained in:
parent
b2c8d80796
commit
e2134ad84a
|
@ -1,10 +1,26 @@
|
||||||
import React from "react"
|
import React, { useEffect, useState } from "react"
|
||||||
import Layout from "../components/layout"
|
import Layout from "../components/layout"
|
||||||
|
|
||||||
export default () => (
|
export default () => {
|
||||||
<Layout>
|
const [opened, setOpened] = useState(false)
|
||||||
<h2>
|
|
||||||
Raumtatus <span style={{ color: `green` }}>OFFEN</span>
|
useEffect(() => {
|
||||||
</h2>
|
async function fetchState() {
|
||||||
</Layout>
|
const response = await fetch("https://status.ctdo.de/api/simple/v2")
|
||||||
)
|
const json = await response.json()
|
||||||
|
setOpened(json.state)
|
||||||
|
}
|
||||||
|
fetchState()
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Layout>
|
||||||
|
<h2>
|
||||||
|
Raumtatus{" "}
|
||||||
|
<span style={{ color: opened ? `green` : `darkred` }}>
|
||||||
|
{opened ? "OFFEN" : "GESCHLOSSEN"}
|
||||||
|
</span>
|
||||||
|
</h2>
|
||||||
|
</Layout>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue