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 { LotType } from "@/types/lots"; import { getlots } from "@/utils/querys/production/lots"; import { useQuery } from "@tanstack/react-query"; import ManualPrint from "./ManualPrinting/ManualPrint"; import ManualPrintForm from "./ManualPrinting/ManualPrintForm"; import { ScrollArea } from "@/components/ui/scroll-area"; import { useGetUserRoles } from "@/lib/store/useGetRoles"; import { useModuleStore } from "@/lib/store/useModuleStore"; let lotColumns = [ { key: "MachineDescription", label: "Machine", }, { key: "AV", label: "AV", }, { key: "Alias", label: "AvDescription", }, { key: "lot", label: "LotNumber", }, { key: "ProlinkLot", label: "ProlinkLot", }, { key: "PlannedQTY", label: "PlannedQTY", }, { key: "Produced", label: "Produced", }, { key: "Remaining", label: "Remaining", }, { key: "overPrinting", label: "Overprinting", }, // { // key: "lastProlinkUpdate", // label: "Last ProlinkCheck", // }, // { // key: "printLabel", // label: "Print Label", // }, ]; export default function Lots() { const { data, isError, isLoading } = useQuery(getlots()); const { user } = useSessionStore(); const { settings } = useSettingStore(); const { userRoles } = useGetUserRoles(); const { modules } = useModuleStore(); const server = settings.filter((n) => n.name === "server")[0]?.value || ""; const roles = ["systemAdmin", "technician", "admin", "manager", "operator"]; const lotdata = data ? data : []; const module = modules.filter((n) => n.name === "logistics"); const accessRoles = userRoles.filter( (n) => n.module_id === module[0]?.module_id ) as any; if (user && roles.includes(accessRoles[0]?.role)) { //width = 1280; const checkCol = lotColumns.some((l) => l.key === "printLabel"); if (!checkCol) { lotColumns = [ ...lotColumns, { key: "printLabel", label: "Print Label", }, ]; } } if (isError) { return (

Current Assigned lots

{lotColumns.map((l) => ( {l.label} ))} {Array(10) .fill(0) .map((_, i) => ( ))}
); } return (

Current Assigned lots

{lotColumns.map((l) => ( {l.label} ))} {isLoading ? ( <> {Array(10) .fill(0) .map((_, i) => ( ))} ) : ( {lotdata.map((lot: LotType) => ( {lot.MachineLocation} {lot.AV} {lot.Alias} {lot.lot} {lot.ProlinkLot} {lot.PlannedQTY} {lot.Produced} {lot.Remaining} {lot.overPrinting} {user && roles.includes( accessRoles[0]?.role ) && ( <> {server === "usday1vms006" || server === "localhost" ? ( <> ) : ( )} )} ))} )}
); }