diff --git a/app/routes/_index.tsx b/app/routes/_index.tsx index 641d6cd..2a728f3 100644 --- a/app/routes/_index.tsx +++ b/app/routes/_index.tsx @@ -43,6 +43,36 @@ export async function loader() { export default function Index() { const { posts } = useLoaderData(); + const [status, setStatus] = useState(""); + const [border_status, setBorderStatus] = useState("border-gray-700"); + + useEffect(() => { + if (status === "online") { + setBorderStatus("border-green-500"); + } else if (status === "offline") { + setBorderStatus("border-red-500"); + } else if (status === "dnd") { + setBorderStatus("border-red-600"); + } else if (status === "idle") { + setBorderStatus("border-yellow-500"); + } else { + setBorderStatus("border-gray-700"); + } + }, [status]); + + useEffect(() => { + fetch( + "https://shsf-api.cottonfieldworkers.shop/api/exec/6/c084ec4a-1b20-491e-ab2e-67c5fa8881e6" + ) + .then((res) => res.json()) + .then((data) => { + setStatus(data.status); + }) + .catch((err) => { + console.error(err); + setStatus("offline"); + }); + }, []); return (
@@ -74,7 +104,9 @@ export default function Index() { Space online
-
+