feat: scanning mode on receipt page
This commit is contained in:
@@ -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,
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user