From 022f1c3d388929a8b9069365dd19f5b27431915c Mon Sep 17 00:00:00 2001 From: Muhammad Izza Alfiansyah Date: Mon, 8 Jul 2024 23:33:31 +0700 Subject: [PATCH] add reset system --- website/src/App.tsx | 51 ++++++++++++++++++++++--------------- website/src/pages/Index.tsx | 23 +++++++++-------- 2 files changed, 43 insertions(+), 31 deletions(-) diff --git a/website/src/App.tsx b/website/src/App.tsx index ca3d971..1bb02ea 100644 --- a/website/src/App.tsx +++ b/website/src/App.tsx @@ -1,5 +1,5 @@ import { A, useLocation, useNavigate } from "@solidjs/router"; -import { createSignal, For, JSX, Match, onMount, Switch } from "solid-js"; +import { createSignal, For, JSX, Match, onMount, Show, Switch } from "solid-js"; import SettingIcon from "./icons/SettingIcon"; import HomeIcon from "./icons/HomeIcon"; import ArchiveIcon from "./icons/ArchiveIcon"; @@ -61,19 +61,25 @@ export default function (props: JSX.HTMLAttributes) { }; const fermentasiSelesai = async () => { - // await supabase.from("pengaturan").update({ running: false }).eq("id", 1); - await supabase.from("kondisi_tapai").delete().neq("id", "0"); - await supabase - .from("realtime_data") - .update({ - kadar_gas: 0, - kelembaban: 0, - suhu: 0, - created_time: 0, - }) - .eq("id", 1); + const isOk = confirm( + "Sistem akan melakukan reset untuk memulai proses fermentasi baru! Lanjutkan?" + ); - setLastHistori(null); + if (isOk) { + await supabase.from("pengaturan").update({ running: false }).eq("id", 1); + await supabase.from("kondisi_tapai").delete().neq("id", "0"); + await supabase + .from("realtime_data") + .update({ + kadar_gas: 0, + kelembaban: 0, + suhu: 0, + created_time: 0, + }) + .eq("id", 1); + + window.location.reload(); + } }; const saveHistori = async () => { @@ -90,8 +96,6 @@ export default function (props: JSX.HTMLAttributes) { rentang_suhu, }) .eq("id", lastHistori()?.id); - - await fermentasiSelesai(); }; const noSaveHistori = async () => { @@ -99,8 +103,6 @@ export default function (props: JSX.HTMLAttributes) { .from("histori_fermentasi") .delete() .eq("id", lastHistori()?.id); - - await fermentasiSelesai(); }; const checkStatusDevice = async () => { @@ -180,7 +182,7 @@ export default function (props: JSX.HTMLAttributes) { return (
-
+ lastHistori()!.waktu_akhir}> +
+ Terjadi kesalahan dan ingin membatalkan fermentasi? Klik di{" "} + + sini + +
+
-
- Terjadi kesalahan dan ingin membatalkan fermentasi? Klik di{" "} - - sini - -
-