QR Code Fast Scan with Auto Quantity
This commit is contained in:
parent
0fc07aaeac
commit
5c6e5fd9be
|
|
@ -127,6 +127,9 @@ export default function BSC1Search(props) {
|
|||
const [QuickAdd, setQuickAdd] = useState(false);
|
||||
const inputRef = useRef(null);
|
||||
const containerRef = useRef(null);
|
||||
// QR code tracking
|
||||
const [lastScannedQr, setLastScannedQr] = useState(null);
|
||||
const [currentSessionQr, setCurrentSessionQr] = useState(null);
|
||||
const focusStatusCustMouse = useSelector(GlobalfocusStatusCustMouse);
|
||||
const CompoPaymentIconStatus = useSelector(GlobalCompoPaymentIconStatus);
|
||||
const CompoPreOrderDtlStatus = useSelector(GlobalCompoPreOrderDtlStatus);
|
||||
|
|
@ -432,6 +435,14 @@ export default function BSC1Search(props) {
|
|||
stopScannerFromParent();
|
||||
};
|
||||
|
||||
|
||||
|
||||
// Clear QR tracker function
|
||||
const clearQrTracker = () => {
|
||||
setLastScannedQr(null);
|
||||
setCurrentSessionQr(null);
|
||||
};
|
||||
|
||||
const ProductNameOnChange = (data) => {
|
||||
if (isSelectingRef.current) {
|
||||
isSelectingRef.current = false;
|
||||
|
|
@ -447,8 +458,22 @@ export default function BSC1Search(props) {
|
|||
}
|
||||
|
||||
await dispatch(changeSearchedData(data));
|
||||
|
||||
// If same QR as current session, just add quantity
|
||||
if (currentSessionQr === data) {
|
||||
if (lastScannedQr) {
|
||||
const updatedProduct = {
|
||||
...lastScannedQr,
|
||||
OrderQty: (lastScannedQr.OrderQty || 1) + 1,
|
||||
Quantity: (lastScannedQr.Quantity || 1) + 1
|
||||
};
|
||||
ProductSelected(updatedProduct);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
// 🚀 Dispatch API
|
||||
// 🚀 Call API for new session QR code
|
||||
searchPromiseRef.current = dispatch(
|
||||
getProductsearch({
|
||||
CompId,
|
||||
|
|
@ -467,6 +492,9 @@ export default function BSC1Search(props) {
|
|||
ApiSearchData?.QrBasedSearch === 'Y' ||
|
||||
ApiSearchData?.OnePcQRBased === 'Y'
|
||||
) {
|
||||
setCurrentSessionQr(data);
|
||||
setLastScannedQr(ApiSearchData);
|
||||
|
||||
ProductSelected(ApiSearchData);
|
||||
setQuickAdd(false);
|
||||
} else if (!ApiSearchData.ProdId && ApiSearchData?.AppId == 0) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue