Merge pull request '10qr-auto-quantity' (#13) from 10qr-auto-quantity into main
Reviewed-on: Pozomind/pozo-retail-app#13
This commit is contained in:
commit
9c6c362fa4
|
|
@ -127,6 +127,10 @@ 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);
|
||||
|
|
@ -143,6 +147,8 @@ export default function BSC1Search(props) {
|
|||
const [onePeiceFlow, setOnePeiceFlow] = useState(false);
|
||||
const [expQtyModel, setExpQtyModel] = useState(false);
|
||||
const [qtyExpData, setQtyExpData] = useState();
|
||||
console.log('h');
|
||||
|
||||
const PreOrderAdditem = useSelector(GlobalPreOrderAdditem);
|
||||
// const [FeatureAddonData, setFeatureAddonData] = useState([]);
|
||||
const [openScanner, setOpenScanner] = useState(false);
|
||||
|
|
@ -432,6 +438,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 +461,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 +495,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