diff --git a/frontend/src/components/dashboard/AddCards.tsx b/frontend/src/components/dashboard/AddCards.tsx index d9c3799..fe40ee4 100644 --- a/frontend/src/components/dashboard/AddCards.tsx +++ b/frontend/src/components/dashboard/AddCards.tsx @@ -34,6 +34,7 @@ export function AddCards() { + diff --git a/frontend/src/components/dashboard/DashBoard.tsx b/frontend/src/components/dashboard/DashBoard.tsx index a0a6b38..45a1212 100644 --- a/frontend/src/components/dashboard/DashBoard.tsx +++ b/frontend/src/components/dashboard/DashBoard.tsx @@ -1,10 +1,12 @@ import { useCardStore } from "@/lib/store/useCardStore"; import INVCheckCard from "../logistics/warehouse/InventoryCard"; import PPOO from "../logistics/warehouse/PPOOCard"; +import OpenOrders from "../logistics/warehouse/openOrders"; const componentsMap: any = { ppoo: PPOO, inv: INVCheckCard, + openOrder: OpenOrders, //QualityRequest, }; @@ -18,12 +20,19 @@ export default function DashBoard() { const name = a.name; //.filter((c) => c.i === card.i)[0].i || "name"; const Component = componentsMap[name.split("-")[0]]; - - return ( -
- {" "} -
- ); + if (name === "openOrder") { + return ( +
+ +
+ ); + } else { + return ( +
+ +
+ ); + } })} ); diff --git a/frontend/src/components/logistics/warehouse/InventoryCard.tsx b/frontend/src/components/logistics/warehouse/InventoryCard.tsx index aa49287..61e5a89 100644 --- a/frontend/src/components/logistics/warehouse/InventoryCard.tsx +++ b/frontend/src/components/logistics/warehouse/InventoryCard.tsx @@ -25,6 +25,9 @@ export default function INVCheckCard(props: any) { laneData = laneData.filter( (l: any) => l.rowType === props.type.toUpperCase() ); + + // age + laneData = laneData.filter((l: any) => l.DaysSinceLast >= props.age); } // const handleCloseCard = () => { diff --git a/frontend/src/components/logistics/warehouse/openOrders.tsx b/frontend/src/components/logistics/warehouse/openOrders.tsx new file mode 100644 index 0000000..c83e25a --- /dev/null +++ b/frontend/src/components/logistics/warehouse/openOrders.tsx @@ -0,0 +1,33 @@ +//import { LstCard } from "@/components/extendedUI/LstCard"; + +import { getOpenOrders } from "@/utils/querys/logistics/getOpenOrders"; +import { openOrderColumns } from "@/utils/tableData/openorders/ooColumns"; +import { OpenOrderTable } from "@/utils/tableData/openorders/ooData"; + +import { useQuery } from "@tanstack/react-query"; +//import { CircleX } from "lucide-react"; +//import { Suspense } from "react"; +//import { toast } from "sonner"; + +export default function OpenOrders() { + //{ style = {} } + const { data, isError, isLoading } = useQuery(getOpenOrders()); + + if (isLoading) return
Loading openOrder data...
; + if (isError) { + return ( +
+

There was an error getting the openorders.

+
+ ); + } + let openOrders: any = data; + + // const handleCloseCard = () => { + // //removeCard("PPOO"); + + // toast.success("card removed"); + // }; + + return ; +} diff --git a/frontend/src/utils/querys/logistics/getOpenOrders.tsx b/frontend/src/utils/querys/logistics/getOpenOrders.tsx new file mode 100644 index 0000000..3fc49bf --- /dev/null +++ b/frontend/src/utils/querys/logistics/getOpenOrders.tsx @@ -0,0 +1,22 @@ +import { queryOptions } from "@tanstack/react-query"; +import axios from "axios"; + +export function getOpenOrders() { + return queryOptions({ + queryKey: ["getOpenOrders"], + queryFn: () => fetchStockSilo(), + //enabled: + staleTime: 1000, + refetchInterval: 1000 * 60 * 15, + refetchOnWindowFocus: true, + }); +} + +const fetchStockSilo = async () => { + const { data } = await axios.get( + `/api/datamart/getopenorders?sDay=15&eDay=45` + ); + // if we are not localhost ignore the devDir setting. + //const url: string = window.location.host.split(":")[0]; + return data.data ?? []; +}; diff --git a/frontend/src/utils/tableData/openorders/ooColumns.tsx b/frontend/src/utils/tableData/openorders/ooColumns.tsx new file mode 100644 index 0000000..8713a0a --- /dev/null +++ b/frontend/src/utils/tableData/openorders/ooColumns.tsx @@ -0,0 +1,61 @@ +import { ColumnDef } from "@tanstack/react-table"; +import { format } from "date-fns"; + +// This type is used to define the shape of our data. +// You can use a Zod schema here if you want. +export type Adjustmnets = { + siloAdjust_id: string; + currentStockLevel: string; + newLevel: number; + dateAdjusted: string; + lastDateAdjusted: string; + comment: string; + commentAddedBy: string; + commentDate: string; + add_user: string; +}; + +export const openOrderColumns: ColumnDef[] = [ + { + accessorKey: "Remark", + header: () =>
Carrier/Remark
, + cell: ({ row }) => { + const remark: any = row.getValue("Remark"); + if (!remark) { + return

No remark

; + } + return

{remark}

; + }, + }, + { + accessorKey: "DeliveryAddressDescription", + header: "Delivery Address", + }, + { + accessorKey: "header", + header: "PO", + }, + { + accessorKey: "releaseNumber", + header: "Release #", + }, + { + accessorKey: "deliveryDate", + header: "DeliveryDate", + cell: ({ row }) => { + if (row.getValue("deliveryDate")) { + const correctDate = format( + row.getValue("deliveryDate"), + "M/d/yyyy hh:mm" + ); + return ( +
{correctDate}
+ ); + } + }, + }, + { + accessorKey: "customerItemNumber", + header: "Material #", + }, +]; diff --git a/frontend/src/utils/tableData/openorders/ooData.tsx b/frontend/src/utils/tableData/openorders/ooData.tsx new file mode 100644 index 0000000..52f5fce --- /dev/null +++ b/frontend/src/utils/tableData/openorders/ooData.tsx @@ -0,0 +1,251 @@ +import { + ColumnDef, + flexRender, + getCoreRowModel, + useReactTable, + getPaginationRowModel, +} from "@tanstack/react-table"; +import { + Table, + TableBody, + TableCell, + TableHead, + TableHeader, + TableRow, +} from "@/components/ui/table"; +import { Button } from "@/components/ui/button"; +import { useState } from "react"; +import { + Select, + SelectContent, + SelectGroup, + SelectItem, + SelectLabel, + SelectTrigger, + SelectValue, +} from "@/components/ui/select"; +import { ScrollArea } from "@/components/ui/scroll-area"; +import { LstCard } from "@/components/extendedUI/LstCard"; +import { useLocation } from "@tanstack/react-router"; + +interface DataTableProps { + columns: ColumnDef[]; + data: TData[]; + //style: any; +} + +export function OpenOrderTable({ + columns, + data, + //style, +}: DataTableProps) { + const [pagination, setPagination] = useState({ + pageIndex: 0, //initial page index + pageSize: 5, //default page size + }); + const location = useLocation(); + const table = useReactTable({ + data, + columns, + getCoreRowModel: getCoreRowModel(), + getPaginationRowModel: getPaginationRowModel(), + onPaginationChange: setPagination, + state: { + //... + pagination, + }, + }); + + //console.log(parseInt(style.height.replace("px", "")) - 50); + return ( + +
+
+

Open orders

+ +
+ {location.pathname === "/" ? ( + + + + {table.getHeaderGroups().map((headerGroup) => ( + + {headerGroup.headers.map((header) => { + return ( + + {header.isPlaceholder + ? null + : flexRender( + header.column + .columnDef + .header, + header.getContext() + )} + + ); + })} + + ))} + + + {table.getRowModel().rows?.length ? ( + table.getRowModel().rows.map((row) => ( + + {row + .getVisibleCells() + .map((cell) => ( + + {flexRender( + cell.column + .columnDef.cell, + cell.getContext() + )} + + ))} + + )) + ) : ( + + + No results. + + + )} + +
+
+ ) : ( + + + + {table.getHeaderGroups().map((headerGroup) => ( + + {headerGroup.headers.map((header) => { + return ( + + {header.isPlaceholder + ? null + : flexRender( + header.column + .columnDef + .header, + header.getContext() + )} + + ); + })} + + ))} + + + {table.getRowModel().rows?.length ? ( + table.getRowModel().rows.map((row) => ( + + {row + .getVisibleCells() + .map((cell) => ( + + {flexRender( + cell.column + .columnDef.cell, + cell.getContext() + )} + + ))} + + )) + ) : ( + + + No results. + + + )} + +
+
+ )} +
+
+ + +
+
+ ); +} diff --git a/frontend/src/utils/tableData/ppoo/ppooColumns.tsx b/frontend/src/utils/tableData/ppoo/ppooColumns.tsx index 6fb97f0..528f069 100644 --- a/frontend/src/utils/tableData/ppoo/ppooColumns.tsx +++ b/frontend/src/utils/tableData/ppoo/ppooColumns.tsx @@ -26,7 +26,7 @@ export const columns: ColumnDef[] = [ }, { accessorKey: "RunningNumber", - header: "Running Number", + header: "Label", }, { accessorKey: "ProductionDate", diff --git a/frontend/src/utils/tableData/production/labels/labelColumns.tsx b/frontend/src/utils/tableData/production/labels/labelColumns.tsx index 7f4121e..d1291bc 100644 --- a/frontend/src/utils/tableData/production/labels/labelColumns.tsx +++ b/frontend/src/utils/tableData/production/labels/labelColumns.tsx @@ -33,7 +33,7 @@ export const labelolumns: ColumnDef[] = [ header: "Label Date", cell: ({ row }) => { if (row.getValue("upd_date")) { - const correctDate = fixTime(row.getValue("created_at")); + const correctDate = fixTime(row.getValue("upd_date")); return (
{correctDate}
);