add histori fermentasi
This commit is contained in:
parent
a703ba816f
commit
60557e4094
|
@ -1,6 +1,26 @@
|
||||||
|
import { createSignal, onMount } from "solid-js";
|
||||||
import Table from "../components/Table";
|
import Table from "../components/Table";
|
||||||
|
import { Histori } from "../types/Histori";
|
||||||
|
import supabase from "../utils/supabase";
|
||||||
|
import { getDates, getTimeDiff } from "../utils/dates";
|
||||||
|
|
||||||
export default function () {
|
export default function () {
|
||||||
|
const [items, setItems] = createSignal<Histori[]>([]);
|
||||||
|
|
||||||
|
const getData = async () => {
|
||||||
|
const { data } = await supabase
|
||||||
|
.from("histori_fermentasi")
|
||||||
|
.select("*")
|
||||||
|
.order("created_at", { ascending: false })
|
||||||
|
.range(0, 10);
|
||||||
|
|
||||||
|
setItems(data as Histori[]);
|
||||||
|
};
|
||||||
|
|
||||||
|
onMount(async () => {
|
||||||
|
await getData();
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div class="space-y-5">
|
<div class="space-y-5">
|
||||||
<div class="bg-white rounded p-5 shadow">
|
<div class="bg-white rounded p-5 shadow">
|
||||||
|
@ -10,32 +30,20 @@ export default function () {
|
||||||
</p>
|
</p>
|
||||||
<Table
|
<Table
|
||||||
headers={["Tanggal", "Lama Fermentasi", "Rentang Suhu", "Status"]}
|
headers={["Tanggal", "Lama Fermentasi", "Rentang Suhu", "Status"]}
|
||||||
items={[
|
items={items().map((item) => [
|
||||||
[
|
getDates(item.created_at),
|
||||||
"24 Maret 2024",
|
Math.round(
|
||||||
"32 Jam",
|
getTimeDiff(item.waktu_awal, item.waktu_akhir) / (1000 * 60 * 60)
|
||||||
"35 - 40 C",
|
) + " Jam",
|
||||||
<span class="uppercase text-green-500">SUKSES</span>,
|
item.rentang_suhu + " C",
|
||||||
],
|
<span
|
||||||
[
|
class={
|
||||||
"23 Maret 2024",
|
"uppercase " + item.berhasil ? "text-green-500" : "text-red-500"
|
||||||
"6 Jam",
|
}
|
||||||
"25- 35 C",
|
>
|
||||||
<span class="uppercase text-red-500">GAGAL</span>,
|
{item.berhasil ? "SUKSES" : "GAGAL"}
|
||||||
],
|
</span>,
|
||||||
[
|
])}
|
||||||
"22 Maret 2024",
|
|
||||||
"24 Jam",
|
|
||||||
"30 - 40 C",
|
|
||||||
<span class="uppercase text-green-500">SUKSES</span>,
|
|
||||||
],
|
|
||||||
[
|
|
||||||
"24 Maret 2024",
|
|
||||||
"24 Jam",
|
|
||||||
"30 - 40 C",
|
|
||||||
<span class="uppercase text-green-500">SUKSES</span>,
|
|
||||||
],
|
|
||||||
]}
|
|
||||||
class="my-5"
|
class="my-5"
|
||||||
></Table>
|
></Table>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
export interface Histori {
|
||||||
|
id: number;
|
||||||
|
waktu_awal: string;
|
||||||
|
waktu_akhir: string;
|
||||||
|
rentang_suhu: string;
|
||||||
|
berhasil: boolean;
|
||||||
|
created_at: string;
|
||||||
|
selesai: boolean;
|
||||||
|
}
|
|
@ -3,5 +3,5 @@ export interface KondisiTapai {
|
||||||
suhu: number;
|
suhu: number;
|
||||||
kelembaban: number;
|
kelembaban: number;
|
||||||
kadar_gas: number;
|
kadar_gas: number;
|
||||||
created_at: Date;
|
created_at: string;
|
||||||
}
|
}
|
|
@ -19,4 +19,13 @@ export function getDates(date: any = null) {
|
||||||
const month = bulan[dates.getMonth()];
|
const month = bulan[dates.getMonth()];
|
||||||
|
|
||||||
return dates.getDate() + ' ' + month + ' ' + year;
|
return dates.getDate() + ' ' + month + ' ' + year;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getTimeDiff(firstDate: string, lastDate: string) {
|
||||||
|
const date_awal = new Date(firstDate);
|
||||||
|
const date_akhir = new Date(lastDate);
|
||||||
|
|
||||||
|
const date_diff = date_akhir.getTime() - date_awal.getTime();
|
||||||
|
|
||||||
|
return date_diff;
|
||||||
}
|
}
|
Loading…
Reference in New Issue