add rentang suhu on save history
This commit is contained in:
parent
b3f02bb4a8
commit
b1c1d6c0af
|
@ -42,6 +42,7 @@ export default function (props: JSX.HTMLAttributes<HTMLDivElement>) {
|
||||||
const [lastHistori, setLastHistori] = createSignal<Histori | null>(null);
|
const [lastHistori, setLastHistori] = createSignal<Histori | null>(null);
|
||||||
const [canNavigate, setCanNavigate] = createSignal<boolean>(false);
|
const [canNavigate, setCanNavigate] = createSignal<boolean>(false);
|
||||||
const [showSidebar, setShowSidebar] = createSignal<boolean>(false);
|
const [showSidebar, setShowSidebar] = createSignal<boolean>(false);
|
||||||
|
const [pengaturan, setPengaturan] = createSignal<Pengaturan>();
|
||||||
|
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
@ -70,10 +71,17 @@ export default function (props: JSX.HTMLAttributes<HTMLDivElement>) {
|
||||||
};
|
};
|
||||||
|
|
||||||
const saveHistori = async () => {
|
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
|
await supabase
|
||||||
.from("histori_fermentasi")
|
.from("histori_fermentasi")
|
||||||
.update({
|
.update({
|
||||||
selesai: true,
|
selesai: true,
|
||||||
|
rentang_suhu,
|
||||||
})
|
})
|
||||||
.eq("id", lastHistori()?.id);
|
.eq("id", lastHistori()?.id);
|
||||||
|
|
||||||
|
@ -124,6 +132,7 @@ export default function (props: JSX.HTMLAttributes<HTMLDivElement>) {
|
||||||
const { data } = await supabase.from("pengaturan").select("*").limit(1);
|
const { data } = await supabase.from("pengaturan").select("*").limit(1);
|
||||||
if (data) {
|
if (data) {
|
||||||
const item: Pengaturan = data[0];
|
const item: Pengaturan = data[0];
|
||||||
|
setPengaturan(item);
|
||||||
|
|
||||||
if (!item.running) {
|
if (!item.running) {
|
||||||
if (location.pathname != "/") {
|
if (location.pathname != "/") {
|
||||||
|
|
Loading…
Reference in New Issue