import { LstCard } from "@/components/extendedUI/LstCard"; import { Skeleton } from "@/components/ui/skeleton"; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from "@/components/ui/table"; // import {useSessionStore} from "@/lib/store/sessionStore"; // import {useSettingStore} from "@/lib/store/useSettings"; import { useQuery } from "@tanstack/react-query"; import { getlabels } from "@/utils/querys/production/labels"; import { format } from "date-fns"; const labelLogs = [ { key: "line", label: "Line" }, { key: "printerName", label: "Printer" }, { key: "runningNr", label: "Running #" }, { key: "upd_date", label: "Label date" }, { key: "status", label: "Label Status" }, //{key: "reprint", label: "Reprint"}, // removing the reprint button for now until repritning is working as intended ]; export default function LabelLog() { const { data, isError, isLoading } = useQuery(getlabels("4")); if (isError) { return (

Labels for the last 2 hours

{labelLogs.map((l) => ( {l.label} ))} {Array(7) .fill(0) .map((_, i) => ( ))}
); } const labelData = data ? data : []; return (

{labelData.length === 0 ? ( No labels have been printed in the last 2 hours ) : ( Labels for the last 2 hours )}

{labelLogs.map((l) => ( {l.label} ))} {isLoading ? ( <> {Array(7) .fill(0) .map((_, i) => ( ))} ) : ( {labelData.map((label: any) => ( {label.line} {label.printerName} {label.runningNr} {format( label?.upd_date.replace("Z", ""), "M/d/yyyy hh:mm" )} {label.status} ))} )} {/* {labelData.length === 0 && (

No labels have been printed in the last 2 hours

)}
*/}
); }