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,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;