From 0144a75c62b1e20a47cc7e979637d391ebc5a0f6 Mon Sep 17 00:00:00 2001 From: mohan Date: Mon, 9 Feb 2026 17:28:22 +0530 Subject: [PATCH] scan page laoding issue --- package.json | 1 + .../Components/BSCombo/BSC1Search.jsx | 2076 ++++++----------- .../Components/BSItemCards/BSItemCard.jsx | 1465 +++++------- 3 files changed, 1316 insertions(+), 2226 deletions(-) diff --git a/package.json b/package.json index 25d1bb6..187784c 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,7 @@ "@reduxjs/toolkit": "^1.9.5", "@tanstack/react-query": "^5.90.11", "@tanstack/react-query-devtools": "^5.91.1", + "@tanstack/react-virtual": "^3.13.18", "antd": "^5.17.4", "antd-img-crop": "^4.22.0", "aos": "^2.3.4", diff --git a/src/Pages/BookingScreen/Components/BSCombo/BSC1Search.jsx b/src/Pages/BookingScreen/Components/BSCombo/BSC1Search.jsx index d7c0f00..76097ab 100644 --- a/src/Pages/BookingScreen/Components/BSCombo/BSC1Search.jsx +++ b/src/Pages/BookingScreen/Components/BSCombo/BSC1Search.jsx @@ -1,11 +1,8 @@ -import React, { useEffect, useRef, useState, useCallback } from 'react'; +import { useEffect, useRef, useState, useCallback } from 'react'; import { shallowEqual, useDispatch, useSelector } from 'react-redux'; import moment from 'moment'; -import { Modal } from 'antd'; -import { ExclamationCircleOutlined } from '@ant-design/icons'; import { BiBarcodeReader } from 'react-icons/bi'; import { GoTriangleRight } from 'react-icons/go'; -import { IoIosSearch } from 'react-icons/io'; import { FiSearch } from 'react-icons/fi'; import defaultimage from '../../../../Images/defaultItemImg.png'; import { Form, AutoComplete } from 'antd'; @@ -13,13 +10,11 @@ import { CloseSquareFilled } from '@ant-design/icons'; import '../../../../Styles/BookingScreen/Template/BSLayout7/BSC1Search.scss'; import { changeSearchedData, - ChangeWSProduct, ChangeNewQrProduct, getProductsearch, GlobalOrderCardDetails, changeOrderCardDetails, GlobalBookingType, - getPreferenceData, GlobalWSProduct, GlobalSearchData, GlobalNewQrProduct, @@ -35,27 +30,23 @@ import { GlobalWeightScalePort, GlobalWeightScaleWeight, changeothersdata, - GlobalUnpaidData, GlobalCreditFocus, GlobalBookingTypeBoth, GlobalOrderType, GlobalReorderProductDetails, - FeatureAddon, GlobalCompoPreOrderDtlStatus, GlobalDropDownStatus, GlobalPreOrderSearchStatus, GlobalFocusKioskPay, - GlobalSelOption, PreferenceData, GlobalFeatAddOnData, GlobalSelectedDatas, getConfigType, - + GlobalGetmultipleSearchDatas, } from '../../../../Features/BookingScreen/BookingData/BookingData'; import { changepreOrderList, GlobalPreOrderList, - GlobalPreOrderListedit, GlobalPreOrderAdditem, GlobalpreOrderOpen, } from '../../../../Features/BookingScreen/PreOrder/PreOrder.js'; @@ -64,7 +55,6 @@ import FormHeader from '../../../PageComponents/FormHeader'; import { DefaultModal } from '../../../../Components/Modal/DefaultModal'; import { Tables } from '../../../../Components/Tables/Table'; import FeaturesFunctionalities from '../BookingFunctionality/FeaturesFunctionalities'; -import { gettableData } from '../../../../Features/PreferenceMaster/PreferenceMaster'; import { isMobile } from 'react-device-detect'; import BarcodeScanner from '../UtillComponents/BarcodeScanner.jsx'; import { @@ -72,18 +62,28 @@ import { StoredSessionData, } from '../../../../Features/ThemeChange/ThemeChange.js'; import { v4 as uuidv4 } from 'uuid'; -import { GlobalAddCustomerDetails } from '../../../../Features/BookingScreen/Customer/addCustomer.js'; - import BSNavBarWeightScale from '../UtillComponents/BSNavBarWeightScale.jsx'; -import { changeFreeProductForLoyalty, ChangeFreeProductList, ChangeFullFreeProductList, changeFullOfferAppliedProducts, ChangeOfferAppliedProducts, changeOfferAppliedProductsForLoyalty, changeTriggerOfferFree, getOfferinBooking, GlobalFreeProdList, GlobalOfferAppliedProducts, GlobalTriggerOfferFree, RemoveOfferAppliedProduct } from '../../../../Features/Offer/Offernew/BookingOffernew.js'; +import { + changeFreeProductForLoyalty, + ChangeFreeProductList, + ChangeFullFreeProductList, + changeFullOfferAppliedProducts, + ChangeOfferAppliedProducts, + changeOfferAppliedProductsForLoyalty, + changeTriggerOfferFree, + getOfferinBooking, + GlobalFreeProdList, + GlobalOfferAppliedProducts, + GlobalTriggerOfferFree, + RemoveOfferAppliedProduct, +} from '../../../../Features/Offer/Offernew/BookingOffernew.js'; import { Global_PromoCodeOffers } from '../../../../Features/Offer/Offer.js'; import { validateOffers } from '../BSItemCards/ValidateOffer.jsx'; import { useSaleswiseOfferWatcher } from '../BSItemCards/SalesWiseOffer.jsx'; - +import ExpireConfirmModal from '../BookingFunctionality/ExpireConfirmModal.jsx'; export default function BSC1Search(props) { const dispatch = useDispatch(); - const searchPromiseRef = useRef(null); const debounceTimerRef = useRef(null); const SessionData = useSelector(StoredSessionData); @@ -100,6 +100,10 @@ export default function BSC1Search(props) { const BookingType = useSelector(GlobalBookingType); const WSProductdata = useSelector(GlobalWSProduct); const ProductSearch = useSelector(GlobalSearchData); + const GetmultipleSearchDatas = useSelector( + GlobalGetmultipleSearchDatas, + shallowEqual + ); const SelectedDatas = useSelector(GlobalSelectedDatas, shallowEqual); const NewQrProductData = useSelector(GlobalNewQrProduct); const ReportholdData = useSelector(GlobalReorderHoldDetails); @@ -116,12 +120,14 @@ export default function BSC1Search(props) { (item) => item.SettingIdName === 'Offer' )?.SettingValue === 'Y'; const templateData = useSelector(getTemplateData, shallowEqual); - console.log(CartOrderDetails, "templateData") - const OfferCheckedInSetup = (templateData?.BookingNavbar?.[1].some( - (item) => item?.OptionName == 'Offer' - )) || (templateData?.BookingCombo1?.[1]?.some( - (item) => item?.OptionName == 'Offer' - )); + console.log(CartOrderDetails, 'templateData'); + const OfferCheckedInSetup = + templateData?.BookingNavbar?.[1].some( + (item) => item?.OptionName == 'Offer' + ) || + templateData?.BookingCombo1?.[1]?.some( + (item) => item?.OptionName == 'Offer' + ); const BSComboData = props?.hasOwnProperty('data') ? props['data'] : null; const [messageType, setMessageType] = useState(null); const [messageData, setMessageData] = useState(null); @@ -135,13 +141,9 @@ export default function BSC1Search(props) { const [ProductList, setProductList] = useState([]); const [addFirst, setAddFirst] = useState(false); - console.log(addFirst, 'addFirstaddFirst'); const [ConfigDataList, setConfigDataList] = useState([]); const [SelectedProduct, setSelectedProduct] = useState({}); - const [expModel, setexpModel] = useState(false); const [prodexpir, setProdexpir] = useState(false); - const [expVarModel, setexpVarModel] = useState(false); - const [expStockModel, setexpStockModel] = useState(false); const [Item, setItem] = useState(); const [VarItem, setVarItem] = useState(); const [StockItem, setStockItem] = useState(); @@ -167,17 +169,12 @@ export default function BSC1Search(props) { ); const CreditFocus = useSelector(GlobalCreditFocus); const [onePeiceFlow, setOnePeiceFlow] = useState(false); - const [expQtyModel, setExpQtyModel] = useState(false); - const [qtyExpData, setQtyExpData] = useState(); - console.log('h'); - const PreOrderAdditem = useSelector(GlobalPreOrderAdditem); const offerAppliedProducts = useSelector( GlobalOfferAppliedProducts, shallowEqual ); const FreeProdList = useSelector(GlobalFreeProdList); - console.log(offerAppliedProducts, "offerAppliedProducts1", FreeProdList) const OverAllproductBasedOfferDatas = useSelector( (state) => state?.BookingOFferNew?.OverAllProductBasedProducts, shallowEqual @@ -185,7 +182,7 @@ export default function BSC1Search(props) { const TakAwayId = ConfigDataList?.find( (a) => a?.ConfigName === 'TakeAway' )?.ConfigId; - console.log(TakAwayId, "TakAwayId") + console.log(TakAwayId, 'TakAwayId'); const DineinId = ConfigDataList?.find( (a) => a?.ConfigName === 'Dine In' )?.ConfigId; @@ -200,10 +197,29 @@ export default function BSC1Search(props) { setScreenWidth(window.innerWidth); }; const [ExpiredProduct, setExpiredProduct] = useState(); - console.log(ExpiredProduct, 'ExpiredProduct'); const isSelectingRef = useRef(false); + const [expireModal, setExpireModal] = useState({ + open: false, + title: '', + onOk: null, + onCancel: null, + }); + + const openExpireModal = ({ title, onOk, onCancel }) => { + setExpireModal({ + open: true, + title, + onOk, + onCancel, + }); + }; + + const closeExpireModal = () => { + setExpireModal((prev) => ({ ...prev, open: false })); + }; + //dhana useEffect(() => { const handleKeyPress = (event) => { @@ -233,19 +249,17 @@ export default function BSC1Search(props) { //dhana async function getOffers() { - let response = await dispatch( + await dispatch( getOfferinBooking({ AppId: AppId, CompId: CompId, BranchId: BranchId }) ).unwrap(); - // if (response?.data?.statusCode === 0) { - // setMessageData('Error fetching offers'); - // setMessageType('error'); - // } } useEffect(() => { getOffers(); }, []); - + useEffect(() => { + focusPreferenceData(); + }, []); useEffect(() => { if (ConfigDataList?.length === 0) { @@ -253,28 +267,182 @@ export default function BSC1Search(props) { } }, []); + useEffect(() => { + const first = + preferenceDatas?.[0]?.['SettingDtlDetails']?.find( + (item) => item.SettingIdName === 'BillItemsOrder' + )?.SettingValue === 'Y'; + setAddFirst(first); + }, [preferenceDatas]); + useEffect(() => { if ( triggerOfferFree && CartOrderDetails?.length > 0 && FreeProdList?.length > 0 ) { - console.log('Before call'); let { ModifiedData, UpdatedFreeProdList, AppliedOffers } = handleLoyaltyFreeProducts(CartOrderDetails, FreeProdList); - console.log( - 'After call', - ModifiedData, - UpdatedFreeProdList, - AppliedOffers - ); - console.log(AppliedOffers, 'AppliedOffers'); dispatch(changeOrderCardDetails(ModifiedData)); dispatch(ChangeFullFreeProductList(UpdatedFreeProdList)); dispatch(changeFullOfferAppliedProducts(AppliedOffers)); dispatch(changeTriggerOfferFree(false)); } }, [triggerOfferFree]); + useEffect(() => { + updateScreenSize(); + window.addEventListener('resize', updateScreenSize); + return () => { + window.removeEventListener('resize', updateScreenSize); + }; + }, []); + useEffect(() => { + if (preFocus && screenWidth < 768) { + setAutoCompleteVisible(true); + } + }, [screenWidth]); + useEffect(() => { + preFocus && screenWidth > 768 && inputRef?.current?.focus(); + }, [CustChangeDropDown]); + useEffect(() => { + if (CreditFocus) { + setAutoCompleteVisible(false); + } else { + preFocus && screenWidth > 768 && setAutoCompleteVisible(true); + } + }, [CreditFocus]); + useEffect(() => { + if (PreOrderSearchStatus) { + setAutoCompleteVisible(false); + } else { + preFocus && screenWidth > 768 && setAutoCompleteVisible(true); + } + }, [PreOrderSearchStatus]); + + useEffect(() => { + preFocus && screenWidth > 768 && setAutoCompleteVisible(true); + preFocus && screenWidth > 768 && inputRef?.current?.focus(); + }, [printStatus]); + + useEffect(() => { + if ( + QuickAdd || + CompoPaymentIconStatus || + focusStatusCustMouse || + modelQty || + modelstock || + ModalVarient || + KioskFocusStatus + ) { + setAutoCompleteVisible(false); + } else { + preFocus && screenWidth > 768 && setAutoCompleteVisible(true); + preFocus && screenWidth > 768 && inputRef?.current?.focus(); + } + }, [ + QuickAdd, + CompoPaymentIconStatus, + focusStatusCustMouse, + modelQty, + modelstock, + ModalVarient, + KioskFocusStatus, + ]); + useEffect(() => { + if (!CompoPreOrderDtlStatus && !DropDownStatus) { + preFocus && screenWidth > 768 && setAutoCompleteVisible(true); + preFocus && screenWidth > 768 && inputRef?.current?.focus(); + } else { + setAutoCompleteVisible(false); + } + }, [CompoPreOrderDtlStatus]); + + useEffect(() => { + preFocus && screenWidth > 768 && inputRef?.current?.focus(); + }, [CartOrderDetails]); + + useEffect(() => { + setAutoCompleteVisible(Globalfocus ? false : true); + if (!Globalfocus) { + preFocus && screenWidth > 768 && inputRef?.current?.focus(); + } + }, [Globalfocus]); + useEffect(() => { + if (!preFocus) { + setAutoCompleteVisible(false); + } else { + setAutoCompleteVisible(true); + } + }, [preFocus]); + + useEffect(() => { + const handleDocumentClick = (event) => { + if ( + containerRef.current && + event.target !== inputRef?.current && + !isDescendant(containerRef?.current, event?.target) && + autoCompleteVisible && + !Globalfocus && + !QuickAdd && + screenWidth > 768 && + preFocus && + !CreditFocus && + !CompoPreOrderDtlStatus && + !focusStatusCustMouse && + !KioskFocusStatus + ) { + inputRef?.current?.focus(); + } + }; + + document.addEventListener('click', handleDocumentClick); + + return () => { + document.removeEventListener('click', handleDocumentClick); + }; + }, [ + inputRef, + Globalfocus, + autoCompleteVisible, + QuickAdd, + screenWidth, + preFocus, + CreditFocus, + CompoPreOrderDtlStatus, + CartOrderDetails, + KioskFocusStatus, + ]); + + useEffect(() => { + if (autoCompleteVisible) { + dispatch(changeCombofocus(false)); + preFocus && screenWidth > 768 && inputRef?.current?.focus(); + } + }, [autoCompleteVisible]); + + useEffect(() => { + if (autoCompleteVisible) { + preFocus && screenWidth > 768 && inputRef?.current?.focus(); + } + }, [autoCompleteVisible]); + useEffect(() => { + getPreferenceStock(); + }, []); + + useEffect(() => { + if (Object.keys(NewQrProductData)?.length > 0) { + let addQrProductData = { ...NewQrProductData }; + addQrProductData['OrderRate'] = addQrProductData['SellPrice']; + addQrProductData['OrderQty'] = addQrProductData['Quantity']; + addQrProductData['BookingTypeName'] = BookingType; + AddOrderDetails(addQrProductData); + } + }, [NewQrProductData]); + useEffect(() => { + if (Object.keys(SelectedProduct)?.length > 0) { + ProductSelected(SelectedProduct); + } + }, [SelectedProduct]); function handleLoyaltyFreeProducts(orderCardDtls, freeProdDtls) { if (!freeProdDtls || freeProdDtls.length === 0) { @@ -518,7 +686,7 @@ export default function BSC1Search(props) { WithoutTaxRate: availableFreeQty * item.OrderRate - (availableFreeQty * item.OrderRate * item.TaxPercentage) / - 100, + 100, Offer: availableFreeQty * item.OrderRate, }; @@ -567,7 +735,7 @@ export default function BSC1Search(props) { ((existingPaidItem.OrderQty + excessQty) * item.OrderRate * item.TaxPercentage) / - 100, + 100, }; ModifiedData.push(mergedPaidItem); @@ -602,7 +770,7 @@ export default function BSC1Search(props) { data?.InwardDtlId === item?.InwardDtlId && data?.ProdId === item?.ProdId && data?.OfferMessage?.[0]?.OfferId === - item?.OfferMessage?.[0]?.OfferId + item?.OfferMessage?.[0]?.OfferId ); if (isAlreadyExists !== -1) { @@ -622,11 +790,11 @@ export default function BSC1Search(props) { ).toFixed(2), WithoutTaxRate: (ModifiedData[isAlreadyExists].OrderQty + item.OrderQty) * - item.OrderRate - + item.OrderRate - ((ModifiedData[isAlreadyExists].OrderQty + item.OrderQty) * item.OrderRate * item.TaxPercentage) / - 100, + 100, Offer: (ModifiedData[isAlreadyExists].OrderQty + item.OrderQty) * item.OrderRate, @@ -652,10 +820,10 @@ export default function BSC1Search(props) { const appliedOfferAlreadyExists = AppliedOffers.findIndex( (offer) => offer?.FreeProductsList?.FreeProdId === - matchingFreeProduct?.FreeProdId && + matchingFreeProduct?.FreeProdId && offer?.TableName === matchingFreeProduct?.TableName && offer?.TableUniqueName === - matchingFreeProduct?.TableUniqueName && + matchingFreeProduct?.TableUniqueName && offer?.OfferId === matchingFreeProduct?.OfferId && offer?.OfferMode === matchingFreeProduct?.OfferMode && offer?.FreeProductsList?.ProdVariantDetails?.[0] @@ -835,18 +1003,6 @@ export default function BSC1Search(props) { }; } - useEffect(() => { - focusPreferenceData(); - }, []); - - useEffect(() => { - const first = - preferenceDatas?.[0]?.['SettingDtlDetails']?.find( - (item) => item.SettingIdName === 'BillItemsOrder' - )?.SettingValue === 'Y'; - setAddFirst(first); - }, [preferenceDatas]); - function safeRound(amountStr) { if (amountStr == null) return '0.00'; const cleaned = String(amountStr).replace(/[^0-9.-]+/g, ''); @@ -862,161 +1018,6 @@ export default function BSC1Search(props) { filteredDatas?.length > 0 ? setpreFocus(false) : setpreFocus(true); }; - useEffect(() => { - updateScreenSize(); - window.addEventListener('resize', updateScreenSize); - return () => { - window.removeEventListener('resize', updateScreenSize); - }; - }, []); - useEffect(() => { - if (preFocus && screenWidth < 768) { - setAutoCompleteVisible(true); - } - }, [screenWidth]); - useEffect(() => { - preFocus && screenWidth > 768 && inputRef?.current?.focus(); - }, [CustChangeDropDown]); - useEffect(() => { - if (CreditFocus) { - setAutoCompleteVisible(false); - } else { - preFocus && screenWidth > 768 && setAutoCompleteVisible(true); - } - }, [CreditFocus]); - useEffect(() => { - if (PreOrderSearchStatus) { - setAutoCompleteVisible(false); - } else { - preFocus && screenWidth > 768 && setAutoCompleteVisible(true); - } - }, [PreOrderSearchStatus]); - - useEffect(() => { - preFocus && screenWidth > 768 && setAutoCompleteVisible(true); - preFocus && screenWidth > 768 && inputRef?.current?.focus(); - }, [printStatus]); - // useEffect(() => { - // if (QuickAdd) { - // setAutoCompleteVisible(false); - // } else { - // preFocus && screenWidth > 768 && setAutoCompleteVisible(true); - // } - // }, [QuickAdd]); - useEffect(() => { - if ( - QuickAdd || - CompoPaymentIconStatus || - focusStatusCustMouse || - modelQty || - modelstock || - ModalVarient || - KioskFocusStatus - ) { - setAutoCompleteVisible(false); - } else { - preFocus && screenWidth > 768 && setAutoCompleteVisible(true); - preFocus && screenWidth > 768 && inputRef?.current?.focus(); - } - }, [ - QuickAdd, - CompoPaymentIconStatus, - focusStatusCustMouse, - modelQty, - modelstock, - ModalVarient, - KioskFocusStatus, - ]); - useEffect(() => { - if (!CompoPreOrderDtlStatus && !DropDownStatus) { - preFocus && screenWidth > 768 && setAutoCompleteVisible(true); - preFocus && screenWidth > 768 && inputRef?.current?.focus(); - } else { - setAutoCompleteVisible(false); - } - }, [CompoPreOrderDtlStatus]); - - useEffect(() => { - preFocus && screenWidth > 768 && inputRef?.current?.focus(); - }, [CartOrderDetails]); - // useEffect(() => { - // if (!CompoPaymentIconStatus) { - // preFocus && screenWidth > 768 && setAutoCompleteVisible(true); - // // inputRef.current.click(); - // preFocus && screenWidth > 768 && inputRef?.current?.focus(); - // } else { - // setAutoCompleteVisible(false); - // } - // }, [CompoPaymentIconStatus]); - - // useEffect(() => { - // if (focusStatusCustMouse) { - // setAutoCompleteVisible(false); - // } else { - // preFocus && screenWidth > 768 && setAutoCompleteVisible(true); - // } - // }, [focusStatusCustMouse]); - - useEffect(() => { - setAutoCompleteVisible(Globalfocus ? false : true); - if (!Globalfocus) { - preFocus && screenWidth > 768 && inputRef?.current?.focus(); - } - }, [Globalfocus]); - useEffect(() => { - if (!preFocus) { - setAutoCompleteVisible(false); - } else { - setAutoCompleteVisible(true); - } - }, [preFocus]); - - useEffect(() => { - const handleDocumentClick = (event) => { - if ( - containerRef.current && - event.target !== inputRef?.current && - !isDescendant(containerRef?.current, event?.target) && - // isDescendant(document.documentElement, event.target) && - autoCompleteVisible && - !Globalfocus && - !QuickAdd && - screenWidth > 768 && - preFocus && - !CreditFocus && - !CompoPreOrderDtlStatus && - !focusStatusCustMouse && - !KioskFocusStatus - ) { - inputRef?.current?.focus(); - } - }; - - document.addEventListener('click', handleDocumentClick); - - return () => { - document.removeEventListener('click', handleDocumentClick); - }; - }, [ - inputRef, - Globalfocus, - autoCompleteVisible, - QuickAdd, - screenWidth, - preFocus, - CreditFocus, - CompoPreOrderDtlStatus, - CartOrderDetails, - KioskFocusStatus, - ]); - - useEffect(() => { - if (autoCompleteVisible) { - dispatch(changeCombofocus(false)); - preFocus && screenWidth > 768 && inputRef?.current?.focus(); - } - }, [autoCompleteVisible]); - const isDescendant = (parent, child) => { let node = child.parentNode; while (node !== null) { @@ -1031,36 +1032,11 @@ export default function BSC1Search(props) { preFocus && screenWidth > 768 && setAutoCompleteVisible(true); }; - useEffect(() => { - if (autoCompleteVisible) { - preFocus && screenWidth > 768 && inputRef?.current?.focus(); - } - }, [autoCompleteVisible]); - const OnfocusTrue = () => { preFocus && screenWidth > 768 && setAutoCompleteVisible(true); preFocus && screenWidth > 768 && inputRef?.current?.focus(); }; - useEffect(() => { - getPreferenceStock(); - }, []); - - useEffect(() => { - if (Object.keys(NewQrProductData)?.length > 0) { - let addQrProductData = { ...NewQrProductData }; - addQrProductData['OrderRate'] = addQrProductData['SellPrice']; - addQrProductData['OrderQty'] = addQrProductData['Quantity']; - addQrProductData['BookingTypeName'] = BookingType; - AddOrderDetails(addQrProductData); - } - }, [NewQrProductData]); - useEffect(() => { - if (Object.keys(SelectedProduct)?.length > 0) { - ProductSelected(SelectedProduct); - } - }, [SelectedProduct]); - const stopScannerFromParent = () => { if (scannerRef.current) { scannerRef?.current?.stopScanner(); // Call stopScanner from the child component @@ -1096,19 +1072,11 @@ export default function BSC1Search(props) { setMessageData(err?.error); setMessageType('error'); } - await searchdata(value); + // await searchdata(value); setOpenScanner(false); // Close the modal after scanning stopScannerFromParent(); }; - - - // Clear QR tracker function - const clearQrTracker = () => { - setLastScannedQr(null); - setCurrentSessionQr(null); - }; - const ProductNameOnChange = (data) => { if (isSelectingRef.current) { isSelectingRef.current = false; @@ -1131,7 +1099,7 @@ export default function BSC1Search(props) { const updatedProduct = { ...lastScannedQr, OrderQty: (lastScannedQr.OrderQty || 1) + 1, - Quantity: (lastScannedQr.Quantity || 1) + 1 + Quantity: (lastScannedQr.Quantity || 1) + 1, }; ProductSelected(updatedProduct); } @@ -1199,46 +1167,51 @@ export default function BSC1Search(props) { function removeDefaultVariantStock(data) { return { ...data, - ProductDetail: (data.ProductDetail || []).map(product => { + ProductDetail: (data.ProductDetail || []).map((product) => { // Only act when StockAvailable === 'Y' if (product.StockAvailable !== 'Y') { - return product + return product; } return { ...product, - ProdVariantDetails: (product.ProdVariantDetails || []).map(variant => { - const hasDefaultVariant = (variant.StockDetails || []).some( - stock => stock.DefaultVariant === 'Y' - ) + ProdVariantDetails: (product.ProdVariantDetails || []).map( + (variant) => { + const hasDefaultVariant = (variant.StockDetails || []).some( + (stock) => stock.DefaultVariant === 'Y' + ); - // If no DefaultVariant exists, return as-is - if (!hasDefaultVariant) { - return variant - } + // If no DefaultVariant exists, return as-is + if (!hasDefaultVariant) { + return variant; + } - return { - ...variant, - StockDetails: variant.StockDetails.filter( - stock => stock.DefaultVariant !== 'Y' - ) + return { + ...variant, + StockDetails: variant.StockDetails.filter( + (stock) => stock.DefaultVariant !== 'Y' + ), + }; } - }) - } - }) - } + ), + }; + }), + }; } const ProductOnSelect = async (data) => { isSelectingRef.current = true; let ProdNamedata = ProductList?.find((item) => item.ProdName === data); - console.log(ProdNamedata, "ProdNamedata") const removedDefault = removeDefaultVariantStock(ProdNamedata); setSelectedProduct(removedDefault); }; const ProductSelected = (item) => { if (item.OverAllExpStatus == 'Y') { - setexpModel(true); + // setexpModel(true); + openExpireModal({ + title: 'Product Expires', + onOk: () => expFun(Item), + }); setItem(item); } else { setQtydata(item); @@ -1537,9 +1510,6 @@ export default function BSC1Search(props) { orderDetails, ProdVariantName ) => { - // let ReorderProdetails = BookingType === "Dine In" && !UnpaidData ? ReportholdData?.OrderDtlDetails - // : BookingType === "Dine In" && UnpaidData ? ReportholdData?.productDetails - // : ReportholdData?.productDetails if (onePeiceFlow) { let SelectedProduct = ReorderProductData?.filter( (a) => a?.ProdId === ProdId && a?.ProdVariantName === ProdVariantName @@ -1679,11 +1649,11 @@ export default function BSC1Search(props) { dataIndex: 'VarientName', key: 'VarientName', align: 'left', - render: (_, record, index) => ( + render: (_, record) => ( 0 || - record.StockCount === 'Stock Not Maintained' + record.StockCount === 'Stock Not Maintained' ? { color: '#000', cursor: 'pointer' } : { color: '#f49898', cursor: 'not-allowed' } } @@ -1713,7 +1683,7 @@ export default function BSC1Search(props) { 0 || - record.StockCount === 'Stock Not Maintained' + record.StockCount === 'Stock Not Maintained' ? { color: '#000', cursor: 'pointer' } : { color: '#f49898', cursor: 'not-allowed' } } @@ -1743,7 +1713,7 @@ export default function BSC1Search(props) { 0 || - record.StockCount === 'Stock Not Maintained' + record.StockCount === 'Stock Not Maintained' ? { color: '#000', cursor: 'pointer' } : { color: '#f49898', cursor: 'not-allowed' } } @@ -1764,21 +1734,6 @@ export default function BSC1Search(props) { }; }, }, - // { - // title:'Stock Quantity', - // dataIndex:'StockCount', - // key:'StockCount', - // align: 'right', - // onCell: (record) => { - // return { - // onClick: () => { - // if (record.StockCount > 0 || record.StockCount==='Stock Not Maintained') { - // Stockfun(record); - // } - // }, - // }; - // }, - // } ]; const stockcolumns = [ { @@ -1812,7 +1767,7 @@ export default function BSC1Search(props) { dataIndex: 'StockCount', key: 'StockCount', align: 'center', - render: (_, record, index) => ( + render: (_, record) => ( 0 @@ -1838,7 +1793,7 @@ export default function BSC1Search(props) { dataIndex: 'Stock Date', key: 'Stock Date', align: 'center', - render: (_, record, index) => ( + render: (_, record) => ( 0 @@ -1922,11 +1877,11 @@ export default function BSC1Search(props) { StockCount: qtydata?.ProductDetail?.[0]?.StockAvailable === 'Y' ? returnVariantStock( - qtydata?.ProductDetail?.[QtyIndex]?.ProdId, - item?.OverAllQty, - CartOrderDetails, - item?.ProdVariantName - ) + qtydata?.ProductDetail?.[QtyIndex]?.ProdId, + item?.OverAllQty, + CartOrderDetails, + item?.ProdVariantName + ) : 'Stock Not Maintained', }); }); @@ -1942,17 +1897,17 @@ export default function BSC1Search(props) { 'Batch No': item?.BatchRef, StockCount: onePeiceFlow ? returnCountStock( - item?.ProdId, - item?.BalanceQty, - CartOrderDetails, - item?.InwardDtlId - ) * item?.NoOfPcs + item?.ProdId, + item?.BalanceQty, + CartOrderDetails, + item?.InwardDtlId + ) * item?.NoOfPcs : returnCountStock( - item?.ProdId, - item?.BalanceQty, - CartOrderDetails, - item?.InwardDtlId - ), + item?.ProdId, + item?.BalanceQty, + CartOrderDetails, + item?.InwardDtlId + ), 'Stock Date': StockDate(item?.InwardDate), Price: onePeiceFlow ? item?.OnePcsPrice : item?.SellPrice, ExpDate: @@ -2006,13 +1961,13 @@ export default function BSC1Search(props) { (cartItem) => cartItem?.ProdId === item?.ProductDetail?.[QtyIndex]?.ProdId && cartItem?.InwardDtlId === - item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ - VarientIndex - ]?.StockDetails?.[0]?.InwardDtlId && + item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ + VarientIndex + ]?.StockDetails?.[0]?.InwardDtlId && cartItem?.OrderRate === - item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ - VarientIndex - ]?.StockDetails?.[0]?.SellPrice && + item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ + VarientIndex + ]?.StockDetails?.[0]?.SellPrice && !cartItem?.SalesId ); @@ -2021,9 +1976,9 @@ export default function BSC1Search(props) { (cartItem) => cartItem?.ProdId === item?.ProductDetail?.[QtyIndex]?.ProdId && cartItem?.InwardDtlId === - item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ - VarientIndex - ]?.StockDetails?.[0]?.InwardDtlId && + item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ + VarientIndex + ]?.StockDetails?.[0]?.InwardDtlId && // (cartItem?.OrderRate === item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]?.StockDetails?.[0]?.SellPrice) !cartItem?.SalesId ); @@ -2065,11 +2020,11 @@ export default function BSC1Search(props) { (cartItem) => cartItem?.ProdId === item?.ProductDetail?.[QtyIndex]?.ProdId && cartItem?.InwardDtlId === - item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] - ?.StockDetails?.[0]?.InwardDtlId && + item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] + ?.StockDetails?.[0]?.InwardDtlId && cartItem?.OrderRate === - item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] - ?.StockDetails?.[0]?.SellPrice && + item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] + ?.StockDetails?.[0]?.SellPrice && !cartItem?.SalesId ); @@ -2078,9 +2033,9 @@ export default function BSC1Search(props) { (cartItem) => cartItem?.ProdId === item?.ProductDetail?.[QtyIndex]?.ProdId && cartItem?.InwardDtlId === - item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ - VarientIndex - ]?.StockDetails?.[0]?.InwardDtlId && + item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ + VarientIndex + ]?.StockDetails?.[0]?.InwardDtlId && // (cartItem?.OrderRate === item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]?.StockDetails?.[0]?.SellPrice) !cartItem?.SalesId ); @@ -2140,7 +2095,14 @@ export default function BSC1Search(props) { } } else if (overallExpStatus === 'Y' && ExpiredProduct) { setVarItem(index.key); - setexpVarModel(true); + openExpireModal({ + title: 'Variant Expires', + onOk: () => expVerFun(VarItem), + onCancel: () => { + setRepeatedModel(false); + setProdexpir(false); + }, + }); } } else { if ( @@ -2151,13 +2113,13 @@ export default function BSC1Search(props) { (cartItem) => cartItem?.ProdId === qtydata?.ProductDetail?.[QtyIndex]?.ProdId && cartItem?.InwardDtlId === - qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ - index.key - ]?.StockDetails?.[0]?.InwardDtlId && + qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ + index.key + ]?.StockDetails?.[0]?.InwardDtlId && cartItem?.OrderRate === - qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ - index.key - ]?.StockDetails?.[0]?.SellPrice && + qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ + index.key + ]?.StockDetails?.[0]?.SellPrice && !cartItem?.SalesId ); @@ -2165,11 +2127,11 @@ export default function BSC1Search(props) { let Isincartonepc = CartOrderDetails?.filter( (cartItem) => cartItem?.ProdId === - qtydata?.ProductDetail?.[QtyIndex]?.ProdId && + qtydata?.ProductDetail?.[QtyIndex]?.ProdId && cartItem?.InwardDtlId === - qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ - VarientIndex - ]?.StockDetails?.[0]?.InwardDtlId && + qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ + VarientIndex + ]?.StockDetails?.[0]?.InwardDtlId && // (cartItem?.OrderRate === item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]?.StockDetails?.[0]?.SellPrice) !cartItem?.SalesId ); @@ -2217,7 +2179,14 @@ export default function BSC1Search(props) { if (!ExpiredProduct) { expVerFun(index.key); } else { - setexpVarModel(true); + openExpireModal({ + title: 'Variant Expires', + onOk: () => expVerFun(VarItem), + onCancel: () => { + setRepeatedModel(false); + setProdexpir(false); + }, + }); } } } @@ -2226,11 +2195,11 @@ export default function BSC1Search(props) { (cartItem) => cartItem?.ProdId === qtydata?.ProductDetail?.[QtyIndex]?.ProdId && cartItem?.InwardDtlId === - qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[index.key] - ?.StockDetails?.[0]?.InwardDtlId && + qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[index.key] + ?.StockDetails?.[0]?.InwardDtlId && cartItem?.OrderRate === - qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[index.key] - ?.StockDetails?.[0]?.SellPrice && + qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[index.key] + ?.StockDetails?.[0]?.SellPrice && !cartItem?.SalesId ); @@ -2239,9 +2208,9 @@ export default function BSC1Search(props) { (cartItem) => cartItem?.ProdId === qtydata?.ProductDetail?.[QtyIndex]?.ProdId && cartItem?.InwardDtlId === - qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ - VarientIndex - ]?.StockDetails?.[0]?.InwardDtlId && + qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ + VarientIndex + ]?.StockDetails?.[0]?.InwardDtlId && // (cartItem?.OrderRate === item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]?.StockDetails?.[0]?.SellPrice) !cartItem?.SalesId ); @@ -2281,33 +2250,24 @@ export default function BSC1Search(props) { } }; const VarientFun = (index) => { - const QtyExpire = index?.ProdVariantDetails?.every( - (item) => item.OverAllExpStatus === 'Y' + let selectedProIndex = qtydata?.ProductDetail?.findIndex( + (item) => + item?.ProdId === index?.ProdId && + item?.Size === index?.Size && + item?.UomName === index?.UomName && + item?.Brand === index?.Brand ); - if (QtyExpire && ExpiredProduct) { - setExpQtyModel(true); - setQtyExpData(index); + setQtyIndex(selectedProIndex); + let count = + qtydata?.ProductDetail[selectedProIndex]?.ProdVariantDetails?.length; + if (count > 1) { + setModelQty(false); + setModalVarient(true); } else { - let selectedProIndex = qtydata?.ProductDetail?.findIndex( - (item) => - item?.ProdId === index?.ProdId && - item?.Size === index?.Size && - item?.UomName === index?.UomName && - item?.Brand === index?.Brand - ); - - setQtyIndex(selectedProIndex); - let count = - qtydata?.ProductDetail[selectedProIndex]?.ProdVariantDetails?.length; - if (count > 1) { - setModelQty(false); - setModalVarient(true); - } else { - const item = { QtyIndex: selectedProIndex, VarientIndex: 0 }; - singleVarient(item); - setModelQty(false); - } + const item = { QtyIndex: selectedProIndex, VarientIndex: 0 }; + singleVarient(item); + setModelQty(false); } }; const singleVarient = (item) => { @@ -2325,15 +2285,15 @@ export default function BSC1Search(props) { let Isincart = CartOrderDetails?.find( (cartItem) => cartItem?.ProdId === - qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdId && + qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdId && cartItem?.InwardDtlId === - qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ - item?.VarientIndex - ]?.StockDetails?.[0]?.InwardDtlId && + qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ + item?.VarientIndex + ]?.StockDetails?.[0]?.InwardDtlId && cartItem?.OrderRate === - qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ - item?.VarientIndex - ]?.StockDetails?.[0]?.SellPrice && + qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ + item?.VarientIndex + ]?.StockDetails?.[0]?.SellPrice && !cartItem?.SalesId ); @@ -2341,11 +2301,11 @@ export default function BSC1Search(props) { let Isincartonepc = CartOrderDetails?.filter( (cartItem) => cartItem?.ProdId === - qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdId && + qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdId && cartItem?.InwardDtlId === - qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ - item?.VarientIndexs - ]?.StockDetails?.[0]?.InwardDtlId && + qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ + item?.VarientIndexs + ]?.StockDetails?.[0]?.InwardDtlId && // (cartItem?.OrderRate === item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]?.StockDetails?.[0]?.SellPrice) !cartItem?.SalesId ); @@ -2423,15 +2383,15 @@ export default function BSC1Search(props) { let Isincart = CartOrderDetails?.find( (cartItem) => cartItem?.ProdId === - qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdId && + qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdId && cartItem?.InwardDtlId === - qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ - item?.VarientIndex - ]?.StockDetails?.[0]?.InwardDtlId && + qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ + item?.VarientIndex + ]?.StockDetails?.[0]?.InwardDtlId && cartItem?.OrderRate === - qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ - item?.VarientIndex - ]?.StockDetails?.[0]?.SellPrice && + qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ + item?.VarientIndex + ]?.StockDetails?.[0]?.SellPrice && !cartItem?.SalesId ); @@ -2439,11 +2399,11 @@ export default function BSC1Search(props) { let Isincartonepc = CartOrderDetails?.filter( (cartItem) => cartItem?.ProdId === - qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdId && + qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdId && cartItem?.InwardDtlId === - qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ - item?.VarientIndex - ]?.StockDetails?.[0]?.InwardDtlId && + qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ + item?.VarientIndex + ]?.StockDetails?.[0]?.InwardDtlId && // (cartItem?.OrderRate === item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]?.StockDetails?.[0]?.SellPrice) !cartItem?.SalesId ); @@ -2538,13 +2498,20 @@ export default function BSC1Search(props) { } else if (overallExpStatus === 'Y' && repeatedModel) { dataTransfer(qtydata, QtyIndex, VarientIndex, item.key, onePeiceFlow); } else { - setexpStockModel(true); + openExpireModal({ + title: 'Stock Expires', + onOk: () => expStockFun(StockItem), + onCancel: () => { + setRepeatedModel(false); + setProdexpir(false); + }, + }); setStockItem(item.key); } } setProdexpir(false); - setRepeatedModel(false); + closeExpireModal(); }; useEffect(() => { @@ -2556,7 +2523,7 @@ export default function BSC1Search(props) { const isKgsProduct = (a?.ProductDetail?.[QtyIndex]?.UomName?.toLowerCase() === 'kgs' || a?.ProductDetail?.[QtyIndex]?.UomName?.toLowerCase() === - 'kg'?.toLowerCase()) && + 'kg'?.toLowerCase()) && a?.ProductDetail?.[QtyIndex]?.Size === '1'; if ( @@ -2565,23 +2532,15 @@ export default function BSC1Search(props) { WeightScaleWeight > 0.005 && WeightScaleWeight !== null ) { - // if ( - // (a?.ProductDetail?.[QtyIndex]?.UomName?.toLowerCase() === - // 'KGS'?.toLowerCase() || - // a?.ProductDetail?.[QtyIndex]?.UomName?.toLowerCase() === - // 'KG'?.toLowerCase()) && - // a?.ProductDetail?.[QtyIndex]?.Size === 1 - // ) { - // if (WeightScaleWeight > 0 && WeightScaleWeight !== null) { let TotalOrderRate = parseFloat( onePcs ? (a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] - ?.StockDetails?.[stockIndex]?.OnePcsPrice / - 1000) * - (parseFloat(WeightScaleWeight) * 1000) + ?.StockDetails?.[stockIndex]?.OnePcsPrice / + 1000) * + (parseFloat(WeightScaleWeight) * 1000) : a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] - ?.StockDetails?.[stockIndex]?.SellPrice / 1000 + ?.StockDetails?.[stockIndex]?.SellPrice / 1000 ) * (parseFloat(WeightScaleWeight) * 1000); let data = { @@ -2637,10 +2596,11 @@ export default function BSC1Search(props) { ?.StockDetails?.[stockIndex]?.InwardId, MRP: onePcs ? a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] - ?.StockDetails?.[stockIndex]?.OnePcsPrice + ?.StockDetails?.[stockIndex]?.OnePcsPrice : a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] - ?.StockDetails?.[stockIndex]?.MRP, - FullProductIdentifierDtls:a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] + ?.StockDetails?.[stockIndex]?.MRP, + FullProductIdentifierDtls: + a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] ?.StockDetails?.[stockIndex]?.ProductIdentifierDtls, OrderRate: parseFloat(TotalOrderRate).toFixed(2), SellingPrice: parseFloat(TotalOrderRate).toFixed(2), @@ -2669,7 +2629,7 @@ export default function BSC1Search(props) { dispatch(changeSearchedData('')); AddOrderDetails(data); // dispatch(changeWeightScaleWeight(null)); - setRepeatedModel(false); + closeExpireModal(); setProdexpir(false); setOnePeiceFlow(false); // } else { @@ -2746,19 +2706,19 @@ export default function BSC1Search(props) { ?.StockDetails?.[stockIndex]?.InwardId, MRP: onePcs ? a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] - ?.StockDetails?.[stockIndex]?.OnePcsPrice + ?.StockDetails?.[stockIndex]?.OnePcsPrice : a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] - ?.StockDetails?.[stockIndex]?.MRP, + ?.StockDetails?.[stockIndex]?.MRP, OrderRate: onePcs ? a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] - ?.StockDetails?.[stockIndex]?.OnePcsPrice + ?.StockDetails?.[stockIndex]?.OnePcsPrice : a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] - ?.StockDetails?.[stockIndex]?.SellPrice, + ?.StockDetails?.[stockIndex]?.SellPrice, SellingPrice: onePcs ? a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] - ?.StockDetails?.[stockIndex]?.OnePcsPrice + ?.StockDetails?.[stockIndex]?.OnePcsPrice : a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] - ?.StockDetails?.[stockIndex]?.SellPrice, + ?.StockDetails?.[stockIndex]?.SellPrice, SuppId: a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] ?.StockDetails?.[stockIndex]?.SuppId, @@ -2771,8 +2731,9 @@ export default function BSC1Search(props) { Offer: a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] ?.StockDetails?.[stockIndex]?.OfferPrice, - FullProductIdentifierDtls:a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] - ?.StockDetails?.[stockIndex]?.ProductIdentifierDtls, + FullProductIdentifierDtls: + a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] + ?.StockDetails?.[stockIndex]?.ProductIdentifierDtls, BookingTypeName: BookingType, CounterName: a?.CounterName, }; @@ -2806,46 +2767,6 @@ export default function BSC1Search(props) { } } }; - const CalculateOverallQty = (item, filterItem) => { - console.log(item, filterItem, 'totalQuantitytotalQuantity'); - const totalQuantity = filterItem?.reduce((accumulator, card) => { - if (card?.StockAvailable !== 'Y') return accumulator; - if (item?.SinglePc !== 'Y') { - let quantity = 0; - - if (card?.SinglePc !== 'Y') { - quantity = card.OrderQty; - } else { - if (card?.OverAllPcs % card?.NoOfPcs >= card?.OrderQty) { - quantity = 0; - } else { - quantity = Math.ceil(card?.OrderQty / card?.NoOfPcs); - } - } - return accumulator + parseInt(quantity); - } else { - let quantity = 0; - - if (card?.SinglePc !== 'Y') { - quantity = card?.OrderQty * card?.NoOfPcs; - } else { - quantity = card?.OrderQty; - } - return accumulator + parseInt(quantity); - } - }, 0); - console.log( - item?.OverAllPcs, - item?.BalanceQty, - totalQuantity, - 'totalQuantity' - ); - if (!item) return 0; - return ( - (item?.SinglePc === 'Y' ? item?.OverAllPcs : item?.BalanceQty) - - totalQuantity - ); - }; const calculateOverAllQty = (item, filterItems) => { if (!item) return 0; @@ -2875,413 +2796,9 @@ export default function BSC1Search(props) { }, 0) || 0; const availableQty = - item?.SinglePc === 'Y' ? item?.OverAllPcs : (item?.BalanceQty || 0); + item?.SinglePc === 'Y' ? item?.OverAllPcs : item?.BalanceQty || 0; return (availableQty || 0) - totalUsedQty; }; - const AddOrderDetails1 = async (item) => { - dispatch(changeHoldOrderDtl(false)); - dispatch(changePreviousOrderLength(CartOrderDetails?.length)); - const OtherOrderDatas = CartOrderDetails?.filter( - (cartItem) => - !( - cartItem?.ProdId === item?.ProdId && - cartItem?.InwardDtlId === item?.InwardDtlId && - cartItem?.OrderRate === item?.OrderRate && - cartItem?.BookingTypeName === item?.BookingTypeName - ) && !cartItem?.SalesId - ); - const OtherOrderDatawithsales = CartOrderDetails?.filter( - (cartItem) => cartItem?.SalesId - ); - const OtherorderDataforNormal = CartOrderDetails?.filter( - (cartItem) => - !( - cartItem?.ProdId === item?.ProdId && - cartItem?.InwardDtlId === item?.InwardDtlId && - cartItem?.OrderRate === item?.OrderRate && - cartItem?.BookingTypeName === item?.BookingTypeName && - !cartItem?.SalesId - ) - ); - const isItemInCart = CartOrderDetails?.find( - (cartItem) => - cartItem?.ProdId === item?.ProdId && - cartItem?.InwardDtlId === item?.InwardDtlId && - cartItem?.OrderRate === item?.OrderRate && - cartItem?.BookingTypeName === item?.BookingTypeName && - !cartItem?.SalesId - ); // check if the item is already in the cart - const isItemInCartfilter = CartOrderDetails?.filter( - (cartItem) => - cartItem?.ProdId === item?.ProdId && - cartItem?.InwardDtlId === item?.InwardDtlId && - !( - cartItem?.OrderRate === item?.OrderRate && - cartItem?.BookingTypeName === item?.BookingTypeName - ) && - !cartItem?.SalesId - ); // check if the item is already in the cart - console.log( - isItemInCartfilter, - isItemInCart, - 'isItemInCartfilterisItemInCartfilter' - ); - const isItemNotInDine = CartOrderDetails?.find( - (cartItem) => - cartItem?.ProdId === item?.ProdId && - cartItem?.InwardDtlId === item?.InwardDtlId && - cartItem?.OrderRate === item?.OrderRate && - cartItem?.BookingTypeName === item?.BookingTypeName && - !cartItem?.SalesId - ); // check if the item is already in the cart - const isItemInCartHold = CartOrderDetails?.find( - (cartItem) => - cartItem?.ProdId === item?.ProdId && - cartItem?.InwardDtlId === item?.InwardDtlId && - cartItem?.OrderRate === item?.OrderRate && - cartItem?.BookingTypeName === item?.BookingTypeName - ); // check if the item is already in the cart - const isItemInCartHoldfilter = CartOrderDetails?.filter( - (cartItem) => - cartItem?.ProdId === item?.ProdId && - cartItem?.InwardDtlId === item?.InwardDtlId && - !( - cartItem?.OrderRate === item?.OrderRate && - cartItem?.BookingTypeName === item?.BookingTypeName - ) - ); // check if the item is already in the cart - const holddataproduct = ReorderProductData?.filter( - (cartItem) => - cartItem?.ProdId === item?.ProdId && - cartItem?.InwardDtlId === item?.InwardDtlId - ); - let totalSelectedProductQty = holddataproduct?.reduce( - (accumulator, card) => { - return ( - accumulator + - parseInt( - card?.StockAvailable === 'Y' - ? item?.SinglePc === 'Y' - ? card.SinglePc !== 'Y' - ? card.OrderQty * card.NoOfPcs - : card.OrderQty - : card.SinglePc !== 'Y' - ? card.OrderQty - : card.OverAllPcs % card.NoOfPcs >= card.OrderQty - ? 0 - : card.OrderQty % card.NoOfPcs === 0 - ? Math.floor(card.OrderQty / card.NoOfPcs) - : Math.floor(card.OrderQty / card.NoOfPcs) + 1 - : 0 - ) - ); - }, - 0 - ); - - let OverallQuantityhold = - CalculateOverallQty(isItemInCartHold, isItemInCartHoldfilter) + - totalSelectedProductQty; - - const OtherorderDataforNormalWithoutSalesId = CartOrderDetails?.filter( - (cartItem) => - !( - cartItem?.ProdId === item?.ProdId && - cartItem?.InwardDtlId === item?.InwardDtlId && - cartItem?.OrderRate === item?.OrderRate && - cartItem?.BookingTypeName === item?.BookingTypeName - ) - ); - - if ( - isItemInCart && - BookingType != 'Dine In' && - OrderType != 'Hold' && - OrderType != 'PreOrder' - ) { - if ( - (CalculateOverallQty(isItemInCart, isItemInCartfilter) > - isItemInCart?.OrderQty && - isItemInCart?.StockAvailable === 'Y') || - isItemInCart?.StockAvailable !== 'Y' - ) { - const UpdatedCartItem = - // if the item is already in the cart, increase the quantity of the item - { - ...isItemInCart, - OrderQty: isItemInCart?.OrderQty + 1, - TotalAmt: (isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate, - TaxAmt: ( - ((isItemInCart?.OrderQty + 1) * - isItemInCart?.OrderRate * - isItemInCart?.TaxPercentage) / - (100 + isItemInCart?.TaxPercentage) - ).toFixed(2), - WithoutTaxRate: - (isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate - - ( - ((isItemInCart?.OrderQty + 1) * - isItemInCart?.OrderRate * - isItemInCart?.TaxPercentage) / - (100 + isItemInCart?.TaxPercentage) - ).toFixed(2), - }; - const UpdatedData = addFirst - ? [UpdatedCartItem, ...OtherorderDataforNormal] - : [...OtherorderDataforNormal, UpdatedCartItem]; - - // if (OfferCheckedInSetup) { - // await applyOffer(UpdatedData); - // } else { - dispatch(changeOrderCardDetails(UpdatedData)); - // } - } else { - setMessageType('error'); - setMessageData('Stock Not Available'); - formRef.current.resetFields(['ItemName']); - setSelectedProduct({}); - } - } else if (isItemInCartHold && OrderType === 'Hold') { - if ( - (OverallQuantityhold > isItemInCartHold?.OrderQty && - isItemInCartHold?.StockAvailable === 'Y') || - isItemInCartHold?.StockAvailable !== 'Y' - ) { - const UpdatedCartItem = { - ...isItemInCartHold, - OrderQty: isItemInCartHold?.OrderQty + 1, - TotalAmt: - (isItemInCartHold?.OrderQty + 1) * isItemInCartHold?.OrderRate, - TaxAmt: ( - ((isItemInCartHold?.OrderQty + 1) * - isItemInCartHold?.OrderRate * - isItemInCartHold?.TaxPercentage) / - (100 + isItemInCartHold?.TaxPercentage) - ).toFixed(2), - WithoutTaxRate: - (isItemInCartHold?.OrderQty + 1) * isItemInCartHold?.OrderRate - - ( - ((isItemInCartHold?.OrderQty + 1) * - isItemInCartHold?.OrderRate * - isItemInCartHold?.TaxPercentage) / - (100 + isItemInCartHold?.TaxPercentage) - ).toFixed(2), - }; - // otherwise, return the cart item - - const UpdatedData = addFirst - ? [UpdatedCartItem, ...OtherorderDataforNormalWithoutSalesId] - : [...OtherorderDataforNormalWithoutSalesId, UpdatedCartItem]; - - // if (OfferCheckedInSetup) { - // await applyOffer(UpdatedData); - // } else { - dispatch(changeOrderCardDetails(UpdatedData)); - // } - } else { - setMessageType('error'); - setMessageData('Stock Not Available'); - formRef.current.resetFields(['ItemName']); - setSelectedProduct({}); - } - } else if ( - isItemNotInDine && - BookingType == 'Dine In' && - OrderType != 'Hold' - ) { - if ( - (CalculateOverallQty(isItemInCart, isItemInCartfilter) > - isItemNotInDine?.OrderQty && - isItemNotInDine?.StockAvailable === 'Y') || - isItemNotInDine?.StockAvailable !== 'Y' - ) { - const UpdatedCartItem = { - ...isItemNotInDine, - OrderQty: isItemNotInDine?.OrderQty + 1, - TotalAmt: - (isItemNotInDine?.OrderQty + 1) * isItemNotInDine?.OrderRate, - TaxAmt: ( - ((isItemNotInDine?.OrderQty + 1) * - isItemNotInDine?.OrderRate * - isItemNotInDine?.TaxPercentage) / - (100 + isItemNotInDine?.TaxPercentage) - ).toFixed(2), - WithoutTaxRate: - (isItemNotInDine?.OrderQty + 1) * isItemNotInDine?.OrderRate - - ( - ((isItemNotInDine?.OrderQty + 1) * - isItemNotInDine?.OrderRate * - isItemNotInDine?.TaxPercentage) / - (100 + isItemNotInDine?.TaxPercentage) - ).toFixed(2), - }; - // otherwise, return the cart item - - const UpdatedData = addFirst - ? [UpdatedCartItem, ...OtherOrderDatas, ...OtherOrderDatawithsales] - : [...OtherOrderDatas, ...OtherOrderDatawithsales, UpdatedCartItem]; - - // if (OfferCheckedInSetup) { - // await applyOffer(UpdatedData); - // } else { - dispatch(changeOrderCardDetails(UpdatedData)); - // } - } else { - setMessageType('error'); - setMessageData('Stock Not Available'); - formRef.current.resetFields(['ItemName']); - setSelectedProduct({}); - } - } else if (BookingType == 'PreOrder') { - if (PreOrderAdditem == 'AddItems') { - // GlobalPreOrderData - let Duplicate = GlobalPreOrderData?.some( - (e) => - e?.InwardDtlId == item.InwardDtlId && e?.SinglePc === item?.SinglePc - ); - if (Duplicate) { - setMessageData(' you have already Select The Product'); - setMessageType('warning'); - } else { - await dispatch( - changepreOrderList([ - ...(Array.isArray(GlobalPreOrderData) ? GlobalPreOrderData : []), - { - ...item, - OrderQty: 1, - TotalAmt: item?.OrderRate, - TaxAmt: ( - (item?.OrderRate * item?.TaxPercentage) / - (100 + item?.TaxPercentage) - ).toFixed(2), - WithoutTaxRate: ( - item?.OrderRate - - (item?.OrderRate * item?.TaxPercentage) / - (100 + item?.TaxPercentage) - ).toFixed(2), - }, - ]) - ); - } - } else { - setMessageData(' you have got to Choose Add item'); - setMessageType('warning'); - } - } else { - if (item?.OtherProduct === 'Others') { - const UpdatedData = addFirst - ? [ - { - ...item, - TotalAmt: item?.OrderQty * item?.OrderRate, - TaxAmt: ( - (item?.OrderQty * item?.OrderRate * item?.TaxPercentage) / - (100 + item?.TaxPercentage) - ).toFixed(2), - WithoutTaxRate: ( - item?.OrderQty * item?.OrderRate - - (item?.OrderQty * item?.OrderRate * item?.TaxPercentage) / - (100 + item?.TaxPercentage) - ).toFixed(2), - localId: uuidv4(), - }, - ...CartOrderDetails, - ] - : [ - ...CartOrderDetails, - { - ...item, - TotalAmt: item?.OrderQty * item?.OrderRate, - TaxAmt: ( - (item?.OrderQty * item?.OrderRate * item?.TaxPercentage) / - (100 + item?.TaxPercentage) - ).toFixed(2), - WithoutTaxRate: ( - item?.OrderQty * item?.OrderRate - - (item?.OrderQty * item?.OrderRate * item?.TaxPercentage) / - (100 + item?.TaxPercentage) - ).toFixed(2), - localId: uuidv4(), - }, - ]; - // if the item is not in the cart, add the item to the cart - // if (OfferCheckedInSetup && preferenceOffer) { - // const withoutComboOffer_CardDetail = UpdatedData?.filter( - // (item) => item.Type !== 'C' - // ); - // if ( - // OrderOfferStatus || - // (withoutComboOffer_CardDetail?.length > 0 && CustDetails) - // ) { - // await newapplyOffer(item, UpdatedData); - // } - // await applyOffer(UpdatedData); - // } else { - dispatch(changeOrderCardDetails(UpdatedData)); - // } - } else { - if ( - (item?.StockAvailable === 'Y' && - CalculateOverallQty(item, isItemInCartfilter) > 0) || - item?.StockAvailable === 'N' - ) { - const UpdatedData = addFirst - ? [ - { - ...item, - OrderQty: 1, - TotalAmt: item?.OrderRate, - TaxAmt: ( - (item?.OrderRate * item?.TaxPercentage) / - (100 + item?.TaxPercentage) - ).toFixed(2), - WithoutTaxRate: ( - item?.OrderRate - - (item?.OrderRate * item?.TaxPercentage) / - (100 + item?.TaxPercentage) - ).toFixed(2), - localId: uuidv4(), - }, - ...CartOrderDetails, - ] - : [ - ...CartOrderDetails, - { - ...item, - OrderQty: 1, - TotalAmt: item?.OrderRate, - TaxAmt: ( - (item?.OrderRate * item?.TaxPercentage) / - (100 + item?.TaxPercentage) - ).toFixed(2), - WithoutTaxRate: ( - item?.OrderRate - - (item?.OrderRate * item?.TaxPercentage) / - (100 + item?.TaxPercentage) - ).toFixed(2), - localId: uuidv4(), - }, - ]; // if the item is not in the cart, add the item to the cart - // if (OfferCheckedInSetup && preferenceOffer) { - // await applyOffer(UpdatedData); - // } else { - dispatch(changeOrderCardDetails(UpdatedData)); - // } - } else { - setMessageType('error'); - setMessageData('Stock Not Available'); - formRef.current.resetFields(['ItemName']); - setSelectedProduct({}); - } // if the item is not in the cart, add the item to the cart - } - } - dispatch(changeothersdata({})); - dispatch(ChangeNewQrProduct({})); - - formRef.current.resetFields(['ItemName']); - setSelectedProduct({}); - dispatch(ChangeWSProduct({})); - }; const AddOrderDetails = async (item) => { if (preOrder) { @@ -3291,7 +2808,6 @@ export default function BSC1Search(props) { } }; - const handlePreOrder = async (item) => { let Response = await dispatch( getConfigType({ TypeName: 'Booking Type' }) @@ -3375,28 +2891,15 @@ export default function BSC1Search(props) { const isExistsInFreeProdList = hasOffer ? FreeProdList?.filter( - (f) => - f?.FreeProdId === item?.ProdId && - f?.ProdVariantDetails?.some((variant) => - variant?.StockDetails?.some( - (stock) => stock?.FreeInwardDtlId === item?.InwardDtlId - ) - ) && - f?.RemainingQty > 0 - ) - : []; - - const freeProductAvailableForThisItem = hasOffer - ? OverAllproductBasedOfferDatas?.ProdDtl?.filter( - (o) => - o?.ProdId === item?.ProdId && - o?.ProdVariantDetails?.some((variant) => - variant?.StockDetails?.some( - (stock) => - stock?.InwardDtlId === item?.InwardDtlId && o?.MinQty > 0 - ) - ) - ) + (f) => + f?.FreeProdId === item?.ProdId && + f?.ProdVariantDetails?.some((variant) => + variant?.StockDetails?.some( + (stock) => stock?.FreeInwardDtlId === item?.InwardDtlId + ) + ) && + f?.RemainingQty > 0 + ) : []; const calculateTaxAmounts = (qty, rate, taxPercentage) => { @@ -3463,9 +2966,10 @@ export default function BSC1Search(props) { ((cartItem?.OfferModeType && cartItem?.OfferMode === 'B' ? true : cartItem?.OfferMode !== 'B') && - cartItem?.OfferMode !== 'P' && cartItem?.OfferMode !== 'C' && - cartItem?.OfferMode !== 'O' && - cartItem?.OfferMode !== 'L' + cartItem?.OfferMode !== 'P' && + cartItem?.OfferMode !== 'C' && + cartItem?.OfferMode !== 'O' && + cartItem?.OfferMode !== 'L' ? true : cartItem?.Offer === 0) ); @@ -3478,31 +2982,14 @@ export default function BSC1Search(props) { !cartItem?.SalesId ); - // const isItemInCartfilter = CartOrderDetails?.filter( - // (cartItem) => - // cartItem?.ProdId === item?.ProdId && - // cartItem?.InwardDtlId === item?.InwardDtlId && - // !( - // cartItem?.OrderRate === item?.OrderRate && - // cartItem?.BookingTypeName === item?.BookingTypeName - // ) && - // !cartItem?.SalesId && - // ((cartItem?.OfferModeType && cartItem?.OfferMode === 'B' - // ? true - // : cartItem?.OfferMode !== 'B') && - // cartItem?.OfferMode !== 'P' && - // cartItem?.OfferMode !== 'L' - // ? true - // : cartItem?.Offer === 0) - // ); - const isItemInCartHold = CartOrderDetails?.find( (cartItem) => itemMatchCondition(cartItem) && (cartItem?.OfferMode !== 'B' && - cartItem?.OfferMode !== 'P' && cartItem?.OfferMode !== 'C' && - cartItem?.OfferMode !== 'O' && - cartItem?.OfferMode !== 'L' + cartItem?.OfferMode !== 'P' && + cartItem?.OfferMode !== 'C' && + cartItem?.OfferMode !== 'O' && + cartItem?.OfferMode !== 'L' ? true : cartItem?.Offer === 0) ); @@ -3516,9 +3003,10 @@ export default function BSC1Search(props) { ((cartItem?.OfferModeType && cartItem?.OfferMode === 'B' ? true : cartItem?.OfferMode !== 'B') && - cartItem?.OfferMode !== 'P' && - cartItem?.OfferMode !== 'L' && cartItem?.OfferMode !== 'C' && - cartItem?.OfferMode !== 'O' + cartItem?.OfferMode !== 'P' && + cartItem?.OfferMode !== 'L' && + cartItem?.OfferMode !== 'C' && + cartItem?.OfferMode !== 'O' ? true : cartItem?.Offer === 0) ) @@ -3529,9 +3017,10 @@ export default function BSC1Search(props) { !( itemMatchCondition(cartItem) && (cartItem?.OfferMode !== 'B' && - cartItem?.OfferMode !== 'P' && - cartItem?.OfferMode !== 'L' && cartItem?.OfferMode !== 'C' && - cartItem?.OfferMode !== 'O' + cartItem?.OfferMode !== 'P' && + cartItem?.OfferMode !== 'L' && + cartItem?.OfferMode !== 'C' && + cartItem?.OfferMode !== 'O' ? true : cartItem?.Offer === 0) ) @@ -3542,38 +3031,35 @@ export default function BSC1Search(props) { if (isItemInCart && !isHoldOrder) { const itemInCart = CartOrderDetails?.find( - (cartItem) => - itemMatchCondition(cartItem) && - !cartItem.SalesId + (cartItem) => itemMatchCondition(cartItem) && !cartItem.SalesId ); let totalUsedQty = 0; - const sameBookingTypeItems = CartOrderDetails?.filter((cartItem) => - itemMatchCondition(cartItem) && - !cartItem.SalesId); + const sameBookingTypeItems = CartOrderDetails?.filter( + (cartItem) => itemMatchCondition(cartItem) && !cartItem.SalesId + ); - const differentBookingTypeItems = CartOrderDetails?.filter((cartItem) => - cartItem.ProdId === item.ProdId && - cartItem.InwardDtlId === item.InwardDtlId && - cartItem.OrderRate === item.OrderRate && - cartItem.BookingTypeName !== item.BookingTypeName && - cartItem.ScaleType === item.ScaleType && - !cartItem.SalesId); + const differentBookingTypeItems = CartOrderDetails?.filter( + (cartItem) => + cartItem.ProdId === item.ProdId && + cartItem.InwardDtlId === item.InwardDtlId && + cartItem.OrderRate === item.OrderRate && + cartItem.BookingTypeName !== item.BookingTypeName && + cartItem.ScaleType === item.ScaleType && + !cartItem.SalesId + ); if (sameBookingTypeItems?.length > 0) { const stockAvailable = sameBookingTypeItems?.some( (item) => item?.StockAvailable === 'Y' ); if (stockAvailable) { - totalUsedQty = sameBookingTypeItems?.reduce( - (acc, item) => { - if (item?.StockAvailable === 'Y') { - return acc + parseInt(item?.OrderQty); - } - return acc; - }, - 0 - ); + totalUsedQty = sameBookingTypeItems?.reduce((acc, item) => { + if (item?.StockAvailable === 'Y') { + return acc + parseInt(item?.OrderQty); + } + return acc; + }, 0); } } @@ -3582,22 +3068,20 @@ export default function BSC1Search(props) { (item) => item?.StockAvailable === 'Y' ); if (stockAvailable) { - totalUsedQty += differentBookingTypeItems?.reduce( - (acc, item) => { - if (item?.StockAvailable === 'Y') { - return acc + parseInt(item?.OrderQty); - } - return acc; - }, - 0 - ); + totalUsedQty += differentBookingTypeItems?.reduce((acc, item) => { + if (item?.StockAvailable === 'Y') { + return acc + parseInt(item?.OrderQty); + } + return acc; + }, 0); } } const overAllQty = calculateOverAllQty(itemInCart, isItemInCartfilter); - if (((overAllQty > totalUsedQty) && - isItemInCart?.StockAvailable === 'Y') || - isItemInCart?.StockAvailable !== 'Y') { + if ( + (overAllQty > totalUsedQty && isItemInCart?.StockAvailable === 'Y') || + isItemInCart?.StockAvailable !== 'Y' + ) { if ( isExistsInFreeProdList?.length > 0 && hasOffer && @@ -3609,15 +3093,22 @@ export default function BSC1Search(props) { isItemInCart, item?.OtherProduct === 'Others' || item?.ScaleType === 'weight' ? ( - (item?.OrderQty || 0) + parseFloat(isItemInCart?.OrderQty) - )?.toFixed(3) + (item?.OrderQty || 0) + parseFloat(isItemInCart?.OrderQty) + )?.toFixed(3) : null ); const updatedData = addFirst ? [updatedCartItem, ...otherOrderDataForNormal] : [...otherOrderDataForNormal, updatedCartItem]; - if (OverAllproductBasedOfferDatas?.ProdDtl?.length > 0 && hasOffer) { - handleFreeProductAvailable(updatedCartItem, updatedData, addFirst); + if ( + OverAllproductBasedOfferDatas?.ProdDtl?.length > 0 && + hasOffer + ) { + handleFreeProductAvailable( + updatedCartItem, + updatedData, + addFirst + ); } else { dispatch(changeOrderCardDetails(updatedData)); } @@ -3631,7 +3122,6 @@ export default function BSC1Search(props) { } // CASE 2: Item exists in cart (hold), is Hold order else if (isItemInCartHold && isHoldOrder) { - const holddataproduct = ReorderProductData?.filter( (cartItem) => cartItem?.ProdId === item?.ProdId && @@ -3662,9 +3152,8 @@ export default function BSC1Search(props) { 0 ); - const itemInCartHold = CartOrderDetails?.find( - (cartItem) => - itemMatchCondition(cartItem) + const itemInCartHold = CartOrderDetails?.find((cartItem) => + itemMatchCondition(cartItem) ); const itemInCartHoldFilter = CartOrderDetails?.filter( @@ -3674,33 +3163,35 @@ export default function BSC1Search(props) { cartItem?.OrderRate !== item?.OrderRate ); - const overAllQtyHold = calculateOverAllQty(itemInCartHold, itemInCartHoldFilter) + totalSelectedProductQty; + const overAllQtyHold = + calculateOverAllQty(itemInCartHold, itemInCartHoldFilter) + + totalSelectedProductQty; let totalUsedQty = 0; const sameBookingTypeItems = CartOrderDetails?.filter((cartItem) => - itemMatchCondition(cartItem)); + itemMatchCondition(cartItem) + ); - const differentBookingTypeItems = CartOrderDetails?.filter((cartItem) => - cartItem.ProdId === item.ProdId && - cartItem.InwardDtlId === item.InwardDtlId && - cartItem.OrderRate === item.OrderRate && - cartItem.BookingTypeName !== item.BookingTypeName); + const differentBookingTypeItems = CartOrderDetails?.filter( + (cartItem) => + cartItem.ProdId === item.ProdId && + cartItem.InwardDtlId === item.InwardDtlId && + cartItem.OrderRate === item.OrderRate && + cartItem.BookingTypeName !== item.BookingTypeName + ); if (sameBookingTypeItems?.length > 0) { const stockAvailable = sameBookingTypeItems?.some( (item) => item?.StockAvailable === 'Y' ); if (stockAvailable) { - totalUsedQty = sameBookingTypeItems?.reduce( - (acc, item) => { - if (item?.StockAvailable === 'Y') { - return acc + parseInt(item?.OrderQty); - } - return acc; - }, - 0 - ); + totalUsedQty = sameBookingTypeItems?.reduce((acc, item) => { + if (item?.StockAvailable === 'Y') { + return acc + parseInt(item?.OrderQty); + } + return acc; + }, 0); } } @@ -3709,15 +3200,12 @@ export default function BSC1Search(props) { (item) => item?.StockAvailable === 'Y' ); if (stockAvailable) { - totalUsedQty += differentBookingTypeItems?.reduce( - (acc, item) => { - if (item?.StockAvailable === 'Y') { - return acc + parseInt(item?.OrderQty); - } - return acc; - }, - 0 - ); + totalUsedQty += differentBookingTypeItems?.reduce((acc, item) => { + if (item?.StockAvailable === 'Y') { + return acc + parseInt(item?.OrderQty); + } + return acc; + }, 0); } } @@ -3733,15 +3221,23 @@ export default function BSC1Search(props) { isItemInCartHold, item?.OtherProduct === 'Others' || item?.ScaleType === 'weight' ? ( - (item?.OrderQty || 0) + parseFloat(isItemInCartHold?.OrderQty) - )?.toFixed(3) + (item?.OrderQty || 0) + + parseFloat(isItemInCartHold?.OrderQty) + )?.toFixed(3) : null ); const updatedData = addFirst ? [updatedCartItem, ...otherOrderDataForNormalWithoutSalesId] : [...otherOrderDataForNormalWithoutSalesId, updatedCartItem]; - if (OverAllproductBasedOfferDatas?.ProdDtl?.length > 0 && hasOffer) { - handleFreeProductAvailable(updatedCartItem, updatedData, addFirst); + if ( + OverAllproductBasedOfferDatas?.ProdDtl?.length > 0 && + hasOffer + ) { + handleFreeProductAvailable( + updatedCartItem, + updatedData, + addFirst + ); } else { dispatch(changeOrderCardDetails(updatedData)); } @@ -3763,9 +3259,11 @@ export default function BSC1Search(props) { dispatch(changeOrderCardDetails(updatedData)); } else { - if ((item?.StockAvailable === 'Y' && - calculateOverAllQty(item, isItemInCartfilter) > 0) || - item?.StockAvailable === 'N') { + if ( + (item?.StockAvailable === 'Y' && + calculateOverAllQty(item, isItemInCartfilter) > 0) || + item?.StockAvailable === 'N' + ) { if ( isExistsInFreeProdList?.length > 0 && hasOffer && @@ -3803,7 +3301,6 @@ export default function BSC1Search(props) { } }; - const handleFreeProduct = (item, filteredFreeProdList, addFirst) => { if (!filteredFreeProdList?.length) return; @@ -3978,14 +3475,14 @@ export default function BSC1Search(props) { updatedCartData = cartData.map((item, idx) => idx === indexToCheck ? { - ...item, - Offer: null, - OfferMessage: undefined, - OfferMode: undefined, - OfferModeType: false, - OfferType: undefined, - OfferValue: null, - } + ...item, + Offer: null, + OfferMessage: undefined, + OfferMode: undefined, + OfferModeType: false, + OfferType: undefined, + OfferValue: null, + } : item ); } @@ -4034,9 +3531,12 @@ export default function BSC1Search(props) { const UpdatedCartItemWithOffer = { ...item, - Offer: (sameProduct || bestOffer?.OfferMode === 'I' || bestOffer?.OfferMode === 'Q') - ? (bestOffer?.OfferAmount || item.Offer) - : (item.Offer || bestOffer?.OfferAmount), + Offer: + sameProduct || + bestOffer?.OfferMode === 'I' || + bestOffer?.OfferMode === 'Q' + ? bestOffer?.OfferAmount || item.Offer + : item.Offer || bestOffer?.OfferAmount, OfferType: item?.OfferType || bestOffer?.OfferType, OfferMessage: item?.OfferMessage || bestOffer?.OfferMessage, OfferMode: item?.OfferMode || bestOffer?.OfferMode, @@ -4051,9 +3551,10 @@ export default function BSC1Search(props) { ((c?.OfferModeType && c?.OfferMode === 'B' ? true : c?.OfferMode !== 'B') && - c?.OfferMode !== 'P' && c?.OfferMode !== 'C' && - c?.OfferMode !== 'O' && - c?.OfferMode !== 'L' + c?.OfferMode !== 'P' && + c?.OfferMode !== 'C' && + c?.OfferMode !== 'O' && + c?.OfferMode !== 'L' ? true : c?.Offer === 0); @@ -4361,10 +3862,10 @@ export default function BSC1Search(props) { return FreeProdList.map((f, i) => i === index ? { - ...existing, - ...newFreeProd, - ProdVariantDetails: existing.ProdVariantDetails, - } + ...existing, + ...newFreeProd, + ProdVariantDetails: existing.ProdVariantDetails, + } : f ); } else { @@ -4434,7 +3935,7 @@ export default function BSC1Search(props) { const cycleSize = buyQty + getQty; const fullCycles = Math.floor( freeCartItem?.reduce((acc, fc) => acc + (fc?.OrderQty || 0), 0) / - cycleSize + cycleSize ); const totalFreeQty = fullCycles * getQty; @@ -4452,18 +3953,14 @@ export default function BSC1Search(props) { c?.ProdId === offer?.ProdId && (offer?.InwardDtlId ? c?.InwardDtlId === offer?.InwardDtlId : true) ); - const buyOrderQty = buyCartItem?.reduce( (acc, fc) => acc + (fc?.OrderQty || 0), 0 ); - // ✅ total eligible free qty (cycles of Buy X Get Y) const eligibleCycles = Math.floor(buyOrderQty / buyQty); const totalFreeQty = eligibleCycles * getQty; - totalDiscount += 0; - // 🟢 Offer message handling if (buyOrderQty === 0) { offerMessage = `No free eligible right now`; @@ -4475,10 +3972,8 @@ export default function BSC1Search(props) { } else { offerMessage = `No free eligible right now`; } - const usedFree = data?.FreeQty || 0; const remainingFree = Math.max(totalFreeQty - usedFree, 0); - const FreeProdList = { OfferId: offer.OfferId, ProdId: item?.ProdId, @@ -4496,7 +3991,6 @@ export default function BSC1Search(props) { OverAllFreeQty: totalFreeQty, FreeQty: usedFree, RemainingQty: remainingFree, - ProdVariantDetails: freeProd.ProdVariantDetails.map((variant) => ({ FreeProdVariantName: variant.ProdVariantName, StockDetails: variant.StockDetails.map((stock) => { @@ -4506,18 +4000,16 @@ export default function BSC1Search(props) { c.ProdId === freeProd.FreeProdId && c.InwardDtlId === stock.InwardDtlId ); - const usedFreeForStock = matchedCartItem?.OrderQty || 0; const remainingFreeForStock = Math.max( totalFreeQty - usedFreeForStock, 0 ); - return { FreeInwardDtlId: stock.InwardDtlId, ProdOfferId: stock.ProdOfferId, ActiveStatus: stock.ActiveStatus, - EligibleFree: totalFreeQty, // still overall, can later split if needed + EligibleFree: totalFreeQty, UsedFree: usedFreeForStock, RemainingFree: remainingFreeForStock, }; @@ -4552,10 +4044,6 @@ export default function BSC1Search(props) { hasChanges: false, }; } - // Filter only free products with remaining quantity - const availableFreeProdList = freeProdList?.filter( - (prod) => prod?.RemainingQty > 0 - ); let updatedOrderCardDetails = []; let updatedFreeProdList = [...freeProdList]; // Create a copy to avoid mutations @@ -4955,36 +4443,7 @@ export default function BSC1Search(props) { } else { SingleQuantity(item, onePeiceFlow); } - setexpModel(false); - }; - - const expQtyFun = (index) => { - const selectedProIndex = qtydata?.ProductDetail?.findIndex( - (item) => - item?.ProdId === index?.ProdId && - item?.Size === index?.Size && - item?.UomName === index?.UomName && - item?.Brand === index?.Brand - ); - - if (selectedProIndex !== -1) { - const count = - qtydata?.ProductDetail[selectedProIndex]?.ProdVariantDetails?.length || - 0; - - if (count > 1) { - setModelQty(false); - setModalVarient(true); - } else { - const item = { QtyIndex: selectedProIndex, VarientIndex: 0 }; - singleVarient(item); - setModelQty(false); - } - } - - setQtyIndex(selectedProIndex); - setRepeatedModel(true); - setExpQtyModel(false); + closeExpireModal(); }; const expVerFun = (item) => { @@ -5000,12 +4459,12 @@ export default function BSC1Search(props) { dataTransfer(qtydata, QtyIndex, item, 0, onePeiceFlow); setModelQty(false); } - setexpVarModel(false); + closeExpireModal(); }; const expStockFun = (item) => { dataTransfer(qtydata, QtyIndex, VarientIndex, item, onePeiceFlow); - setexpStockModel(false); + closeExpireModal(); }; let brandMapping = {}; // Group product details by Brand ID @@ -5021,7 +4480,6 @@ export default function BSC1Search(props) { }); const getMaxBrandWidth = () => { let maxBrandDataLength = 0; - // Iterate through each brand and find the maximum length of the specified key Object.values(brandMapping).forEach((brand) => { const keyDataLength = brand.length; @@ -5029,7 +4487,6 @@ export default function BSC1Search(props) { maxBrandDataLength = keyDataLength; } }); - // Set your width logic here based on the maxBrandDataLength const maxWidth = maxBrandDataLength >= 5 ? 750 : 'max-content'; @@ -5081,15 +4538,15 @@ export default function BSC1Search(props) { {option.ProductDetail?.filter( (item) => item.OnePcsAvailable == 'Y' ).length !== 0 && ( - { - setOnePeiceFlow(true); - }} - /> - )} + { + setOnePeiceFlow(true); + }} + /> + )} ), @@ -5112,101 +4569,48 @@ export default function BSC1Search(props) { handleQrcode()} - // onClick={() => OnfocusTrue()} + // onClick={() => OnfocusTrue()} /> )} OnfocusTrue()} + // onClick={() => OnfocusTrue()} /> - {ProductSearch?.length > 5 && QuickAdd && ( -
- -
- )} + {ProductSearch?.length > 5 && + QuickAdd && + GetmultipleSearchDatas.some((e) => e.toLowerCase() === 'qrcode') && ( +
+ +
+ )} {BSComboData == 'Combo1' && FeatureAddonData?.FeatureDtls?.find( (item) => item?.FeatureAddonName?.toLowerCase() === 'weight scale' ) && } - - -

Product Expires

- - } - open={expModel} - onOk={() => expFun(Item)} - onCancel={() => setexpModel(false)} - okText="Submit" - cancelText="Don't Submit" - >
- - -

Quantity Expires

- - } - open={expQtyModel} - onOk={() => expQtyFun(qtyExpData)} - onCancel={() => { - (setRepeatedModel(false), setProdexpir(false), setExpQtyModel(false)); - }} - okText="Submit" - cancelText="Don't Submit" - maskTransitionName="" - transitionName="" - >
- - -

Variant Expires

- - } - open={expVarModel} - onOk={() => expVerFun(VarItem)} - onCancel={() => { - (setexpVarModel(false), setRepeatedModel(false), setProdexpir(false)); - }} - okText="Submit" - cancelText="Don't Submit" - >
- - -

Stock Expires

- - } - open={expStockModel} - onOk={() => expStockFun(StockItem)} - onCancel={() => { - (setexpStockModel(false), - setRepeatedModel(false), - setProdexpir(false)); - }} - okText="Submit" - cancelText="Don't Submit" - >
+ {expireModal?.open && ( + { + expireModal.onOk?.(); + closeExpireModal(); + }} + onCancel={() => { + expireModal.onCancel?.(); + closeExpireModal(); + }} + /> + )} + @@ -5216,9 +4620,120 @@ export default function BSC1Search(props) { open={modelQty} width={widthBasedOnProdVariantDetails} footer={null} - children={ -
-
+ handleCancel={CloseModal} + > +
+
+
+

Item Name:

+
+
+

{qtydata?.ProdName}

+
+
+
+ {Object.keys(brandMapping)?.map((brandId) => ( +
+
+

+ {' '} + {brandId !== 'null' && brandId !== 'undefined' + ? brandId + : ''} +

+
+ +
+ {brandMapping[brandId]?.map((item, index) => ( +
+
+ 0 || item?.StockAvailable !== 'Y' + ? 'ItemQtyCard' + : 'ItemQtyCard-disabled' + } + onClick={() => VarientFun(item)} + > +
+ {`Product +
+ +
+

+ {item?.Size + ' ' + item?.UomName} +

+ {returnQtyCount( + item?.ProdId, + item, + CartOrderDetails + ) > 0 || item?.StockAvailable !== 'Y' ? ( +

+ +   + { + item?.ProdVariantDetails?.[0]?.StockDetails?.[0] + ?.SellPrice + } +

+ ) : ( + '' + )} +
+
+
+ ))} +
+ {brandId !== 'null' && brandId !== 'undefined' ?
: ''} +
+ ))} + + {Object.keys(brandMapping).length === 0 && ( +

No product details available

+ )} +
+
+ + + +
+ } + open={modelstock} + // width={500} + footer={null} + handleCancel={CloseModal1} + > +
+
+

Item Name:

@@ -5229,150 +4744,28 @@ export default function BSC1Search(props) {

{qtydata?.ProdName}

-
- {Object.keys(brandMapping)?.map((brandId) => ( -
-
-

- {' '} - {brandId !== 'null' && brandId !== 'undefined' - ? brandId - : ''} -

-
- -
- {brandMapping[brandId]?.map((item, index) => ( -
-
0 || item?.StockAvailable !== 'Y' - ? 'ItemQtyCard' - : 'ItemQtyCard-disabled' - } - onClick={() => VarientFun(item)} - > -
- {`Product -
- -
-

- {item?.Size + ' ' + item?.UomName} -

- {returnQtyCount( - item?.ProdId, - item, - CartOrderDetails - ) > 0 || item?.StockAvailable !== 'Y' ? ( -

- -   - { - item?.ProdVariantDetails?.[0] - ?.StockDetails?.[0]?.SellPrice - } -

- ) : ( - '' - )} -
-
-
- ))} -
- {brandId !== 'null' && brandId !== 'undefined' ? ( -
- ) : ( - '' - )} -
- ))} - - {Object.keys(brandMapping).length === 0 && ( -

No product details available

- )} -
-
- } - handleCancel={CloseModal} - /> - - -
- } - open={modelstock} - // width={500} - footer={null} - children={ -
-
-
-
-

Item Name:

-
-
-

- {qtydata?.ProdName} -

-
+
+
+

Item Quantity:

-
-
-

Item Quantity:

-
-
-

- {qtydata?.ProductDetail?.[QtyIndex]?.Size}{' '} - {onePeiceFlow - ? 'PCS' - : qtydata?.ProductDetail?.[QtyIndex]?.UomName} -

-
+
+

+ {qtydata?.ProductDetail?.[QtyIndex]?.Size}{' '} + {onePeiceFlow + ? 'PCS' + : qtydata?.ProductDetail?.[QtyIndex]?.UomName} +

-
- -
- } - handleCancel={CloseModal1} - /> +
+ +
+
+ @@ -5382,54 +4775,51 @@ export default function BSC1Search(props) { open={ModalVarient} width={500} footer={null} - children={ -
-
-
-
-

Item Name:

-
-
-

- {qtydata?.ProdName} -

-
+ handleCancel={CloseVarientModal} + > +
+
+
+
+

Item Name:

-
-
-

Item Quantity:

-
-
-

- {qtydata?.ProductDetail?.[QtyIndex]?.Size}{' '} - {onePeiceFlow - ? 'PCS' - : qtydata?.ProductDetail?.[QtyIndex]?.UomName} -

-
+
+

{qtydata?.ProdName}

-
- +
+
+

Item Quantity:

+
+
+

+ {qtydata?.ProductDetail?.[QtyIndex]?.Size}{' '} + {onePeiceFlow + ? 'PCS' + : qtydata?.ProductDetail?.[QtyIndex]?.UomName} +

+
- } - handleCancel={CloseVarientModal} - /> +
+ +
+
+ {isMobile && screenWidth <= 768 && ( { const AllCategoryDatas = useSelector(GlobalCategorieData, shallowEqual); const AllsubcatgoryDatas = useSelector(GlobalSubcategorieData, shallowEqual); const RetailWSSalesType = useSelector(GlobalRetailWSSalesType, shallowEqual); - // const CustDetails = SelectedCust ? SelectedCust : AddCustomerDetails?.[0]; - const BookingTypeBoth = useSelector(GlobalBookingTypeBoth); + const GPreOrderList = useSelector(GlobalPreOrderList, shallowEqual); const [modelQty, setModelQty] = useState(false); const [modelstock, setModelstock] = useState(false); const [ModalVarient, setModalVarient] = useState(false); const [QtyIndex, setQtyIndex] = useState(0); const [VarientIndex, setVarientIndex] = useState(0); - const [expModel, setexpModel] = useState(false); const [prodexpir, setProdexpir] = useState(false); - const [expVarModel, setexpVarModel] = useState(false); - const [expStockModel, setexpStockModel] = useState(false); const [initialRun, setInitialRun] = useState(false); const [Item, setItem] = useState(); const [VarItem, setVarItem] = useState(0); @@ -281,12 +273,11 @@ const BSItemCard = (props) => { const [QuickAdd, setQuickAdd] = useState(true); const [onePeiceFlow, setOnePeiceFlow] = useState(false); const [BillOrderPre, setBillOrderPre] = useState(); - const [expQtyModel, setExpQtyModel] = useState(false); const [qtyExpData, setQtyExpData] = useState(); const OrderOfferDetail = useSelector(Global_OrderOfferDetail); - const [freeProductsOffers, setfreeProductsOffers] = useState([]); + // const [freeProductsOffers, setfreeProductsOffers] = useState([]); const [screenWidth, setScreenWidth] = useState(window.innerWidth); - const [screenHeight, setScreenHeight] = useState(window.innerHeight); + // const [screenHeight, setScreenHeight] = useState(window.innerHeight); const ProdCat = useSelector(GlobalProductCategorie, shallowEqual); const paymentloader = useSelector(GlobalPayementloader, shallowEqual); const SessionData = useSelector(StoredSessionData, shallowEqual); @@ -314,6 +305,12 @@ const BSItemCard = (props) => { const triggerOfferFree = useSelector(GlobalTriggerOfferFree); const productCardTrigger = useSelector(GlobalProductCardTrigger); const appPreferences = useSelector(ApplicationPreferences); + const [expireModal, setExpireModal] = useState({ + open: false, + title: '', + onOk: null, + onCancel: null, + }); const salespagefields = appPreferences?.find( (pref) => pref?.PreferredCatName === 'Sales Page Fields' )?.PreferenceCatDetails; @@ -322,7 +319,7 @@ const BSItemCard = (props) => { type?.PreferredSubCatName?.toLowerCase() === 'available date' && type?.PreferredStatus === 'Y' ); - console.log(AvailableDate, salespagefields, 'Available Date'); + const SingleMember = salespagefields?.find( (type) => type?.PreferredSubCatName?.toLowerCase() === 'single member' && @@ -613,7 +610,7 @@ const BSItemCard = (props) => { WithoutTaxRate: availableFreeQty * item.OrderRate - (availableFreeQty * item.OrderRate * item.TaxPercentage) / - 100, + 100, Offer: availableFreeQty * item.OrderRate, }; @@ -662,7 +659,7 @@ const BSItemCard = (props) => { ((existingPaidItem.OrderQty + excessQty) * item.OrderRate * item.TaxPercentage) / - 100, + 100, }; ModifiedData.push(mergedPaidItem); @@ -697,7 +694,7 @@ const BSItemCard = (props) => { data?.InwardDtlId === item?.InwardDtlId && data?.ProdId === item?.ProdId && data?.OfferMessage?.[0]?.OfferId === - item?.OfferMessage?.[0]?.OfferId + item?.OfferMessage?.[0]?.OfferId ); if (isAlreadyExists !== -1) { @@ -717,11 +714,11 @@ const BSItemCard = (props) => { ).toFixed(2), WithoutTaxRate: (ModifiedData[isAlreadyExists].OrderQty + item.OrderQty) * - item.OrderRate - + item.OrderRate - ((ModifiedData[isAlreadyExists].OrderQty + item.OrderQty) * item.OrderRate * item.TaxPercentage) / - 100, + 100, Offer: (ModifiedData[isAlreadyExists].OrderQty + item.OrderQty) * item.OrderRate, @@ -747,10 +744,10 @@ const BSItemCard = (props) => { const appliedOfferAlreadyExists = AppliedOffers.findIndex( (offer) => offer?.FreeProductsList?.FreeProdId === - matchingFreeProduct?.FreeProdId && + matchingFreeProduct?.FreeProdId && offer?.TableName === matchingFreeProduct?.TableName && offer?.TableUniqueName === - matchingFreeProduct?.TableUniqueName && + matchingFreeProduct?.TableUniqueName && offer?.OfferId === matchingFreeProduct?.OfferId && offer?.OfferMode === matchingFreeProduct?.OfferMode && offer?.FreeProductsList?.ProdVariantDetails?.[0] @@ -930,6 +927,19 @@ const BSItemCard = (props) => { }; } + const openExpireModal = ({ title, onOk, onCancel }) => { + setExpireModal({ + open: true, + title, + onOk, + onCancel, + }); + }; + + const closeExpireModal = () => { + setExpireModal((prev) => ({ ...prev, open: false })); + }; + // Usage example: // const result = handleLoyaltyFreeProducts(orderCardDtls, freeProdDtls); // console.log(result.ModifiedData); @@ -937,13 +947,9 @@ const BSItemCard = (props) => { // console.log(result.AppliedOffers); async function getOffers() { - let response = await dispatch( + await dispatch( getOfferinBooking({ AppId: AppId, CompId: CompId, BranchId: BranchId }) ).unwrap(); - - if (response?.data?.statusCode == 1) { - let expiredProd = response?.data?.data; - } } useEffect(() => { @@ -964,7 +970,7 @@ const BSItemCard = (props) => { if (TableName === 'BuyXGetXOffers') return true; } ); - setfreeProductsOffers(filteredOffers); + // setfreeProductsOffers(filteredOffers); getOffers(); }, [OrderOfferDetail]); @@ -978,12 +984,7 @@ const BSItemCard = (props) => { }); } }, [SelectedCardFont]); - // const cardData = !globalAccessForOthers - // ? CardAccess - // ? SelectedDatas - // : ItemCard?.length == 0 ? noSubcatCardData : ItemCard - // : ""; - //mohan 18-04-2025 + const cardData = !globalAccessForOthers ? CardAccess ? SelectedDatas?.length > 1 @@ -992,7 +993,7 @@ const BSItemCard = (props) => { ? [] : SelectedDatas : ItemCard?.length == 0 || - (ItemCard?.[0]?.AppId === 0 && ItemCard?.[0]?.CompId === 0) + (ItemCard?.[0]?.AppId === 0 && ItemCard?.[0]?.CompId === 0) ? noSubcatCardData : ItemCard : ''; @@ -1076,14 +1077,14 @@ const BSItemCard = (props) => { ProdSubCat: ProdSubCat, ...(AvailableDate && selectedDate ? { - date: Array.isArray(selectedDate) - ? selectedDate - .map((d) => (d?.format ? d.format('YYYY-MM-DD') : d)) - .join(',') - : selectedDate?.format - ? selectedDate.format('YYYY-MM-DD') - : selectedDate, - } + date: Array.isArray(selectedDate) + ? selectedDate + .map((d) => (d?.format ? d.format('YYYY-MM-DD') : d)) + .join(',') + : selectedDate?.format + ? selectedDate.format('YYYY-MM-DD') + : selectedDate, + } : {}), }; //mohan @@ -1130,14 +1131,14 @@ const BSItemCard = (props) => { prodCat: ProdCat, ...(AvailableDate && selectedDate ? { - date: Array.isArray(selectedDate) - ? selectedDate - .map((d) => (d?.format ? d.format('YYYY-MM-DD') : d)) - .join(',') - : selectedDate?.format - ? selectedDate.format('YYYY-MM-DD') - : selectedDate, - } + date: Array.isArray(selectedDate) + ? selectedDate + .map((d) => (d?.format ? d.format('YYYY-MM-DD') : d)) + .join(',') + : selectedDate?.format + ? selectedDate.format('YYYY-MM-DD') + : selectedDate, + } : {}), }; @@ -1155,13 +1156,6 @@ const BSItemCard = (props) => { if (tempconfigdata?.data?.statusCode == 1) { setConfigDataList(tempconfigdata?.data?.data); - let configdata = tempconfigdata?.data?.data; - let checkName = BookingTypeBoth ? 'DineIn,TakeAway' : BookingType; - - let filterconfigdata = configdata?.find( - (a) => a?.ConfigName === checkName - ); - // setSelectedBookingType(filterconfigdata?.ConfigId); } }; @@ -1195,7 +1189,10 @@ const BSItemCard = (props) => { useEffect(() => { if (ItemCard?.[0]?.QrBasedSearch === 'Y') { if (ItemCard?.[0]?.OverAllExpStatus == 'Y' && ExpiredProduct) { - setexpModel(true); + openExpireModal({ + title: 'Product Expires', + onOk: () => expFun(Item), + }); setItem(ItemCard?.[0]); } else { setQtydata(ItemCard?.[0]); @@ -1203,7 +1200,10 @@ const BSItemCard = (props) => { } } else if (ItemCard?.[0]?.OnePcQRBased === 'Y') { if (ItemCard?.[0]?.OverAllExpStatus == 'Y' && ExpiredProduct) { - setexpModel(true); + openExpireModal({ + title: 'Product Expires', + onOk: () => expFun(Item), + }); setItem(ItemCard?.[0]); setOnePeiceFlow(true); } else { @@ -1295,14 +1295,6 @@ const BSItemCard = (props) => { )?.SettingValue === 'Y'; setExpiredProduct(expiredDate); }; - const to12Hour = (timeStr) => { - if (!timeStr) return ''; - let [h, m] = timeStr.split(':'); - h = parseInt(h, 10); - const suffix = h >= 12 ? 'PM' : 'AM'; - h = h % 12 || 12; // 0 → 12 - return `${h}${suffix}`; - }; const CloseModal = () => { setModelQty(false); @@ -1351,13 +1343,13 @@ const BSItemCard = (props) => { (cartItem) => cartItem?.ProdId === item?.ProductDetail?.[QtyIndex]?.ProdId && cartItem?.InwardDtlId === - item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ - VarientIndex - ]?.StockDetails?.[0]?.InwardDtlId && + item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ + VarientIndex + ]?.StockDetails?.[0]?.InwardDtlId && cartItem?.OrderRate === - item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ - VarientIndex - ]?.StockDetails?.[0]?.SellPrice && + item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ + VarientIndex + ]?.StockDetails?.[0]?.SellPrice && !cartItem?.SalesId ); @@ -1366,9 +1358,9 @@ const BSItemCard = (props) => { (cartItem) => cartItem?.ProdId === item?.ProductDetail?.[QtyIndex]?.ProdId && cartItem?.InwardDtlId === - item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ - VarientIndex - ]?.StockDetails?.[0]?.InwardDtlId && + item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ + VarientIndex + ]?.StockDetails?.[0]?.InwardDtlId && // (cartItem?.OrderRate === item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]?.StockDetails?.[0]?.SellPrice) !cartItem?.SalesId ); @@ -1410,11 +1402,11 @@ const BSItemCard = (props) => { (cartItem) => cartItem?.ProdId === item?.ProductDetail?.[QtyIndex]?.ProdId && cartItem?.InwardDtlId === - item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] - ?.StockDetails?.[0]?.InwardDtlId && + item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] + ?.StockDetails?.[0]?.InwardDtlId && cartItem?.OrderRate === - item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] - ?.StockDetails?.[0]?.SellPrice && + item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] + ?.StockDetails?.[0]?.SellPrice && !cartItem?.SalesId ); @@ -1423,9 +1415,9 @@ const BSItemCard = (props) => { (cartItem) => cartItem?.ProdId === item?.ProductDetail?.[QtyIndex]?.ProdId && cartItem?.InwardDtlId === - item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ - VarientIndex - ]?.StockDetails?.[0]?.InwardDtlId && + item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ + VarientIndex + ]?.StockDetails?.[0]?.InwardDtlId && // (cartItem?.OrderRate === item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]?.StockDetails?.[0]?.SellPrice) !cartItem?.SalesId ); @@ -1464,55 +1456,6 @@ const BSItemCard = (props) => { } }; - // const Stockfun = (index) => { - // setVarientIndex(index.key) - // let count = qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[index.key]?.StockDetails?.length; - // if (StockPreferenceDetail?.SettingValue === "Y") { - // if (count > 1) { - // if (qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[index.key]?.OverAllExpStatus == 'N') { - // setModalVarient(false) - // setModelstock(true) - // setVarItem(index.key) - // } - // else if (qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[index.key]?.OverAllExpStatus == 'Y') { - // if (prodexpir) { - // setRepeatedModel(true) - // setModalVarient(false) - // setModelstock(true) - // setVarItem(index.key) - // } - // else { - // setexpVarModel(true); - // setVarItem(index.key) - // } - // } - // // setVarientIndex(index.key) - // } - // else { - // if (qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[index.key]?.OverAllExpStatus == 'N') { - // dataTransfer(qtydata, QtyIndex, index.key, 0); - // setModelQty(false) - // setVarItem(index.key) - // } - // else if (qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[index.key]?.OverAllExpStatus == 'Y') { - // if (prodexpir) { - // setProdexpir(false) - // setRepeatedModel(true) - // dataTransfer(qtydata, QtyIndex, index.key, 0); - // setModelQty(false) - // setVarItem(index.key) - // } - // else{ - // setexpVarModel(true); - // setVarItem(index.key) - // } - // } - // } - // } else { - // dataTransfer(qtydata, QtyIndex, index.key, 0); - // setModelQty(false) - // } - // } const Stockfun = (index) => { setVarientIndex(index.key); const variantDetails = @@ -1537,7 +1480,14 @@ const BSItemCard = (props) => { } } else if (overallExpStatus === 'Y' && ExpiredProduct) { setVarItem(index.key); - setexpVarModel(true); + openExpireModal({ + title: 'Variant Expires', + onOk: () => expVerFun(VarItem), + onCancel: () => { + setRepeatedModel(false); + setProdexpir(false); + }, + }); } } else { if ( @@ -1548,13 +1498,13 @@ const BSItemCard = (props) => { (cartItem) => cartItem?.ProdId === qtydata?.ProductDetail?.[QtyIndex]?.ProdId && cartItem?.InwardDtlId === - qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ - index.key - ]?.StockDetails?.[0]?.InwardDtlId && + qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ + index.key + ]?.StockDetails?.[0]?.InwardDtlId && cartItem?.OrderRate === - qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ - index.key - ]?.StockDetails?.[0]?.SellPrice && + qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ + index.key + ]?.StockDetails?.[0]?.SellPrice && !cartItem?.SalesId ); @@ -1562,11 +1512,11 @@ const BSItemCard = (props) => { let Isincartonepc = CartOrderDetails?.filter( (cartItem) => cartItem?.ProdId === - qtydata?.ProductDetail?.[QtyIndex]?.ProdId && + qtydata?.ProductDetail?.[QtyIndex]?.ProdId && cartItem?.InwardDtlId === - qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ - index.key - ]?.StockDetails?.[0]?.InwardDtlId && + qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ + index.key + ]?.StockDetails?.[0]?.InwardDtlId && // (cartItem?.OrderRate === item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]?.StockDetails?.[0]?.SellPrice) !cartItem?.SalesId ); @@ -1613,7 +1563,14 @@ const BSItemCard = (props) => { } } else if (overallExpStatus === 'Y' && ExpiredProduct) { setVarItem(index.key); - setexpVarModel(true); + openExpireModal({ + title: 'Variant Expires', + onOk: () => expVerFun(VarItem), + onCancel: () => { + setRepeatedModel(false); + setProdexpir(false); + }, + }); return; } } @@ -1627,13 +1584,13 @@ const BSItemCard = (props) => { (cartItem) => cartItem?.ProdId === qtydata?.ProductDetail?.[QtyIndex]?.ProdId && cartItem?.InwardDtlId === - qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ - index.key - ]?.StockDetails?.[0]?.InwardDtlId && + qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ + index.key + ]?.StockDetails?.[0]?.InwardDtlId && cartItem?.OrderRate === - qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ - index.key - ]?.StockDetails?.[0]?.SellPrice && + qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ + index.key + ]?.StockDetails?.[0]?.SellPrice && !cartItem?.SalesId ); @@ -1642,9 +1599,9 @@ const BSItemCard = (props) => { (cartItem) => cartItem?.ProdId === qtydata?.ProductDetail?.[QtyIndex]?.ProdId && cartItem?.InwardDtlId === - qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ - index.key - ]?.StockDetails?.[0]?.InwardDtlId && + qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ + index.key + ]?.StockDetails?.[0]?.InwardDtlId && // (cartItem?.OrderRate === item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]?.StockDetails?.[0]?.SellPrice) !cartItem?.SalesId ); @@ -1670,16 +1627,6 @@ const BSItemCard = (props) => { dataTransfer(qtydata, QtyIndex, index.key, 0, onePeiceFlow); } } else { - // if (Isincart && Isincart?.StockAvailable === 'Y') { - // if (Isincart?.BalanceQty > Isincart?.OrderQty) { - // dataTransfer(qtydata, QtyIndex, index.key, 0, onePeiceFlow); - // } else { - // dataTransfer(qtydata, QtyIndex, index.key, 1, onePeiceFlow); - // } - // } else { - // dataTransfer(qtydata, QtyIndex, index.key, 0, onePeiceFlow); - // } - const findNextAvailableStockIndex = ( stockDetails, CartOrderDetails, @@ -1745,7 +1692,14 @@ const BSItemCard = (props) => { } } else if (overallExpStatus === 'Y' && ExpiredProduct) { setVarItem(index.key); - setexpVarModel(true); + openExpireModal({ + title: 'Variant Expires', + onOk: () => expVerFun(VarItem), + onCancel: () => { + setRepeatedModel(false); + setProdexpir(false); + }, + }); return; } setModelQty(false); @@ -1757,7 +1711,14 @@ const BSItemCard = (props) => { (item) => item.OverAllExpStatus === 'Y' ); if (QtyExpire && ExpiredProduct) { - setExpQtyModel(true); + openExpireModal({ + title: 'Quantity Expires', + onOk: () => expQtyFun(qtyExpData), + onCancel: () => { + setRepeatedModel(false); + (setProdexpir(false),closeExpireModal()); + }, + }); setQtyExpData(index); } else { const selectedProIndex = qtydata?.ProductDetail?.findIndex( @@ -1808,15 +1769,15 @@ const BSItemCard = (props) => { let Isincart = CartOrderDetails?.find( (cartItem) => cartItem?.ProdId === - qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdId && + qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdId && cartItem?.InwardDtlId === - qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ - item?.VarientIndex - ]?.StockDetails?.[0]?.InwardDtlId && + qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ + item?.VarientIndex + ]?.StockDetails?.[0]?.InwardDtlId && cartItem?.OrderRate === - qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ - item?.VarientIndex - ]?.StockDetails?.[0]?.SellPrice && + qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ + item?.VarientIndex + ]?.StockDetails?.[0]?.SellPrice && !cartItem?.SalesId ); @@ -1824,11 +1785,11 @@ const BSItemCard = (props) => { let Isincartonepc = CartOrderDetails?.filter( (cartItem) => cartItem?.ProdId === - qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdId && + qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdId && cartItem?.InwardDtlId === - qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ - item?.VarientIndex - ]?.StockDetails?.[0]?.InwardDtlId && + qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ + item?.VarientIndex + ]?.StockDetails?.[0]?.InwardDtlId && // (cartItem?.OrderRate === item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]?.StockDetails?.[0]?.SellPrice) !cartItem?.SalesId ); @@ -1907,15 +1868,15 @@ const BSItemCard = (props) => { let Isincart = CartOrderDetails?.find( (cartItem) => cartItem?.ProdId === - qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdId && + qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdId && cartItem?.InwardDtlId === - qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ - item?.VarientIndex - ]?.StockDetails?.[0]?.InwardDtlId && + qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ + item?.VarientIndex + ]?.StockDetails?.[0]?.InwardDtlId && cartItem?.OrderRate === - qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ - item?.VarientIndex - ]?.StockDetails?.[0]?.SellPrice && + qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ + item?.VarientIndex + ]?.StockDetails?.[0]?.SellPrice && !cartItem?.SalesId ); @@ -1923,11 +1884,11 @@ const BSItemCard = (props) => { let Isincartonepc = CartOrderDetails?.filter( (cartItem) => cartItem?.ProdId === - qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdId && + qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdId && cartItem?.InwardDtlId === - qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ - item?.VarientIndex - ]?.StockDetails?.[0]?.InwardDtlId && + qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ + item?.VarientIndex + ]?.StockDetails?.[0]?.InwardDtlId && // (cartItem?.OrderRate === item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]?.StockDetails?.[0]?.SellPrice) !cartItem?.SalesId ); @@ -2023,7 +1984,14 @@ const BSItemCard = (props) => { } else if (overallExpStatus === 'Y' && repeatedModel) { dataTransfer(qtydata, QtyIndex, VarientIndex, item.key, onePeiceFlow); } else { - setexpStockModel(true); + openExpireModal({ + title: 'Stock Expires', + onOk: () => expStockFun(StockItem), + onCancel: () => { + setRepeatedModel(false); + setProdexpir(false); + }, + }); setStockItem(item.key); } } @@ -2032,178 +2000,9 @@ const BSItemCard = (props) => { setRepeatedModel(false); }; - const pressTimer = useRef(null); - const isLongPress = useRef(false); const [priceChangeProduct, setPriceChangeProduct] = useState([]); const [productPriceChange, setProductPriceChange] = useState(false); - const handleMouseDownItemCard = (e, item) => { - isLongPress.current = false; - - pressTimer.current = setTimeout(() => { - if ( - !( - (item?.OverAllQty !== undefined && !preferenceSingleSales - ? returnCount( - item?.ProductDetail?.[0]?.ProdName, - item?.OverAllQty, - CartOrderDetails - ) - : returnOnepcCount( - item?.ProductDetail?.[0]?.ProdName, - item?.OverAllPcs, - CartOrderDetails - )) > 0 || - item?.ProductDetail?.some((item) => item?.StockAvailable !== 'Y') - ) - ) { - e.stopPropagation(); - } else { - isLongPress.current = true; - handleLongPress(item); - } - }, 1000); // Adjust duration as needed - }; - - const handleMouseUpItemCard = (e, item, check) => { - clearTimeout(pressTimer.current); - - if (!isLongPress.current) { - // Your existing onClick logic - if ( - !( - (item?.OverAllQty !== undefined && !preferenceSingleSales - ? returnCount( - item?.ProductDetail?.[0]?.ProdName, - item?.OverAllQty, - CartOrderDetails - ) - : returnOnepcCount( - item?.ProductDetail?.[0]?.ProdName, - item?.OverAllPcs, - CartOrderDetails - )) > 0 || - item?.ProductDetail?.some((item) => item?.StockAvailable !== 'Y') - ) - ) { - e.stopPropagation(); - } else { - if (check && !e.target.closest('.card4Main-onepiece')) { - CardOnclick( - item, - item?.OnePcsAvailable === 'Y' && - preferenceSingleSales && - 'OnePeiceProduct' - ); - } else if (!check) { - CardOnclick( - item, - item?.OnePcsAvailable === 'Y' && - preferenceSingleSales && - 'OnePeiceProduct' - ); - } - } - } - - isLongPress.current = false; - }; - - const handleMouseLeave = () => { - clearTimeout(pressTimer.current); - isLongPress.current = false; - }; - - // Mobile - Touch Start - const handleTouchStartItemCard = (e, item) => { - e.preventDefault(); - isLongPress.current = false; - - pressTimer.current = setTimeout(() => { - if ( - !( - (item?.OverAllQty !== undefined && !preferenceSingleSales - ? returnCount( - item?.ProductDetail?.[0]?.ProdName, - item?.OverAllQty, - CartOrderDetails - ) - : returnOnepcCount( - item?.ProductDetail?.[0]?.ProdName, - item?.OverAllPcs, - CartOrderDetails - )) > 0 || - item?.ProductDetail?.some((item) => item?.StockAvailable !== 'Y') - ) - ) { - e.stopPropagation(); - } else { - isLongPress.current = true; - handleLongPress(item); - } - }, 1000); - }; - - // Mobile - Touch End - const handleTouchEndItemCard = (e, item, check = false) => { - e.preventDefault(); - clearTimeout(pressTimer.current); - - if (!isLongPress.current) { - // Same logic as mouse up - if ( - !( - (item?.OverAllQty !== undefined && !preferenceSingleSales - ? returnCount( - item?.ProductDetail?.[0]?.ProdName, - item?.OverAllQty, - CartOrderDetails - ) - : returnOnepcCount( - item?.ProductDetail?.[0]?.ProdName, - item?.OverAllPcs, - CartOrderDetails - )) > 0 || - item?.ProductDetail?.some((item) => item?.StockAvailable !== 'Y') - ) - ) { - e.stopPropagation(); - } else { - if (check && !e.target.closest('.card4Main-onepiece')) { - CardOnclick( - item, - item?.OnePcsAvailable === 'Y' && - preferenceSingleSales && - 'OnePeiceProduct' - ); - } else if (!check) { - CardOnclick( - item, - item?.OnePcsAvailable === 'Y' && - preferenceSingleSales && - 'OnePeiceProduct' - ); - } - } - } - - isLongPress.current = false; - }; - - // Mobile - Touch Cancel (when interrupted) - const handleTouchCancelItemCard = () => { - clearTimeout(pressTimer.current); - isLongPress.current = false; - }; - - const handleLongPress = (item) => { - console.log('Long press triggered for:', item); - setPriceChangeProduct([item]); - setProductPriceChange(true); - // Add your long press logic here - // For example: open a context menu, show options, etc. - }; - const CardOnclick = async (item, Parameter) => { setOnePeiceFlow(Parameter === 'OnePeiceProduct'); @@ -2223,7 +2022,10 @@ const BSItemCard = (props) => { Parameter === 'OnePeiceProduct' ? transformedItem : item; setQtydata(modiffiedData); if (modiffiedData.OverAllExpStatus === 'Y' && ExpiredProduct) { - setexpModel(true); + openExpireModal({ + title: 'Product Expires', + onOk: () => expFun(Item), + }); setItem(modiffiedData); } else if (modiffiedData) { setQtydata(modiffiedData); @@ -2334,28 +2136,15 @@ const BSItemCard = (props) => { const isExistsInFreeProdList = hasOffer ? FreeProdList?.filter( - (f) => - f?.FreeProdId === item?.ProdId && - f?.ProdVariantDetails?.some((variant) => - variant?.StockDetails?.some( - (stock) => stock?.FreeInwardDtlId === item?.InwardDtlId - ) - ) && - f?.RemainingQty > 0 - ) - : []; - - const freeProductAvailableForThisItem = hasOffer - ? OverAllproductBasedOfferDatas?.ProdDtl?.filter( - (o) => - o?.ProdId === item?.ProdId && - o?.ProdVariantDetails?.some((variant) => - variant?.StockDetails?.some( - (stock) => - stock?.InwardDtlId === item?.InwardDtlId && o?.MinQty > 0 - ) - ) - ) + (f) => + f?.FreeProdId === item?.ProdId && + f?.ProdVariantDetails?.some((variant) => + variant?.StockDetails?.some( + (stock) => stock?.FreeInwardDtlId === item?.InwardDtlId + ) + ) && + f?.RemainingQty > 0 + ) : []; const calculateTaxAmounts = (qty, rate, taxPercentage) => { @@ -2422,9 +2211,10 @@ const BSItemCard = (props) => { ((cartItem?.OfferModeType && cartItem?.OfferMode === 'B' ? true : cartItem?.OfferMode !== 'B') && - cartItem?.OfferMode !== 'P' && cartItem?.OfferMode !== 'C' && - cartItem?.OfferMode !== 'O' && - cartItem?.OfferMode !== 'L' + cartItem?.OfferMode !== 'P' && + cartItem?.OfferMode !== 'C' && + cartItem?.OfferMode !== 'O' && + cartItem?.OfferMode !== 'L' ? true : cartItem?.Offer === 0) ); @@ -2435,9 +2225,10 @@ const BSItemCard = (props) => { ((cartItem?.OfferModeType && cartItem?.OfferMode === 'B' ? true : cartItem?.OfferMode !== 'B') && - cartItem?.OfferMode !== 'P' && cartItem?.OfferMode !== 'C' && - cartItem?.OfferMode !== 'O' && - cartItem?.OfferMode !== 'L' + cartItem?.OfferMode !== 'P' && + cartItem?.OfferMode !== 'C' && + cartItem?.OfferMode !== 'O' && + cartItem?.OfferMode !== 'L' ? true : cartItem?.Offer === 0) ); @@ -2451,9 +2242,10 @@ const BSItemCard = (props) => { ((cartItem?.OfferModeType && cartItem?.OfferMode === 'B' ? true : cartItem?.OfferMode !== 'B') && - cartItem?.OfferMode !== 'P' && cartItem?.OfferMode !== 'C' && - cartItem?.OfferMode !== 'O' && - cartItem?.OfferMode !== 'L' + cartItem?.OfferMode !== 'P' && + cartItem?.OfferMode !== 'C' && + cartItem?.OfferMode !== 'O' && + cartItem?.OfferMode !== 'L' ? true : cartItem?.Offer === 0) ) @@ -2466,9 +2258,10 @@ const BSItemCard = (props) => { ((cartItem?.OfferModeType && cartItem?.OfferMode === 'B' ? true : cartItem?.OfferMode !== 'B') && - cartItem?.OfferMode !== 'P' && cartItem?.OfferMode !== 'C' && - cartItem?.OfferMode !== 'O' && - cartItem?.OfferMode !== 'L' + cartItem?.OfferMode !== 'P' && + cartItem?.OfferMode !== 'C' && + cartItem?.OfferMode !== 'O' && + cartItem?.OfferMode !== 'L' ? true : cartItem?.Offer === 0) ) @@ -2489,8 +2282,8 @@ const BSItemCard = (props) => { isItemInCart, item?.OtherProduct === 'Others' || item?.ScaleType === 'weight' ? ( - (item?.OrderQty || 0) + parseFloat(isItemInCart?.OrderQty) - )?.toFixed(3) + (item?.OrderQty || 0) + parseFloat(isItemInCart?.OrderQty) + )?.toFixed(3) : null ); const updatedData = addFirst @@ -2516,8 +2309,8 @@ const BSItemCard = (props) => { isItemInCartHold, item?.OtherProduct === 'Others' || item?.ScaleType === 'weight' ? ( - (item?.OrderQty || 0) + parseFloat(isItemInCartHold?.OrderQty) - )?.toFixed(3) + (item?.OrderQty || 0) + parseFloat(isItemInCartHold?.OrderQty) + )?.toFixed(3) : null ); const updatedData = addFirst @@ -2744,14 +2537,14 @@ const BSItemCard = (props) => { updatedCartData = cartData.map((item, idx) => idx === indexToCheck ? { - ...item, - Offer: null, - OfferMessage: undefined, - OfferMode: undefined, - OfferModeType: false, - OfferType: undefined, - OfferValue: null, - } + ...item, + Offer: null, + OfferMessage: undefined, + OfferMode: undefined, + OfferModeType: false, + OfferType: undefined, + OfferValue: null, + } : item ); } @@ -2800,9 +2593,12 @@ const BSItemCard = (props) => { const UpdatedCartItemWithOffer = { ...item, - Offer: (sameProduct || bestOffer?.OfferMode === 'I' || bestOffer?.OfferMode === 'Q') - ? (bestOffer?.OfferAmount || item.Offer) - : (item.Offer || bestOffer?.OfferAmount), + Offer: + sameProduct || + bestOffer?.OfferMode === 'I' || + bestOffer?.OfferMode === 'Q' + ? bestOffer?.OfferAmount || item.Offer + : item.Offer || bestOffer?.OfferAmount, OfferType: item?.OfferType || bestOffer?.OfferType, OfferMessage: item?.OfferMessage || bestOffer?.OfferMessage, OfferMode: item?.OfferMode || bestOffer?.OfferMode, @@ -2817,9 +2613,10 @@ const BSItemCard = (props) => { ((c?.OfferModeType && c?.OfferMode === 'B' ? true : c?.OfferMode !== 'B') && - c?.OfferMode !== 'P' && c?.OfferMode !== 'C' && - c?.OfferMode !== 'O' && - c?.OfferMode !== 'L' + c?.OfferMode !== 'P' && + c?.OfferMode !== 'C' && + c?.OfferMode !== 'O' && + c?.OfferMode !== 'L' ? true : c?.Offer === 0); @@ -3134,7 +2931,6 @@ const BSItemCard = (props) => { }; }); - console.log(Postdata, 'Postdata'); const response = await dispatch( bulkpostdata({ ProdDetails: Postdata }) ).unwrap(); @@ -3207,10 +3003,10 @@ const BSItemCard = (props) => { return FreeProdList.map((f, i) => i === index ? { - ...existing, - ...newFreeProd, - ProdVariantDetails: existing.ProdVariantDetails, - } + ...existing, + ...newFreeProd, + ProdVariantDetails: existing.ProdVariantDetails, + } : f ); } else { @@ -3280,7 +3076,7 @@ const BSItemCard = (props) => { const cycleSize = buyQty + getQty; const fullCycles = Math.floor( freeCartItem?.reduce((acc, fc) => acc + (fc?.OrderQty || 0), 0) / - cycleSize + cycleSize ); const totalFreeQty = fullCycles * getQty; @@ -3838,7 +3634,7 @@ const BSItemCard = (props) => { parseInt(totalSelectedProductQty || 0) + parseInt(reorderComboConsumed || 0); } - } catch (_) { } + } catch (_) {} let getCurrentProdDtl = orderDetails?.filter( (a) => a?.ProdName === ProdName ); @@ -4039,7 +3835,7 @@ const BSItemCard = (props) => { parseInt(totalSelectedProductQty || 0) + parseInt(reorderComboConsumed || 0); } - } catch (_) { } + } catch (_) {} let getCurrentProdDtl = orderDetails?.filter((a) => a?.ProdId === ProdId); let totalOrderQty = getCurrentProdDtl?.reduce((accumulator, card) => { return ( @@ -4075,7 +3871,7 @@ const BSItemCard = (props) => { }, 0); totalOrderQty = parseInt(totalOrderQty || 0) + parseInt(comboConsumed || 0); - } catch (_) { } + } catch (_) {} let OverallProdQty = totalOrderQty - totalSelectedProductQty; if ( parseInt(ItemQuantity) > @@ -4161,7 +3957,7 @@ const BSItemCard = (props) => { parseInt(totalSelectedProductQty || 0) + parseInt(reorderComboConsumed || 0); } - } catch (_) { } + } catch (_) {} let getCurrentProdDtl = orderDetails?.filter((a) => a?.ProdId === ProdId); let totalOrderQty = getCurrentProdDtl?.reduce((accumulator, card) => { return ( @@ -4200,7 +3996,7 @@ const BSItemCard = (props) => { }, 0); totalOrderQty = parseInt(totalOrderQty || 0) + parseInt(comboConsumed || 0); - } catch (_) { } + } catch (_) {} let OverallProdQty = totalOrderQty - totalSelectedProductQty; if ( parseInt(ItemQuantity) > @@ -4292,7 +4088,7 @@ const BSItemCard = (props) => { parseInt(totalSelectedProductQty || 0) + parseInt(reorderComboConsumed || 0); } - } catch (_) { } + } catch (_) {} let getCurrentProdDtl = orderDetails?.filter( (a) => a?.ProdId === ProdId && a?.InwardDtlId === InwardDtlId ); @@ -4335,7 +4131,7 @@ const BSItemCard = (props) => { }, 0); totalOrderQty = parseInt(totalOrderQty || 0) + parseInt(comboConsumed || 0); - } catch (_) { } + } catch (_) {} let OverallProdQty = totalOrderQty - totalSelectedProductQty; if ( @@ -4419,7 +4215,7 @@ const BSItemCard = (props) => { parseInt(totalSelectedProductQty || 0) + parseInt(reorderComboConsumed || 0); } - } catch (_) { } + } catch (_) {} let getCurrentProdDtl = orderDetails?.filter( (a) => a?.ProdId === ProdId && a?.InwardDtlId === InwardDtlId ); @@ -4466,7 +4262,7 @@ const BSItemCard = (props) => { }, 0); totalOrderQty = parseInt(totalOrderQty || 0) + parseInt(comboConsumed || 0); - } catch (_) { } + } catch (_) {} let OverallProdQty = totalOrderQty - totalSelectedProductQty; if ( @@ -4644,7 +4440,7 @@ const BSItemCard = (props) => { 0 || - record.StockCount === 'Stock Not Maintained' + record.StockCount === 'Stock Not Maintained' ? { color: '#000', cursor: 'pointer' } : { color: '#f49898', cursor: 'not-allowed' } } @@ -4674,7 +4470,7 @@ const BSItemCard = (props) => { 0 || - record.StockCount === 'Stock Not Maintained' + record.StockCount === 'Stock Not Maintained' ? { color: '#000', cursor: 'pointer' } : { color: '#f49898', cursor: 'not-allowed' } } @@ -4704,7 +4500,7 @@ const BSItemCard = (props) => { 0 || - record.StockCount === 'Stock Not Maintained' + record.StockCount === 'Stock Not Maintained' ? { color: '#000', cursor: 'pointer' } : { color: '#f49898', cursor: 'not-allowed' } } @@ -4879,17 +4675,17 @@ const BSItemCard = (props) => { qtydata?.ProductDetail?.[QtyIndex]?.StockAvailable === 'Y' ? onePeiceFlow ? returnVariantStock( - qtydata?.ProductDetail?.[QtyIndex]?.ProdId, - item?.OverAllPcs, - CartOrderDetails, - item?.ProdVariantName - ) + qtydata?.ProductDetail?.[QtyIndex]?.ProdId, + item?.OverAllPcs, + CartOrderDetails, + item?.ProdVariantName + ) : returnVariantStock( - qtydata?.ProductDetail?.[QtyIndex]?.ProdId, - item?.OverAllQty, - CartOrderDetails, - item?.ProdVariantName - ) + qtydata?.ProductDetail?.[QtyIndex]?.ProdId, + item?.OverAllQty, + CartOrderDetails, + item?.ProdVariantName + ) : 'Stock Not Maintained', VariantAvailableFrom: item?.AvailableFrom, VariantAvailableTo: item?.AvailableTo, @@ -4911,20 +4707,20 @@ const BSItemCard = (props) => { 'Batch No': item?.BatchRef, StockCount: onePeiceFlow ? returnCountStock( - item?.ProdId, - item?.OverAllPcs, - CartOrderDetails, - item?.InwardDtlId, - 'Y' - ) + item?.ProdId, + item?.OverAllPcs, + CartOrderDetails, + item?.InwardDtlId, + 'Y' + ) : returnCountStock( - item?.ProdId, - item?.BalanceQty, - CartOrderDetails, - item?.InwardDtlId, - 'N', - item?.OverAllPcs - ), + item?.ProdId, + item?.BalanceQty, + CartOrderDetails, + item?.InwardDtlId, + 'N', + item?.OverAllPcs + ), 'Stock Date': ExtractDateFormate(item?.InwardDate), Price: onePeiceFlow ? item?.OnePcsPrice : item?.SellPrice, ExpDate: @@ -5303,7 +5099,8 @@ const BSItemCard = (props) => { setVarItem(0); SingleQuantity(item, onePeiceFlow); } - setexpModel(false); + + closeExpireModal(); setProdexpir(true); setQtydata(item); }; @@ -5409,7 +5206,7 @@ const BSItemCard = (props) => { setQtyIndex(selectedProIndex); setRepeatedModel(true); - setExpQtyModel(false); + closeExpireModal() }; const expVerFun = (item) => { @@ -5426,12 +5223,12 @@ const BSItemCard = (props) => { setModelQty(false); setSelectedBrand('Others'); } - setexpVarModel(false); + closeExpireModal(); }; const expStockFun = (item) => { dataTransfer(qtydata, QtyIndex, VarientIndex, item, onePeiceFlow); - setexpStockModel(false); + closeExpireModal(); }; const getMaxBrandWidth = () => { @@ -5463,17 +5260,7 @@ const BSItemCard = (props) => { }; }, []); - useEffect(() => { - function handleResize() { - setScreenHeight(window.innerHeight); - } - - window.addEventListener('resize', handleResize); - - return () => { - window.removeEventListener('resize', handleResize); - }; - }, []); + // Example usage for checking the length of 'ProdVariantDetails' const widthBasedOnProdVariantDetails = getMaxBrandWidth(); @@ -6084,9 +5871,9 @@ const BSItemCard = (props) => { allProducts.forEach((product) => { const brandName = product.BrandName && - product.BrandName !== 'null' && - product.BrandName !== 'undefined' && - product.BrandName.trim() !== '' + product.BrandName !== 'null' && + product.BrandName !== 'undefined' && + product.BrandName.trim() !== '' ? product.BrandName : 'Others'; @@ -6120,13 +5907,13 @@ const BSItemCard = (props) => { const result = prodname ? (cardData || [])?.filter( - (item) => - normalize(item.ProdName).includes(normalize(prodname)) || - normalize(item.ProdCatName).includes(normalize(prodname)) || - item.ProductDetail?.some((detail) => - normalize(detail.ProdName).includes(normalize(prodname)) - ) - ) + (item) => + normalize(item.ProdName).includes(normalize(prodname)) || + normalize(item.ProdCatName).includes(normalize(prodname)) || + item.ProductDetail?.some((detail) => + normalize(detail.ProdName).includes(normalize(prodname)) + ) + ) : cardData; console.log(prodQty, 'cardDatacardData', result, prodname); @@ -6146,8 +5933,8 @@ const BSItemCard = (props) => { CardOnclick( result?.[0], result?.[0]?.OnePcsAvailable === 'Y' && - preferenceSingleSales && - 'OnePeiceProduct' + preferenceSingleSales && + 'OnePeiceProduct' ); // AddOrderDetails2(result?.[0]) } else if (item?.OverAllQty < prodQty) { @@ -6206,8 +5993,8 @@ const BSItemCard = (props) => { zIndex: '12', top: templateData?.BookingLayout?.[0] === 'Layout5' || - templateData?.BookingLayout?.[0] === 'Layout4' || - templateData?.BookingLayout?.[0] === 'Layout6' + templateData?.BookingLayout?.[0] === 'Layout4' || + templateData?.BookingLayout?.[0] === 'Layout6' ? '2.5rem' : '', }} @@ -6286,21 +6073,21 @@ const BSItemCard = (props) => { }} className={ (item?.OverAllQty !== undefined && - !preferenceSingleSales + !preferenceSingleSales ? returnCount( - item?.ProductDetail?.[0]?.ProdName, - item?.OverAllQty, - CartOrderDetails, - item?.OverAllPcs - ) + item?.ProductDetail?.[0]?.ProdName, + item?.OverAllQty, + CartOrderDetails, + item?.OverAllPcs + ) : returnOnepcCount( - item?.ProductDetail?.[0]?.ProdName, - item?.OverAllPcs, - CartOrderDetails - ) > 0) || - item?.ProductDetail?.some( - (item) => item?.StockAvailable !== 'Y' - ) + item?.ProductDetail?.[0]?.ProdName, + item?.OverAllPcs, + CartOrderDetails + ) > 0) || + item?.ProductDetail?.some( + (item) => item?.StockAvailable !== 'Y' + ) ? 'BkPrdCardActive' : 'BkPrdCardDeActive' } @@ -6338,39 +6125,39 @@ const BSItemCard = (props) => { cardFunction?.Background && (SelectedCardColor ? SelectedCardColor?.[ - 'BackgroundColor' - ] + 'BackgroundColor' + ] : ''), padding: !cardFunction?.ImageUp && - !cardFunction?.ImageDown + !cardFunction?.ImageDown ? cardFunction?.SmallImage && - '5px 9px' + '5px 9px' : '8px 2px', flexDirection: cardFunction?.ImageRight && - 'row-reverse' + 'row-reverse' ? cardFunction?.ImageRight && - 'row-reverse' + 'row-reverse' : cardFunction?.ImageUp && 'column' ? cardFunction?.ImageUp && - 'column' + 'column' : cardFunction?.ImageDown && - 'column-reverse' + 'column-reverse' ? cardFunction?.ImageDown && - 'column-reverse' + 'column-reverse' : cardFunction?.ImageLeft && - 'row', + 'row', borderRadius: cardFunction?.EdgeCurve && '6px', width: !cardFunction?.ImageUp && - !cardFunction?.ImageDown && - !cardFunction?.BigImage && - !cardFunction?.ImageRight && - cardFunction?.SmallImage && - (cardFunction?.ImageUp || - cardFunction?.ImageDown) + !cardFunction?.ImageDown && + !cardFunction?.BigImage && + !cardFunction?.ImageRight && + cardFunction?.SmallImage && + (cardFunction?.ImageUp || + cardFunction?.ImageDown) ? '6rem' : cardFunction?.BigImage && '9rem', height: @@ -6403,19 +6190,19 @@ const BSItemCard = (props) => { if ( !( (item?.OverAllQty !== undefined && - !preferenceSingleSales + !preferenceSingleSales ? returnCount( - item?.ProductDetail?.[0] - ?.ProdName, - item?.OverAllQty, - CartOrderDetails - ) + item?.ProductDetail?.[0] + ?.ProdName, + item?.OverAllQty, + CartOrderDetails + ) : returnOnepcCount( - item?.ProductDetail?.[0] - ?.ProdName, - item?.OverAllPcs, - CartOrderDetails - ) > 0) || + item?.ProductDetail?.[0] + ?.ProdName, + item?.OverAllPcs, + CartOrderDetails + ) > 0) || item?.ProductDetail?.some( (item) => item?.StockAvailable !== 'Y' @@ -6427,8 +6214,8 @@ const BSItemCard = (props) => { CardOnclick( item, item?.OnePcsAvailable === 'Y' && - preferenceSingleSales && - 'OnePeiceProduct' + preferenceSingleSales && + 'OnePeiceProduct' ); } }} @@ -6437,39 +6224,39 @@ const BSItemCard = (props) => { > {(cardFunction?.BigImage || cardFunction?.SmallImage) && ( - - )} + ? item?.ProductDetail?.[0] + ?.ProdLogo + : defaultimage + } + alt="" + /> + )}
{ cardFunction?.Background && (SelectedCardColor ? SelectedCardColor?.[ - 'BackgroundColor' - ] + 'BackgroundColor' + ] : ''), position: !cardFunction?.BigImage @@ -6503,7 +6290,7 @@ const BSItemCard = (props) => { height: cardFunction?.SmallImage ? '5.5rem' : !cardFunction?.BigImage && - '5.5rem', + '5.5rem', alignItems: !cardFunction?.BigImage && !cardFunction?.SmallImage && @@ -6526,11 +6313,11 @@ const BSItemCard = (props) => { 'uppercase', width: !cardFunction?.SmallImage ? cardFunction?.BigImage && - '120px' + '120px' : cardFunction?.SmallImage && - !cardFunction?.ImageUp && - !cardFunction?.ImageDown && - '85px', + !cardFunction?.ImageUp && + !cardFunction?.ImageDown && + '85px', // Width: cardFunction?.BigImage && "70px", fontSize: !cardFunction?.BigImage && @@ -6552,24 +6339,24 @@ const BSItemCard = (props) => { > {item?.ProdName}{' '} {(item?.OverAllQty !== undefined && - !preferenceSingleSales + !preferenceSingleSales ? returnCount( - item?.ProductDetail?.[0] - ?.ProdName, - item?.OverAllQty, - CartOrderDetails, - item - ) + item?.ProductDetail?.[0] + ?.ProdName, + item?.OverAllQty, + CartOrderDetails, + item + ) : returnOnepcCount( - item?.ProductDetail?.[0] - ?.ProdName, - item?.OverAllPcs, - CartOrderDetails - ) > 0) || - item?.ProductDetail?.some( - (item) => - item?.StockAvailable !== 'Y' - ) ? ( + item?.ProductDetail?.[0] + ?.ProdName, + item?.OverAllPcs, + CartOrderDetails + ) > 0) || + item?.ProductDetail?.some( + (item) => + item?.StockAvailable !== 'Y' + ) ? ( '' ) : (

{ fontSize: !cardFunction?.SmallImage ? cardFunction?.BigImage && - '12px' + '12px' : '12px', textAlign: 'center', lineHeight: '2', @@ -6608,8 +6395,8 @@ const BSItemCard = (props) => { : '', color: SelectedCardColor ? SelectedCardColor?.[ - 'FontColor' - ] + 'FontColor' + ] : '', }} > @@ -6657,19 +6444,19 @@ const BSItemCard = (props) => { count={ !preferenceSingleSales ? returnCount( - item - ?.ProductDetail?.[0] - ?.ProdName, - item?.OverAllQty, - CartOrderDetails - ) + item + ?.ProductDetail?.[0] + ?.ProdName, + item?.OverAllQty, + CartOrderDetails + ) : returnOnepcCount( - item - ?.ProductDetail?.[0] - ?.ProdName, - item?.OverAllPcs, - CartOrderDetails - ) + item + ?.ProductDetail?.[0] + ?.ProdName, + item?.OverAllPcs, + CartOrderDetails + ) } overflowCount={10000} > @@ -6721,14 +6508,14 @@ const BSItemCard = (props) => { item?.OverAllPcs, CartOrderDetails ) > 0 || - item?.ProductDetail?.some( - (product) => - product?.StockAvailable !== - 'Y' - ) + item?.ProductDetail?.some( + (product) => + product?.StockAvailable !== + 'Y' + ) ? cardFunction?.Background ? SelectedCardColor?.BackgroundColor || - '#000000' + '#000000' : '#fff' : '#ff4d4f', }} @@ -6770,39 +6557,39 @@ const BSItemCard = (props) => { cardFunction?.Background && (SelectedCardColor ? SelectedCardColor?.[ - 'BackgroundColor' - ] + 'BackgroundColor' + ] : ''), padding: !cardFunction?.ImageUp && - !cardFunction?.ImageDown + !cardFunction?.ImageDown ? cardFunction?.SmallImage && - '5px 9px' + '5px 9px' : '8px 2px', flexDirection: cardFunction?.ImageRight && - 'row-reverse' + 'row-reverse' ? cardFunction?.ImageRight && - 'row-reverse' + 'row-reverse' : cardFunction?.ImageUp && 'column' ? cardFunction?.ImageUp && - 'column' + 'column' : cardFunction?.ImageDown && - 'column-reverse' + 'column-reverse' ? cardFunction?.ImageDown && - 'column-reverse' + 'column-reverse' : cardFunction?.ImageLeft && - 'row', + 'row', borderRadius: cardFunction?.EdgeCurve && '6px', width: !cardFunction?.ImageUp && - !cardFunction?.ImageDown && - !cardFunction?.BigImage && - !cardFunction?.ImageRight && - cardFunction?.SmallImage && - (cardFunction?.ImageUp || - cardFunction?.ImageDown) + !cardFunction?.ImageDown && + !cardFunction?.BigImage && + !cardFunction?.ImageRight && + cardFunction?.SmallImage && + (cardFunction?.ImageUp || + cardFunction?.ImageDown) ? '6rem' : cardFunction?.BigImage && '9rem', height: @@ -6820,19 +6607,19 @@ const BSItemCard = (props) => { if ( !( (item?.OverAllQty !== undefined && - !preferenceSingleSales + !preferenceSingleSales ? returnCount( - item?.ProductDetail?.[0] - ?.ProdName, - item?.OverAllQty, - CartOrderDetails - ) + item?.ProductDetail?.[0] + ?.ProdName, + item?.OverAllQty, + CartOrderDetails + ) : returnOnepcCount( - item?.ProductDetail?.[0] - ?.ProdName, - item?.OverAllPcs, - CartOrderDetails - ) > 0) || + item?.ProductDetail?.[0] + ?.ProdName, + item?.OverAllPcs, + CartOrderDetails + ) > 0) || item?.ProductDetail?.some( (item) => item?.StockAvailable !== 'Y' @@ -6844,48 +6631,48 @@ const BSItemCard = (props) => { CardOnclick( item, item?.OnePcsAvailable === 'Y' && - preferenceSingleSales && - 'OnePeiceProduct' + preferenceSingleSales && + 'OnePeiceProduct' ); } }} - // data-aos="zoom-in" data-aos-duration="600" + // data-aos="zoom-in" data-aos-duration="600" > {(cardFunction?.BigImage || cardFunction?.SmallImage) && ( - - )} + ? item?.ProductDetail?.[0] + ?.ProdLogo + : defaultimage + } + alt="" + /> + )}

{ cardFunction?.Background && (SelectedCardColor ? SelectedCardColor?.[ - 'BackgroundColor' - ] + 'BackgroundColor' + ] : ''), position: !cardFunction?.BigImage @@ -6919,7 +6706,7 @@ const BSItemCard = (props) => { height: cardFunction?.SmallImage ? '5.5rem' : !cardFunction?.BigImage && - '4.5rem', + '4.5rem', alignItems: !cardFunction?.BigImage && !cardFunction?.SmallImage && @@ -6939,11 +6726,11 @@ const BSItemCard = (props) => { 'uppercase', width: !cardFunction?.SmallImage ? cardFunction?.BigImage && - '120px' + '120px' : cardFunction?.SmallImage && - !cardFunction?.ImageUp && - !cardFunction?.ImageDown && - '85px', + !cardFunction?.ImageUp && + !cardFunction?.ImageDown && + '85px', // Width: cardFunction?.BigImage && "70px", fontSize: !cardFunction?.BigImage && @@ -6965,24 +6752,24 @@ const BSItemCard = (props) => { > {item?.ProdName}{' '} {(item?.OverAllQty !== undefined && - !preferenceSingleSales + !preferenceSingleSales ? returnCount( - item?.ProductDetail?.[0] - ?.ProdName, - item?.OverAllQty, - CartOrderDetails, - item - ) + item?.ProductDetail?.[0] + ?.ProdName, + item?.OverAllQty, + CartOrderDetails, + item + ) : returnOnepcCount( - item?.ProductDetail?.[0] - ?.ProdName, - item?.OverAllPcs, - CartOrderDetails - ) > 0) || - item?.ProductDetail?.some( - (item) => - item?.StockAvailable !== 'Y' - ) ? ( + item?.ProductDetail?.[0] + ?.ProdName, + item?.OverAllPcs, + CartOrderDetails + ) > 0) || + item?.ProductDetail?.some( + (item) => + item?.StockAvailable !== 'Y' + ) ? ( '' ) : (

{ fontSize: !cardFunction?.SmallImage ? cardFunction?.BigImage && - '12px' + '12px' : '12px', textAlign: 'center', lineHeight: '2', @@ -7021,8 +6808,8 @@ const BSItemCard = (props) => { : '', color: SelectedCardColor ? SelectedCardColor?.[ - 'FontColor' - ] + 'FontColor' + ] : '', }} > @@ -7067,19 +6854,19 @@ const BSItemCard = (props) => { count={ !preferenceSingleSales ? returnCount( - item - ?.ProductDetail?.[0] - ?.ProdName, - item?.OverAllQty, - CartOrderDetails - ) + item + ?.ProductDetail?.[0] + ?.ProdName, + item?.OverAllQty, + CartOrderDetails + ) : returnOnepcCount( - item - ?.ProductDetail?.[0] - ?.ProdName, - item?.OverAllPcs, - CartOrderDetails - ) + item + ?.ProductDetail?.[0] + ?.ProdName, + item?.OverAllPcs, + CartOrderDetails + ) } overflowCount={10000} > @@ -7130,14 +6917,14 @@ const BSItemCard = (props) => { item?.OverAllPcs, CartOrderDetails ) > 0 || - item?.ProductDetail?.some( - (product) => - product?.StockAvailable !== - 'Y' - ) + item?.ProductDetail?.some( + (product) => + product?.StockAvailable !== + 'Y' + ) ? cardFunction?.Background ? SelectedCardColor?.BackgroundColor || - '#000000' + '#000000' : '#fff' : '#ff4d4f', }} @@ -7152,21 +6939,21 @@ const BSItemCard = (props) => {

0) || - item?.ProductDetail?.some( - (item) => item?.StockAvailable !== 'Y' - ) + item?.ProductDetail?.[0]?.ProdName, + item?.OverAllPcs, + CartOrderDetails + ) > 0) || + item?.ProductDetail?.some( + (item) => item?.StockAvailable !== 'Y' + ) ? 'card4Main card4Main-active' : 'card4Main card4Main-deactive' } @@ -7189,17 +6976,17 @@ const BSItemCard = (props) => { if ( !( (item?.OverAllQty !== undefined && - !preferenceSingleSales + !preferenceSingleSales ? returnCount( - item?.ProductDetail?.[0]?.ProdName, - item?.OverAllQty, - CartOrderDetails - ) + item?.ProductDetail?.[0]?.ProdName, + item?.OverAllQty, + CartOrderDetails + ) : returnOnepcCount( - item?.ProductDetail?.[0]?.ProdName, - item?.OverAllPcs, - CartOrderDetails - ) > 0) || + item?.ProductDetail?.[0]?.ProdName, + item?.OverAllPcs, + CartOrderDetails + ) > 0) || item?.ProductDetail?.some( (item) => item?.StockAvailable !== 'Y' ) @@ -7214,8 +7001,8 @@ const BSItemCard = (props) => { CardOnclick( item, item?.OnePcsAvailable === 'Y' && - preferenceSingleSales && - 'OnePeiceProduct' + preferenceSingleSales && + 'OnePeiceProduct' ); // This will trigger if you're clicking outside the "One Piece" button } @@ -7257,7 +7044,7 @@ const BSItemCard = (props) => { height={60} src={ item?.ProductDetail?.[0]?.ProdLogo === - '' + '' ? defaultimage : item?.ProductDetail?.[0]?.ProdLogo ? item?.ProductDetail?.[0]?.ProdLogo @@ -7272,21 +7059,21 @@ const BSItemCard = (props) => {
{item?.ProdName} {(item?.OverAllQty !== undefined && - !preferenceSingleSales + !preferenceSingleSales ? returnCount( - item?.ProductDetail?.[0]?.ProdName, - item?.OverAllQty, - CartOrderDetails, - item - ) + item?.ProductDetail?.[0]?.ProdName, + item?.OverAllQty, + CartOrderDetails, + item + ) : returnOnepcCount( - item?.ProductDetail?.[0]?.ProdName, - item?.OverAllPcs, - CartOrderDetails - ) > 0) || - item?.ProductDetail?.some( - (item) => item?.StockAvailable !== 'Y' - ) ? ( + item?.ProductDetail?.[0]?.ProdName, + item?.OverAllPcs, + CartOrderDetails + ) > 0) || + item?.ProductDetail?.some( + (item) => item?.StockAvailable !== 'Y' + ) ? ( '' ) : (

{ )}

{((item?.OverAllQty !== undefined && - !preferenceSingleSales + !preferenceSingleSales ? returnCount( - item?.ProductDetail?.[0]?.ProdName, - item?.OverAllQty, - CartOrderDetails, - item - ) + item?.ProductDetail?.[0]?.ProdName, + item?.OverAllQty, + CartOrderDetails, + item + ) : returnOnepcCount( - item?.ProductDetail?.[0]?.ProdName, - item?.OverAllPcs, - CartOrderDetails - ) > 0) || + item?.ProductDetail?.[0]?.ProdName, + item?.OverAllPcs, + CartOrderDetails + ) > 0) || item?.ProductDetail?.some( (item) => item?.StockAvailable !== 'Y' )) && ( -
-
- ₹ {ItemSellingPrice(item)} -
- -
- <> - ({ItemSize(item)} {ItemUomName(item)}) - -
+
+
+ ₹ {ItemSellingPrice(item)}
- )} + +
+ <> + ({ItemSize(item)} {ItemUomName(item)}) + +
+
+ )}
{/* Stock Count Badge */} @@ -7352,17 +7139,17 @@ const BSItemCard = (props) => { count={ !preferenceSingleSales ? returnCount( - item?.ProductDetail?.[0] - ?.ProdName, - item?.OverAllQty, - CartOrderDetails - ) + item?.ProductDetail?.[0] + ?.ProdName, + item?.OverAllQty, + CartOrderDetails + ) : returnOnepcCount( - item?.ProductDetail?.[0] - ?.ProdName, - item?.OverAllPcs, - CartOrderDetails - ) + item?.ProductDetail?.[0] + ?.ProdName, + item?.OverAllPcs, + CartOrderDetails + ) } overflowCount={10000} > @@ -7411,13 +7198,13 @@ const BSItemCard = (props) => { item?.OverAllPcs, CartOrderDetails ) > 0 || - item?.ProductDetail?.some( - (product) => - product?.StockAvailable !== 'Y' - ) + item?.ProductDetail?.some( + (product) => + product?.StockAvailable !== 'Y' + ) ? cardFunction?.Background ? SelectedCardColor?.BackgroundColor || - '#000000' + '#000000' : '#fff' : '#ff4d4f', }} @@ -7502,107 +7289,19 @@ const BSItemCard = (props) => {
- {expModel && ( - -
- -
-
-

Product Expires

-
-
- } - open={expModel} - onOk={() => expFun(Item)} - onCancel={() => setexpModel(false)} - okText="Submit" - cancelText="Don't Submit" - maskTransitionName="" // Remove animation for the mask - transitionName="" - > - )} - - {expQtyModel && ( - - -

Quantity Expires

-
- } - open={expQtyModel} - onOk={() => expQtyFun(qtyExpData)} - onCancel={() => { - (setRepeatedModel(false), - setProdexpir(false), - setExpQtyModel(false)); + {expireModal?.open && ( + { + expireModal.onOk?.(); + closeExpireModal(); }} - okText="Submit" - cancelText="Don't Submit" - maskTransitionName="" - transitionName="" - > - )} - - {expVarModel && ( - - -

Variant Expires

-
- } - open={expVarModel} - onOk={() => expVerFun(VarItem)} onCancel={() => { - (setexpVarModel(false), - setRepeatedModel(false), - setProdexpir(false)); + expireModal.onCancel?.(); + closeExpireModal(); }} - okText="Submit" - cancelText="Don't Submit" - maskTransitionName="" - transitionName="" - > - )} - {expStockModel && ( - - -

Stock Expires

-
- } - open={expStockModel} - onOk={() => expStockFun(StockItem)} - onCancel={() => { - (setexpStockModel(false), - setRepeatedModel(false), - setProdexpir(false)); - }} - okText="Submit" - cancelText="Don't Submit" - maskTransitionName="" - transitionName="" - > + /> )} {modelQty && ( @@ -7893,16 +7592,16 @@ const BSItemCard = (props) => { ]?.ProdVariantName?.toLowerCase()?.includes( 'variant' ) && ( - - ( - { - qtydata?.ProductDetail?.[QtyIndex] - ?.ProdVariantDetails?.[VarientIndex] - ?.ProdVariantName - } - ){' '} - - )} + + ( + { + qtydata?.ProductDetail?.[QtyIndex] + ?.ProdVariantDetails?.[VarientIndex] + ?.ProdVariantName + } + ){' '} + + )}