feat: residues accounting

This commit is contained in:
2025-01-14 21:35:06 +04:00
parent fec6b13972
commit c45d2ac20a
74 changed files with 2994 additions and 28 deletions

View File

@@ -0,0 +1,32 @@
import { useMemo } from "react";
import { MRT_ColumnDef, MRT_RowData } from "mantine-react-table";
const useResiduesTableColumns = <T extends MRT_RowData>() => {
return useMemo<MRT_ColumnDef<T>[]>(
() => [
{
header: "Название",
accessorKey: "product.name",
Cell: ({ row }) => row.original.product?.name ?? "-",
},
{
header: "Артикул",
accessorKey: "product.article",
Cell: ({ row }) => row.original.product?.article ?? "-",
},
{
header: "Размер",
accessorKey: "product.size",
Cell: ({ row }) => row.original.product?.size ?? "-",
},
{
header: "Количество",
accessorKey: "quantity",
},
],
[],
);
};
export default useResiduesTableColumns;

View File

@@ -0,0 +1,31 @@
import { useResiduesContext } from "../contexts/ResiduesContext.tsx";
import { notifications } from "../../../shared/lib/notifications.ts";
const useResiduesPdf = () => {
const { palletIdsToPrint, boxIdsToPrint } = useResiduesContext();
const basePdfUrl = `${import.meta.env.VITE_API_URL}/residues/pdf`;
const getPdf = (url: string) => {
const pdfWindow = window.open(url);
if (!pdfWindow) return;
pdfWindow.print();
};
const onGetPalletsPdfClick = () => {
if (palletIdsToPrint.size === 0 && boxIdsToPrint.size === 0) {
notifications.show({ message: "Не выбран ни один элемент для печати "});
return;
}
const palletIdsStr = palletIdsToPrint.values().toArray().join(",")
const boxIdsStr = boxIdsToPrint.values().toArray().join(",")
getPdf(`${basePdfUrl}/?pallet_ids=${palletIdsStr}&box_ids=${boxIdsStr}`);
};
return {
onGetPalletsPdfClick,
};
};
export default useResiduesPdf;