From b1c1d6c0afbbfea78e2cdf99e781d0be1a577aa7 Mon Sep 17 00:00:00 2001 From: Muhammad Izza Alfiansyah Date: Thu, 27 Jun 2024 17:59:02 +0700 Subject: [PATCH] add rentang suhu on save history --- website/src/App.tsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/website/src/App.tsx b/website/src/App.tsx index 657275e..c97bd60 100644 --- a/website/src/App.tsx +++ b/website/src/App.tsx @@ -42,6 +42,7 @@ export default function (props: JSX.HTMLAttributes) { const [lastHistori, setLastHistori] = createSignal(null); const [canNavigate, setCanNavigate] = createSignal(false); const [showSidebar, setShowSidebar] = createSignal(false); + const [pengaturan, setPengaturan] = createSignal(); const location = useLocation(); const navigate = useNavigate(); @@ -70,10 +71,17 @@ export default function (props: JSX.HTMLAttributes) { }; const saveHistori = async () => { + const auto = pengaturan()?.auto; + const suhu_min = pengaturan()?.suhu_min; + const suhu_max = pengaturan()?.suhu_max; + + const rentang_suhu = auto ? suhu_min + " - " + suhu_max : "-"; + await supabase .from("histori_fermentasi") .update({ selesai: true, + rentang_suhu, }) .eq("id", lastHistori()?.id); @@ -124,6 +132,7 @@ export default function (props: JSX.HTMLAttributes) { const { data } = await supabase.from("pengaturan").select("*").limit(1); if (data) { const item: Pengaturan = data[0]; + setPengaturan(item); if (!item.running) { if (location.pathname != "/") {