feat: scanning mode on receipt page

This commit is contained in:
2025-01-23 17:57:28 +04:00
parent f62d2662d6
commit 4500422f82
22 changed files with 676 additions and 91 deletions

View File

@@ -2,6 +2,9 @@ import { useEffect, useState } from "react";
import { ResidualPalletSchema, ResiduesService } from "../../../../../client";
import { modals } from "@mantine/modals";
import { notifications } from "../../../../../shared/lib/notifications.ts";
import useBarcodesProductsMap from "../../../hooks/useBarcodesProductsMap.tsx";
import useApplyingScannedResult from "./useApplyingScannedResult.tsx";
import useScanningMode from "../../../hooks/useScanningMode.tsx";
type Props = {
palletId: number;
@@ -27,6 +30,16 @@ const useReceiptPallet = ({ palletId }: Props) => {
.catch(err => console.log(err));
};
const { barcodesProductsMap } = useBarcodesProductsMap({ clientId: clientId ?? -1 });
const { onScanningFinish } = useApplyingScannedResult({
object: pallet,
barcodesProductsMap,
refetch: fetchPallet,
});
const { scanningData, toggleScanning } = useScanningMode({ onScanningFinish });
const onCreateProductClick = () => {
if (!(pallet && clientId)) return;
modals.openContextModal({
@@ -38,6 +51,7 @@ const useReceiptPallet = ({ palletId }: Props) => {
isBox: false,
object: pallet,
fetchObject: fetchPallet,
barcodesProductsMap,
},
});
};
@@ -64,6 +78,9 @@ const useReceiptPallet = ({ palletId }: Props) => {
clientId,
onCreateProductClick,
onCreateBoxClick,
barcodesProductsMap,
scanningData,
toggleScanning,
};
};