From 2c7677a0c346cbb9853391592f6bba83677e8406 Mon Sep 17 00:00:00 2001 From: Muhammad Izza Alfiansyah Date: Sat, 11 May 2024 09:31:01 +0700 Subject: [PATCH] disable navigate when fermentation not started yet --- website/src/App.tsx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/website/src/App.tsx b/website/src/App.tsx index bdfd59f..2c351b8 100644 --- a/website/src/App.tsx +++ b/website/src/App.tsx @@ -33,6 +33,7 @@ export default function (props: JSX.HTMLAttributes) { ]; const [lastHistori, setLastHistori] = createSignal(null); + const [canNavigate, setCanNavigate] = createSignal(false); const location = useLocation(); const navigate = useNavigate(); @@ -51,6 +52,7 @@ export default function (props: JSX.HTMLAttributes) { }; const deleteAllData = async () => { + await supabase.from("pengaturan").update({ running: false }).eq("id", 1); await supabase.from("kondisi_tapai").delete().neq("id", "0"); setLastHistori(null); @@ -80,7 +82,7 @@ export default function (props: JSX.HTMLAttributes) { }; const checkStatusDevice = async () => { - const lastData1: any = await new Promise(async (res, rej) => { + const lastData1: any = await new Promise(async (res) => { const { data } = await supabase .from("kondisi_tapai") .select("created_time") @@ -115,6 +117,8 @@ export default function (props: JSX.HTMLAttributes) { if (location.pathname != "/") { navigate("/"); } + } else { + setCanNavigate(true); } } }; @@ -122,7 +126,7 @@ export default function (props: JSX.HTMLAttributes) { onMount(async () => { await checkPengaturan(); await getLastHistori(); - // await checkStatusDevice(); + await checkStatusDevice(); }); return ( @@ -131,7 +135,7 @@ export default function (props: JSX.HTMLAttributes) {
Fermonitor
- + @@ -141,7 +145,7 @@ export default function (props: JSX.HTMLAttributes) { {(item) => (