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/Components/Loader/Loader.jsx b/src/Components/Loader/Loader.jsx index 9860b0f..f0d30d0 100644 --- a/src/Components/Loader/Loader.jsx +++ b/src/Components/Loader/Loader.jsx @@ -37,9 +37,9 @@ const Loader = () => {

Loading

PozoApp - BillingApp PozoApp - BillingApp + PozoApp + PozoApp PozoApp

diff --git a/src/Features/BookingScreen/BookingData/BookingData.js b/src/Features/BookingScreen/BookingData/BookingData.js index 23a4dab..8626441 100644 --- a/src/Features/BookingScreen/BookingData/BookingData.js +++ b/src/Features/BookingScreen/BookingData/BookingData.js @@ -1609,6 +1609,7 @@ const initialState = { salesBillEdit: false, previousOrderPayment: [], previousOrderOfferDetails: [], + getmultipleSearchDatas: [] }; const BookingData = createSlice({ @@ -2110,6 +2111,13 @@ const BookingData = createSlice({ state.AllCustomers = []; } }); + builder.addCase(getmultipleSearch.fulfilled, (state, action) => { + if (action?.payload?.data?.statusCode === 1) { + state.getmultipleSearchDatas = action?.payload?.data?.data[0]?.SearchTermDtl?.map((e) => e?.SearchTerm) || []; + } else { + state.getmultipleSearchDatas = []; + } + }); }, }); @@ -2387,5 +2395,7 @@ export const GlobalPreviousOrderPayment = (state) => state?.BookingData?.previousOrderPayment; export const GlobalPreviousOrderOfferDetails = (state) => state?.BookingData?.previousOrderOfferDetails; +export const GlobalGetmultipleSearchDatas = (state) => + state?.BookingData?.getmultipleSearchDatas; export default BookingData.reducer; diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingEditQuantity/BSBillingEditQuantity.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingEditQuantity/BSBillingEditQuantity.jsx index ddefcd5..4a3942d 100644 --- a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingEditQuantity/BSBillingEditQuantity.jsx +++ b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingEditQuantity/BSBillingEditQuantity.jsx @@ -40,6 +40,7 @@ import { } from '../../../../../Features/Offer/Offernew/BookingOffernew.js'; import { validateOffers } from '../../BSItemCards/ValidateOffer.jsx'; import { v4 as uuidv4 } from 'uuid'; +import WeightCalculatePrice from './WeightCalculatePrice.jsx'; const BSBillingEditQuantity = (props) => { const dispatch = useDispatch(); @@ -101,15 +102,33 @@ const BSBillingEditQuantity = (props) => { const SettingDataSelector = useSelector(PreferenceData); const OrderType = useSelector(GlobalOrderType); const [BillOrderPre, setBillOrderPre] = useState(null); - const [RadioBtnSelection, setRadioBtnSelection] = useState( - props?.shortKeyMethod == 'price' - ? 'Price' - : ItemData?.ScaleType !== 'weight' - ? 'Quantity' - : PriceChangeaccess - ? 'Price' - : 'Parcel' - ); + const SHORTKEY_TO_RADIO = { + price: 'Price', + quantity: 'qty', + Parcel: 'Parcel', + weightAmount: 'weightAmount' +}; +const [RadioBtnSelection, setRadioBtnSelection] = useState(() => { + if (props?.shortKeyMethod && SHORTKEY_TO_RADIO[props.shortKeyMethod]) { + return SHORTKEY_TO_RADIO[props.shortKeyMethod]; + } + if (ItemData?.ScaleType !== 'weight') { + return 'Quantity'; + } + if (PriceChangeaccess) { + return 'Price'; + } + return 'Parcel'; +}); + // const [RadioBtnSelection, setRadioBtnSelection] = useState( + // props?.shortKeyMethod == 'price' + // ? 'Price' + // : ItemData?.ScaleType !== 'weight' + // ? 'Quantity' + // : PriceChangeaccess + // ? 'Price' + // : 'Parcel' + // ); const [PercentageSelection, setPercentageSelection] = useState('Fixed'); const [RadioDetails, setRadioDetails] = useState(false); const [editedPrice, setEditedPrice] = useState(0); @@ -678,12 +697,12 @@ const BSBillingEditQuantity = (props) => { const handleEditQuantity = async ( editedProduct, editedProductIndex, - newPrice + newPrice, + overrideQty = null ) => { - // check itself is a offer product - - const editedQty = - props?.Productdata?.ScaleType !== 'weight' + const editedQty = overrideQty !== null + ? overrideQty + : props?.Productdata?.ScaleType !== 'weight' ? parseInt(Quantity) : props.Productdata.OrderQty; const addFirst = BillOrderPre === 'Y'; @@ -3096,9 +3115,10 @@ const BSBillingEditQuantity = (props) => { newPrice = 0, offerApply = false ) => { + const fixedQty = Number(qty.toFixed(3)); const updatedProduct = { ...editedProduct, - OrderQty: qty, + OrderQty: fixedQty, OrderRate: newPrice > 0 ? newPrice : editedProduct?.OrderRate, ...calculateTaxAmounts({ qty: qty, @@ -3236,289 +3256,6 @@ const BSBillingEditQuantity = (props) => { OfferValue: offerValue, }; }; - - // const AddProductQuantity = async () => { - // let NewPrice = NewPrice1 > 0 ? NewPrice1 : props.Productdata.OrderRate; - // await dispatch(changeHoldOrderDtl(false)); - // await dispatch(changePreviousOrderLength(CartOrderDetails?.length)); - // const OtherOrderDatas = CartOrderDetails?.filter( - // (cartItem) => - // !( - // cartItem?.ProdId === props?.Productdata?.ProdId && - // cartItem.InwardDtlId === props?.Productdata?.InwardDtlId && - // cartItem?.OrderRate === props?.Productdata?.OrderRate && - // cartItem?.BookingTypeName === props?.Productdata?.BookingTypeName - // ) && !cartItem?.SalesId - // ); - - // const OtherOrderDatawithsales = CartOrderDetails?.filter( - // (cartItem) => cartItem?.SalesId - // ); - // const OtherorderDataforNormal = CartOrderDetails?.filter( - // (cartItem) => - // !( - // cartItem?.ProdId === props?.Productdata?.ProdId && - // cartItem?.InwardDtlId === props?.Productdata?.InwardDtlId && - // cartItem?.OrderRate === props?.Productdata?.OrderRate && - // cartItem?.BookingTypeName === props?.Productdata?.BookingTypeName && - // !cartItem?.SalesId - // ) - // ); - - // const isItemInCart = CartOrderDetails?.find( - // (cartItem) => - // cartItem?.ProdId === props?.Productdata?.ProdId && - // cartItem?.InwardDtlId === props?.Productdata?.InwardDtlId && - // cartItem?.OrderRate === props?.Productdata?.OrderRate && - // cartItem?.BookingTypeName === props?.Productdata?.BookingTypeName && - // !cartItem?.SalesId - // ); // check if the item is already in the cart - // // changing for one piece stock checking - // const isItemInCartfilter = CartOrderDetails?.filter( - // (cartItem) => - // cartItem?.ProdId === props?.Productdata?.ProdId && - // cartItem?.InwardDtlId === props?.Productdata?.InwardDtlId && - // !( - // cartItem?.OrderRate === props?.Productdata?.OrderRate && - // cartItem?.BookingTypeName === props?.Productdata?.BookingTypeName - // ) && - // !cartItem?.SalesId - // ); // check if the item is already in the cart - // let OverallQuantity = CalculateOverallQty(isItemInCart, isItemInCartfilter); - // const BookingTypeProd = props?.Productdata?.BookingTypeName; - // const isItemInCartHold = CartOrderDetails?.find( - // (cartItem) => - // cartItem?.ProdId === props?.Productdata?.ProdId && - // cartItem?.InwardDtlId === props?.Productdata?.InwardDtlId && - // cartItem?.OrderRate === props?.Productdata?.OrderRate && - // cartItem?.BookingTypeName === props?.Productdata?.BookingTypeName - // ); // check if the item is already in the cart - // const isItemInCartHoldfilter = CartOrderDetails?.filter( - // (cartItem) => - // cartItem?.ProdId === props?.Productdata?.ProdId && - // cartItem?.InwardDtlId === props?.Productdata?.InwardDtlId && - // !( - // cartItem?.OrderRate === props?.Productdata?.OrderRate && - // cartItem?.BookingTypeName === props?.Productdata?.BookingTypeName - // ) - // ); // check if the item is already in the cart - // const holddataproduct = ReorderProductData?.filter( - // (cartItem) => - // cartItem?.ProdId === props?.Productdata?.ProdId && - // cartItem?.InwardDtlId === props?.Productdata?.InwardDtlId - // ); - // let totalSelectedProductQty = holddataproduct?.reduce( - // (accumulator, card) => { - // return ( - // accumulator + - // parseInt( - // card?.StockAvailable === 'Y' - // ? props?.Productdata?.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 === props?.Productdata?.ProdId && - // cartItem?.InwardDtlId === props?.Productdata?.InwardDtlId && - // cartItem?.OrderRate === props?.Productdata?.OrderRate && - // cartItem?.BookingTypeName === props?.Productdata?.BookingTypeName - // ) - // ); - - // if (parseInt(Quantity) === 0 || Quantity === '') { - // setMessageType('error'); - // setMessageData('Please enter valid quantity'); - // setQuantity(''); - // } - // else { - // if (isItemInCart && BookingTypeProd != 'Dine In' && OrderType != 'Hold') { - // if (isItemInCart?.StockAvailable === 'Y') { - // let Condition = OverallQuantity >= Quantity; - // if (Condition) { - // const UpdatedCartItem = await createUpdatedCartItem( - // isItemInCart, - // Quantity, - // NewPrice - // ); - // const Cartdata = MergecardItem( - // UpdatedCartItem, - // BillOrderPre, - // OtherorderDataforNormal - // ); - // await dispatch(changeOrderCardDetails(Cartdata)); - // if (OfferCheckedInSetup && preferenceOffer) { - // await applyOffer(Cartdata); - // } else { - // dispatch(changeOrderCardDetails(Cartdata)); - // } - - // props.handleEditQuantityCancel(); - // setClearQuantity(false); - // } else { - // setMessageType('error'); - // setMessageData('Stock Not Available'); - // setQuantity(''); - // } - // } else { - // if ( - // isItemInCart && - // BookingTypeProd != 'Dine In' && - // OrderType != 'Hold' - // ) { - // const UpdatedCartItem = createUpdatedCartItem( - // isItemInCart, - // Quantity, - // NewPrice - // ); - // const Cartdata = MergecardItem( - // UpdatedCartItem, - // BillOrderPre, - // OtherorderDataforNormal - // ); - // await dispatch(changeOrderCardDetails(Cartdata)); - // if (OfferCheckedInSetup && preferenceOffer) { - // await applyOffer(Cartdata); - // } else { - // dispatch(changeOrderCardDetails(Cartdata)); - // } - // } - // props.handleEditQuantityCancel(); - // setClearQuantity(false); - // } - // } - // else if (isItemInCartHold && OrderType === 'Hold') { - // if (isItemInCartHold?.StockAvailable === 'Y') { - // let Condition = OverallQuantityhold >= Quantity; - // if (Condition) { - // const UpdatedCartItem = createUpdatedCartItem( - // isItemInCartHold, - // Quantity, - // NewPrice - // ); - // const Cartdata = MergecardItem( - // UpdatedCartItem, - // BillOrderPre, - // OtherorderDataforNormalWithoutSalesId - // ); - // if (OfferCheckedInSetup && preferenceOffer) { - // await applyOffer(Cartdata); - // } else { - // dispatch(changeOrderCardDetails(Cartdata)); - // } - // await dispatch(changeOrderCardDetails(Cartdata)); - - // props.handleEditQuantityCancel(); - // setClearQuantity(false); - // } else { - // setMessageType('error'); - // setMessageData('Stock Not Available'); - // setQuantity(''); - // } - // } else { - // if (isItemInCartHold && OrderType === 'Hold') { - // const UpdatedCartItem = createUpdatedCartItem( - // isItemInCartHold, - // Quantity, - // NewPrice - // ); - // const Cartdata = MergecardItem( - // UpdatedCartItem, - // BillOrderPre, - // OtherorderDataforNormalWithoutSalesId - // ); - // await dispatch(changeOrderCardDetails(Cartdata)); - // if (OfferCheckedInSetup && preferenceOffer) { - // await applyOffer(Cartdata); - // } else { - // dispatch(changeOrderCardDetails(Cartdata)); - // } - // } - // props.handleEditQuantityCancel(); - // setClearQuantity(false); - // } - // } - // else if ( - // isItemInCart && - // BookingTypeProd === 'Dine In' && - // OrderType != 'Hold' - // ) { - // if (isItemInCart?.StockAvailable === 'Y') { - // let Condition = OverallQuantity >= Quantity; - // if (Condition) { - // const UpdatedCartItem = createUpdatedCartItem( - // isItemInCart, - // Quantity, - // NewPrice - // ); - // const Cartdata = MergecardItem( - // UpdatedCartItem, - // BillOrderPre, - // OtherOrderDatas - // ); - // await dispatch( - // changeOrderCardDetails([...OtherOrderDatawithsales, ...Cartdata]) - // ); - // if (OfferCheckedInSetup && preferenceOffer) { - // await applyOffer(Cartdata); - // } else { - // dispatch(changeOrderCardDetails(Cartdata)); - // } - // props.handleEditQuantityCancel(); - // setClearQuantity(false); - // } else { - // setMessageType('error'); - // setMessageData('Stock Not Available'); - // setQuantity(''); - // } - // } - // else { - // if ( - // isItemInCart && - // BookingTypeProd === 'Dine In' && - // OrderType != 'Hold' - // ) { - // const UpdatedCartItem = createUpdatedCartItem( - // isItemInCart, - // Quantity, - // NewPrice - // ); - // const Cartdata = MergecardItem( - // UpdatedCartItem, - // BillOrderPre, - // OtherorderDataforNormal - // ); - // await dispatch(changeOrderCardDetails(Cartdata)); - // if (OfferCheckedInSetup && preferenceOffer) { - // await applyOffer(Cartdata); - // } else { - // dispatch(changeOrderCardDetails(Cartdata)); - // } - // } - // props.handleEditQuantityCancel(); - // setClearQuantity(false); - // } - // } - // } - // }; const CloseModal = () => { props.handleEditQuantityCancel(); setClearQuantity(false); @@ -3656,19 +3393,19 @@ const BSBillingEditQuantity = (props) => { const enteredDiscount = parseFloat(data?.target.value); if (limit === null || limit === undefined || limit === 0) { - if ( - parseFloat(enteredDiscount) < parseFloat(sellingPrice) || - parseFloat(enteredDiscount) === parseFloat(sellingPrice) - ) { + // if ( + // parseFloat(enteredDiscount) < parseFloat(sellingPrice) || + // parseFloat(enteredDiscount) === parseFloat(sellingPrice) + // ) { setEditedPrice(enteredDiscount); setDisableSubmitButton(true); - } else { - setMessageType('error'); - setMessageData('Please Give less than value for sell price'); - setDisableSubmitButton(false); - setEditedPrice(0); - formRef.current?.resetFields(); - } + // } else { + // setMessageType('error'); + // setMessageData('Please Give less than value for sell price'); + // setDisableSubmitButton(false); + // setEditedPrice(0); + // formRef.current?.resetFields(); + // } return; } @@ -3706,6 +3443,33 @@ const BSBillingEditQuantity = (props) => { setPackageDtl(data || []); }; + const handleWeightCalculation = async (data) => { + const { price, quantity } = data; + setQuantity(quantity); + setEditedPrice(price); + await handleWeightSubmit(quantity, price); + }; + + const handleWeightSubmit = async (qty, price) => { + await dispatch(changeHoldOrderDtl(false)); + await dispatch(changePreviousOrderLength(CartOrderDetails?.length)); + let localId = props.Index; + let editedProductIndex = CartOrderDetails?.findIndex( + (e) => e?.localId == localId + ); + const editedProduct = { + ...CartOrderDetails[editedProductIndex], + OrderQty: qty + }; + + await handleEditQuantity(editedProduct, editedProductIndex, editedProduct.OrderRate, qty); + props.handleEditQuantityCancel(); + setClearQuantity(false); + }; + const isKg = + props?.Productdata?.Size == 1 && + ["KG", "KGS"].includes(props?.Productdata?.UomName?.toUpperCase()); + return (
{ > Packing + + {isKg && ()} +
{RadioBtnSelection == 'Quantity' && ( @@ -4007,6 +3784,15 @@ const BSBillingEditQuantity = (props) => { /> )} + {RadioBtnSelection == 'weightAmount' && ( + <> + + + )}
{((RadioBtnSelection == 'Price' && disableSubmitButton) || RadioBtnSelection == 'Quantity') && ( diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingEditQuantity/WeightCalculatePrice.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingEditQuantity/WeightCalculatePrice.jsx new file mode 100644 index 0000000..c646c5e --- /dev/null +++ b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingEditQuantity/WeightCalculatePrice.jsx @@ -0,0 +1,169 @@ +import { useState, useEffect, useRef } from 'react'; +import { InputField } from '../../../../../Components/Forms/InputField.jsx'; +import { Form, Radio } from 'antd'; +import Buttons from '../../../../../Components/Forms/Buttons.jsx'; +import { ArrowRightOutlined } from '@ant-design/icons'; +import "./WeightCalculatePrice.scss" + +const WeightCalculatePrice = ({ itemData, CartOrderDetails, onSubmit }) => { + const [enteredPrice, setEnteredPrice] = useState(''); + const [enteredQty, setEnteredQty] = useState(''); + const [calculatedQty, setCalculatedQty] = useState(0); + const [calcMode, setCalcMode] = useState('kgs'); + + const priceInputRef = useRef(null); + const [form] = Form.useForm(); + + const basePrice = parseFloat( + itemData?.OrderRate || itemData?.SellingPrice || 0 + ); + + // Auto focus input + useEffect(() => { + setTimeout(() => { + const input = priceInputRef.current?.querySelector('input'); + if (input) input.focus(); + }, 100); + }, [calcMode]); + + // AMT → calculate QTY + const handlePriceChange = (e) => { + const value = e.target.value; + setEnteredPrice(value); + + if (value && basePrice > 0) { + const qty = parseFloat(value) / basePrice; + setCalculatedQty(qty); + } else { + setCalculatedQty(0); + } + }; + + // KGS → calculate AMT + const handleQtyChange = (e) => { + const value = e.target.value; + setEnteredQty(value); + + if (value && basePrice > 0) { + const qty = parseFloat(value); + const price = qty * basePrice; + setEnteredPrice(price.toFixed(2)); + setCalculatedQty(qty); + } else { + setEnteredPrice(''); + setCalculatedQty(0); + } + }; + + const handleSubmit = (e) => { + if (e && e.preventDefault) e.preventDefault(); + + if (calculatedQty > 0 && enteredPrice > 0) { + onSubmit?.({ + price: parseFloat(enteredPrice), + quantity: parseFloat(calculatedQty), + }); + } + }; + + return ( +
+
+ {/* MODE SELECTION */} +
+
+ { + setCalcMode(e.target.value); + setEnteredPrice(''); + setEnteredQty(''); + setCalculatedQty(0); + form.resetFields(); + }} + > + KGS + AMT + + +

+ Base Price: ₹{basePrice.toFixed(2)} per{' '} + {itemData?.UomName || 'unit'} +

+
+
+ + {/* AMOUNT INPUT */} + {calcMode === 'amt' && ( + + { + e.target.value = e.target.value.replace(/[^0-9.]/g, ''); + }} + /> + + )} + + {/* QUANTITY INPUT */} + {calcMode === 'kgs' && ( + + { + e.target.value = e.target.value.replace(/[^0-9.]/g, ''); + }} + /> + + )} +
+
+ + + {calculatedQty > 0 ? calculatedQty.toFixed(3) : '0.000'}{' '} + {itemData?.UomName || 'units'} + +
+ + {enteredPrice > 0 && ( +
+ + ₹{parseFloat(enteredPrice).toFixed(2)} +
+ )} +
+
+ } + /> +
+
+
+ ); +}; + +export default WeightCalculatePrice; diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingEditQuantity/WeightCalculatePrice.scss b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingEditQuantity/WeightCalculatePrice.scss new file mode 100644 index 0000000..5f7b2dd --- /dev/null +++ b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingEditQuantity/WeightCalculatePrice.scss @@ -0,0 +1,9 @@ +.productils { + margin: 10px 0; +} + +.weightCalBTN { + width: 100%; + display: flex; + justify-content: flex-end; +} \ No newline at end of file diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable1/BSBillingTable1.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable1/BSBillingTable1.jsx index bb0030b..a61f899 100644 --- a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable1/BSBillingTable1.jsx +++ b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable1/BSBillingTable1.jsx @@ -274,21 +274,49 @@ const BSBillingTable1 = () => { setshortKeyMethod(method); }; + // const handleKeyDown = (event) => { + // if (!event.ctrlKey) return; + + // const key = event.key.toLowerCase(); + + // if (key === 'q') { + // event.preventDefault(); + // handleShortcut('qty'); + // } + + // if (key === 'e') { + // event.preventDefault(); + // handleShortcut('price'); + // } + // }; const handleKeyDown = (event) => { - if (!event.ctrlKey) return; + const key = event.key.toLowerCase(); + // 👉 ALT + P → Open Edit Total Amount + if (event.altKey && key === 'p') { + event.preventDefault(); + if (tableData?.length > 0) { + OpenEditTotalAmount(); + } + return; + } + // 👉 CTRL shortcuts + if (!event.ctrlKey) return; - const key = event.key.toLowerCase(); - - if (key === 'q') { + if (key === 'q') { event.preventDefault(); handleShortcut('qty'); - } - - if (key === 'e') { + } else if (key === 'e') { event.preventDefault(); handleShortcut('price'); + } else if (key === 'y') { + event.preventDefault(); + handleShortcut('Parcel'); + } else if (key === 'b') { + event.preventDefault(); + handleShortcut('weightAmount'); } - }; + + }; window.addEventListener('keydown', handleKeyDown); return () => { diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable1/BST1Payment.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable1/BST1Payment.jsx index 21270cd..d7fba48 100644 --- a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable1/BST1Payment.jsx +++ b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable1/BST1Payment.jsx @@ -505,7 +505,8 @@ export default function BST1Payment() { useEffect(() => { if (!preOrder) { const totalSum = OrderCardDetail?.reduce( - (acc, card) => acc + parseFloat(card.OrderRate * card.OrderQty || 0), + // (acc, card) => acc + parseFloat(card.OrderRate * card.OrderQty || 0), + (acc, card) => acc + parseFloat(card.TotalAmt || 0), 0 ); @@ -1994,7 +1995,8 @@ export default function BST1Payment() { Type: a.Type, OrderQty: a.OrderQty, OrderRate: a.OrderRate, - TotalAmt: a.OrderQty * a.OrderRate, + // TotalAmt: a.OrderQty * a.OrderRate, + TotalAmt: a.TotalAmt, TaxAmt: a.TaxAmt, RefundQty: 0, InwardDtlId: a.InwardDtlId, diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable2/BSBillingTable2.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable2/BSBillingTable2.jsx index 6ab8ec1..f6d92d8 100644 --- a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable2/BSBillingTable2.jsx +++ b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable2/BSBillingTable2.jsx @@ -539,7 +539,8 @@ const BSBillingTable2 = () => { useEffect(() => { if (!preOrder) { const totalSum = OrderCardDetail?.reduce( - (acc, card) => acc + parseFloat(card.OrderRate * card.OrderQty || 0), + // (acc, card) => acc + parseFloat(card.OrderRate * card.OrderQty || 0), + (acc, card) => acc + parseFloat(card.TotalAmt || 0), 0 ); @@ -2034,7 +2035,8 @@ const BSBillingTable2 = () => { Type: a.Type, OrderQty: a.OrderQty, OrderRate: a.OrderRate, - TotalAmt: a.OrderQty * a.OrderRate, + // TotalAmt: a.OrderQty * a.OrderRate, + TotalAmt: a.TotalAmt, TaxAmt: a.TaxAmt, RefundQty: 0, InwardDtlId: a.InwardDtlId, diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable3/BSBillingTable3.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable3/BSBillingTable3.jsx index 0e4f8df..5af7c1e 100644 --- a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable3/BSBillingTable3.jsx +++ b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable3/BSBillingTable3.jsx @@ -228,22 +228,34 @@ const BSBillingTable3 = () => { handleEditQuantity(item); setshortKeyMethod(method); }; + const handleKeyDown = (event) => { + const key = event.key.toLowerCase(); + // 👉 ALT + P → Open Edit Total Amount + if (event.altKey && key === 'p') { + event.preventDefault(); + if (tableData?.length > 0) { + OpenEditTotalAmount(); + } + return; + } + // 👉 CTRL shortcuts + if (!event.ctrlKey) return; - const handleKeyDown = (event) => { - if (!event.ctrlKey) return; - - const key = event.key.toLowerCase(); - - if (key === 'q') { + if (key === 'q') { event.preventDefault(); handleShortcut('qty'); - } - - if (key === 'e') { + } else if (key === 'e') { event.preventDefault(); handleShortcut('price'); + } else if (key === 'y') { + event.preventDefault(); + handleShortcut('Parcel'); + } else if (key === 'b') { + event.preventDefault(); + handleShortcut('weightAmount'); } - }; + + }; window.addEventListener('keydown', handleKeyDown); return () => { diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable3/BSBillingTable3pay.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable3/BSBillingTable3pay.jsx index 75d52dc..116745e 100644 --- a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable3/BSBillingTable3pay.jsx +++ b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable3/BSBillingTable3pay.jsx @@ -534,7 +534,8 @@ const BSBillingTable3Pay = () => { useEffect(() => { if (!preOrder) { const totalSum = OrderCardDetail?.reduce( - (acc, card) => acc + parseFloat(card.OrderRate * card.OrderQty || 0), + // (acc, card) => acc + parseFloat(card.OrderRate * card.OrderQty || 0), //sree + (acc, card) => acc + parseFloat(card.TotalAmt || 0), 0 ); @@ -2180,7 +2181,8 @@ const BSBillingTable3Pay = () => { Type: a.Type, OrderQty: a.OrderQty, OrderRate: a.OrderRate, - TotalAmt: a.OrderQty * a.OrderRate, + // TotalAmt: a.OrderQty * a.OrderRate, //sri + TotalAmt: a.TotalAmt, TaxAmt: a.TaxAmt, RefundQty: 0, InwardDtlId: a.InwardDtlId, diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable4/BSBilling4Payment.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable4/BSBilling4Payment.jsx index cf0e76f..9cee205 100644 --- a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable4/BSBilling4Payment.jsx +++ b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable4/BSBilling4Payment.jsx @@ -591,7 +591,8 @@ const BSBilling4Payment = () => { useEffect(() => { if (!preOrder) { const totalSum = OrderCardDetail?.reduce( - (acc, card) => acc + parseFloat(card.OrderRate * card.OrderQty || 0), + // (acc, card) => acc + parseFloat(card.OrderRate * card.OrderQty || 0), + (acc, card) => acc + parseFloat(card.TotalAmt || 0), 0 ); @@ -2062,7 +2063,8 @@ const BSBilling4Payment = () => { Type: a.Type, OrderQty: a.OrderQty, OrderRate: a.OrderRate, - TotalAmt: a.OrderQty * a.OrderRate, + // TotalAmt: a.OrderQty * a.OrderRate, + TotalAmt: a.TotalAmt, TaxAmt: a.TaxAmt, RefundQty: 0, InwardDtlId: a.InwardDtlId, diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable4/BSBillingTable4.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable4/BSBillingTable4.jsx index 29fb64e..f43aa0b 100644 --- a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable4/BSBillingTable4.jsx +++ b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable4/BSBillingTable4.jsx @@ -281,22 +281,34 @@ const BSBillingTable4 = () => { setshortKeyMethod(method); }; - const handleKeyDown = (event) => { - if (!preferenceshortcutkey) return; - if (!event.ctrlKey) return; + const handleKeyDown = (event) => { + const key = event.key.toLowerCase(); + // 👉 ALT + P → Open Edit Total Amount + if (event.altKey && key === 'p') { + event.preventDefault(); + if (tableData?.length > 0) { + OpenEditTotalAmount(); + } + return; + } + // 👉 CTRL shortcuts + if (!event.ctrlKey) return; - const key = event.key.toLowerCase(); - - if (key === 'q') { + if (key === 'q') { event.preventDefault(); handleShortcut('qty'); - } - - if (key === 'e') { + } else if (key === 'e') { event.preventDefault(); handleShortcut('price'); + } else if (key === 'y') { + event.preventDefault(); + handleShortcut('Parcel'); + } else if (key === 'b') { + event.preventDefault(); + handleShortcut('weightAmount'); } - }; + + }; window.addEventListener('keydown', handleKeyDown); diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable5/BSBillingTable5.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable5/BSBillingTable5.jsx index a126a4f..c4ee9cb 100644 --- a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable5/BSBillingTable5.jsx +++ b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable5/BSBillingTable5.jsx @@ -579,7 +579,8 @@ const BSBillingTable5 = () => { useEffect(() => { if (!preOrder) { const totalSum = OrderCardDetail?.reduce( - (acc, card) => acc + parseFloat(card.OrderRate * card.OrderQty || 0), + // (acc, card) => acc + parseFloat(card.OrderRate * card.OrderQty || 0), + (acc, card) => acc + parseFloat(card.TotalAmt || 0), 0 ); @@ -2077,7 +2078,8 @@ const BSBillingTable5 = () => { Type: a.Type, OrderQty: a.OrderQty, OrderRate: a.OrderRate, - TotalAmt: a.OrderQty * a.OrderRate, + // TotalAmt: a.OrderQty * a.OrderRate, + TotalAmt: a.TotalAmt, TaxAmt: a.TaxAmt, RefundQty: 0, InwardDtlId: a.InwardDtlId, diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable5/BsBill.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable5/BsBill.jsx index 1320efe..4e55d96 100644 --- a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable5/BsBill.jsx +++ b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable5/BsBill.jsx @@ -1927,22 +1927,34 @@ const BsBill = () => { setshortKeyMethod(method); }; - const handleKeyDown = (event) => { - if (!preferenceshortcutkey) return; - if (!event.ctrlKey) return; + const handleKeyDown = (event) => { + const key = event.key.toLowerCase(); + // 👉 ALT + P → Open Edit Total Amount + if (event.altKey && key === 'p') { + event.preventDefault(); + if (TableData?.length > 0) { + OpenEditTotalAmount(); + } + return; + } + // 👉 CTRL shortcuts + if (!event.ctrlKey) return; - const key = event.key.toLowerCase(); - - if (key === 'q') { + if (key === 'q') { event.preventDefault(); handleShortcut('qty'); - } - - if (key === 'e') { + } else if (key === 'e') { event.preventDefault(); handleShortcut('price'); + } else if (key === 'y') { + event.preventDefault(); + handleShortcut('Parcel'); + } else if (key === 'b') { + event.preventDefault(); + handleShortcut('weightAmount'); } - }; + + }; window.addEventListener('keydown', handleKeyDown); return () => { diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable6/BSBillingTable6.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable6/BSBillingTable6.jsx index 442f9aa..5433a60 100644 --- a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable6/BSBillingTable6.jsx +++ b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable6/BSBillingTable6.jsx @@ -255,24 +255,33 @@ const BSBillingTable6 = () => { setshortKeyMethod(method); }; - const handleKeyDown = (event) => { - - if (!preferenceshortcutkey) return - if (!event.ctrlKey) return; - - const key = event.key.toLowerCase(); - - if (key === 'q') { + const handleKeyDown = (event) => { + const key = event.key.toLowerCase(); + // 👉 ALT + P → Open Edit Total Amount + if (event.altKey && key === 'p') { + event.preventDefault(); + if (tableData?.length > 0) { + OpenEditTotalAmount(); + } + return; + } + // 👉 CTRL shortcuts + if (!event.ctrlKey) return; +if (key === 'q') { event.preventDefault(); handleShortcut('qty'); - } - - if (key === 'e') { + } else if (key === 'e') { event.preventDefault(); handleShortcut('price'); + } else if (key === 'y') { + event.preventDefault(); + handleShortcut('Parcel'); + } else if (key === 'b') { + event.preventDefault(); + handleShortcut('weightAmount'); } - }; - + + }; window.addEventListener('keydown', handleKeyDown); return () => { diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable6/BST6Payment.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable6/BST6Payment.jsx index 7d29254..9a02c94 100644 --- a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable6/BST6Payment.jsx +++ b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable6/BST6Payment.jsx @@ -551,7 +551,8 @@ const BST6Payment = () => { useEffect(() => { if (!preOrder) { const totalSum = OrderCardDetail?.reduce( - (acc, card) => acc + parseFloat(card.OrderRate * card.OrderQty || 0), + // (acc, card) => acc + parseFloat(card.OrderRate * card.OrderQty || 0), + (acc, card) => acc + parseFloat(card.TotalAmt || 0), 0 ); @@ -2118,7 +2119,8 @@ const BST6Payment = () => { Type: a.Type, OrderQty: a.OrderQty, OrderRate: a.OrderRate, - TotalAmt: a.OrderQty * a.OrderRate, + // TotalAmt: a.OrderQty * a.OrderRate, + TotalAmt: a.TotalAmt, TaxAmt: a.TaxAmt, RefundQty: 0, InwardDtlId: a.InwardDtlId, diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable7/BSBilling7Payment.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable7/BSBilling7Payment.jsx index 83380f9..f8400af 100644 --- a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable7/BSBilling7Payment.jsx +++ b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable7/BSBilling7Payment.jsx @@ -570,7 +570,8 @@ const BSBilling7Payment = () => { useEffect(() => { if (!preOrder) { const totalSum = OrderCardDetail?.reduce( - (acc, card) => acc + parseFloat(card.OrderRate * card.OrderQty || 0), + // (acc, card) => acc + parseFloat(card.OrderRate * card.OrderQty || 0), + (acc, card) => acc + parseFloat(card.TotalAmt || 0), 0 ); @@ -2086,7 +2087,8 @@ const BSBilling7Payment = () => { Type: a.Type, OrderQty: a.OrderQty, OrderRate: a.OrderRate, - TotalAmt: a.OrderQty * a.OrderRate, + // TotalAmt: a.OrderQty * a.OrderRate, + TotalAmt: a.TotalAmt, TaxAmt: a.TaxAmt, RefundQty: 0, InwardDtlId: a.InwardDtlId, diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable7/BSBillingTable7.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable7/BSBillingTable7.jsx index 0cbda12..406cd6b 100644 --- a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable7/BSBillingTable7.jsx +++ b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable7/BSBillingTable7.jsx @@ -225,35 +225,6 @@ const BSBillingTable7 = () => { setPreviousdataLength(PreviousOrderLength); }, [PreviousOrderLength]); - // useEffect(() => { - // const handleKeyDown = (event) => { - // // Ctrl + Q - // if (event.ctrlKey && event.key.toLowerCase() === 'q') { - // event.preventDefault(); - - // const getItem = (data = []) => { - // if (!data.length) return null; - // return BillOrderPre === 'Y' ? data[0] : data[data.length - 1]; - // }; - - // let item = null; - // if (tableDataTakeAway?.length > 0) { - // item = getItem(tableDataTakeAway); - // } else if (tableDataDinein?.length > 0) { - // item = getItem(tableDataDinein); - // } - // if (item) { - // handleEditQuantity(item); - // } - // } - // }; - // window.addEventListener('keydown', handleKeyDown); - - // return () => { - // window.removeEventListener('keydown', handleKeyDown); - // }; - // }, [tableDataTakeAway, tableDataDinein, BillOrderPre]); - useEffect(() => { if (!preferenceshortcutkey) return; const getSelectedItem = () => { @@ -279,21 +250,31 @@ const BSBillingTable7 = () => { }; const handleKeyDown = (event) => { - if (!preferenceshortcutkey) return; - if (!event.ctrlKey) return; - - const key = event.key.toLowerCase(); - - if (key === 'q') { + const key = event.key.toLowerCase(); + // 👉 ALT + P → Open Edit Total Amount + if (event.altKey && key === 'p') { + event.preventDefault(); + if (tableData?.length > 0) { + OpenEditTotalAmount(); + } + return; + } + if (!event.ctrlKey) return; + if (key === 'q') { event.preventDefault(); handleShortcut('qty'); - } - - if (key === 'e') { + } else if (key === 'e') { event.preventDefault(); handleShortcut('price'); + } else if (key === 'y') { + event.preventDefault(); + handleShortcut('Parcel'); + } else if (key === 'b') { + event.preventDefault(); + handleShortcut('weightAmount'); } - }; + + }; window.addEventListener('keydown', handleKeyDown); return () => { diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/BSEditTotalAmount/BSEditTotalAmt.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/BSEditTotalAmount/BSEditTotalAmt.jsx index 049f2e9..431dab8 100644 --- a/src/Pages/BookingScreen/Components/BSBillingTables/BSEditTotalAmount/BSEditTotalAmt.jsx +++ b/src/Pages/BookingScreen/Components/BSBillingTables/BSEditTotalAmount/BSEditTotalAmt.jsx @@ -38,6 +38,10 @@ const BSEditTotalAmt = (props) => { console.log(OverAllSales, 'OverAllEstimateOverAllEstimate'); const formRef = useRef(null); const formEstRef = useRef(null); + const salesDiscInputRef = useRef(null); + const salesMoreOptInputRef = useRef(null); + const estDiscInputRef = useRef(null); + const estMoreOptInputRef = useRef(null); const dispatch = useDispatch(); const [messageType, setMessageType] = useState(null); const [messageData, setMessageData] = useState(null); @@ -87,6 +91,29 @@ const BSEditTotalAmt = (props) => { return () => clearInterval(timer); }, [timeLeft]); + useEffect(() => { + const focusInput = (ref) => { + setTimeout(() => { + const inputElement = ref.current?.querySelector('input'); + inputElement?.focus(); + }, 100); + }; + + if (SalesData?.length > 0) { + if (MoreOpt) { + focusInput(salesMoreOptInputRef); + } else if (EditTotalAmt) { + focusInput(salesDiscInputRef); + } + } else if (EstimateData?.length > 0 && EditTotalAmt) { + if (ESTMoreOpt) { + focusInput(estMoreOptInputRef); + } else { + focusInput(estDiscInputRef); + } + } + }, [EditTotalAmt, MoreOpt, ESTMoreOpt, SalesData, EstimateData]); + const handleOtpChange = (index, value) => { // Allow empty value for clearing if (value === '' || value.match(/^[0-9]$/)) { @@ -201,6 +228,10 @@ const BSEditTotalAmt = (props) => { setMessageData('Please Give less than value for sell price'); setESTSellingPrice(0); formEstRef?.current?.resetFields(); + setTimeout(() => { + const inputElement = estDiscInputRef.current?.querySelector('input'); + inputElement?.focus(); + }, 100); } else { setESTSellingPrice(inputValue); // Check if entered amount is 0 or equals total amount @@ -214,6 +245,13 @@ const BSEditTotalAmt = (props) => { handleOk(); } }; + + const handleEstKeyDown = (e) => { + if (e.key === 'Enter') { + e.preventDefault(); + SetTotalDiscount(); + } + }; const SalesChangefun = (e) => { const inputValue = e.target.value.trim(); console.log(e, e.target.value, 'SalesChangefun'); @@ -223,6 +261,10 @@ const BSEditTotalAmt = (props) => { setMessageData('Please Give less than value for sell price'); setSellingPrice(0); formRef?.current?.resetFields(); + setTimeout(() => { + const inputElement = salesDiscInputRef.current?.querySelector('input'); + inputElement?.focus(); + }, 100); } else { setSellingPrice(inputValue); // SalesTotalAmount() @@ -232,6 +274,13 @@ const BSEditTotalAmt = (props) => { // setSalesDiscAmount(0) } }; + + const handleSalesKeyDown = (e) => { + if (e.key === 'Enter') { + e.preventDefault(); + SetTotalDiscount(); + } + }; const orderscolumns = [ { title: 'Sl.No', @@ -347,6 +396,10 @@ const BSEditTotalAmt = (props) => { setSalesDiscAmount(0); // setFinalTotalAmt() formRef.current?.resetFields(); + setTimeout(() => { + const inputElement = salesMoreOptInputRef.current?.querySelector('input'); + inputElement?.focus(); + }, 100); }; const onEstPercentageSelectionChange = (data) => { setESTPercentageSelection(data); @@ -354,6 +407,10 @@ const BSEditTotalAmt = (props) => { setEstDiscAmount(0); // setFinalTotalAmt() formEstRef.current?.resetFields(); + setTimeout(() => { + const inputElement = estMoreOptInputRef.current?.querySelector('input'); + inputElement?.focus(); + }, 100); }; const PriceChangefun = (data) => { @@ -375,6 +432,10 @@ const BSEditTotalAmt = (props) => { setSalesDiscAmount(0); // setNewPrice1(0) formRef.current?.resetFields(); + setTimeout(() => { + const inputElement = salesMoreOptInputRef.current?.querySelector('input'); + inputElement?.focus(); + }, 100); } } else { // Percentage mode @@ -391,6 +452,10 @@ const BSEditTotalAmt = (props) => { setMessageData('Please Give less than or equal to 100'); setSalesDiscAmount(0); formRef.current?.resetFields(); + setTimeout(() => { + const inputElement = salesMoreOptInputRef.current?.querySelector('input'); + inputElement?.focus(); + }, 100); } } } else { @@ -400,6 +465,13 @@ const BSEditTotalAmt = (props) => { } }; + const handlePriceKeyDown = (e) => { + if (e.key === 'Enter') { + e.preventDefault(); + SetTotalDiscount(); + } + }; + const PriceChangefunEst = (data) => { console.log(data?.target.value, PercentageSelection, 'datadata'); if (data?.target.value) { @@ -418,6 +490,10 @@ const BSEditTotalAmt = (props) => { setMessageData('Please Give less than value for sell price'); setEstDiscAmount(0); formEstRef.current?.resetFields(); + setTimeout(() => { + const inputElement = estMoreOptInputRef.current?.querySelector('input'); + inputElement?.focus(); + }, 100); } } else { // Percentage mode @@ -434,6 +510,10 @@ const BSEditTotalAmt = (props) => { setMessageData('Please Give less than or equal to 100'); setEstDiscAmount(0); formEstRef.current?.resetFields(); + setTimeout(() => { + const inputElement = estMoreOptInputRef.current?.querySelector('input'); + inputElement?.focus(); + }, 100); } } } else { @@ -444,6 +524,13 @@ const BSEditTotalAmt = (props) => { } }; + const handlePriceEstKeyDown = (e) => { + if (e.key === 'Enter') { + e.preventDefault(); + SetTotalDiscount(); + } + }; + const moreOptions = () => { setMoreOpt((prev) => !prev); setSalesDiscAmount(0); @@ -535,15 +622,18 @@ const BSEditTotalAmt = (props) => { }, ]} > - SalesChangefun(e)} - maxLength={8} - /> +
+ SalesChangefun(e)} + onKeyDown={(e) => handleSalesKeyDown(e)} + maxLength={8} + /> +
{' '} @@ -593,18 +683,21 @@ const BSEditTotalAmt = (props) => { }, ]} > - PriceChangefun(e)} - // isOnChange={formType == "edit" || formRef.current?.getFieldsValue()?.CustName ? true : false} - /> +
+ PriceChangefun(e)} + onKeyDown={(e) => handlePriceKeyDown(e)} + // isOnChange={formType == "edit" || formRef.current?.getFieldsValue()?.CustName ? true : false} + /> +
{/* PriceChangefun(e)} @@ -684,16 +777,19 @@ const BSEditTotalAmt = (props) => { }, ]} > - EstChangefun(e)} - maxLength={8} - /> +
+ EstChangefun(e)} + onKeyDown={(e) => handleEstKeyDown(e)} + maxLength={8} + /> +
@@ -742,18 +838,21 @@ const BSEditTotalAmt = (props) => { }, ]} > - PriceChangefunEst(e)} - // isOnChange={formType == "edit" || formRef.current?.getFieldsValue()?.CustName ? true : false} - /> +
+ PriceChangefunEst(e)} + onKeyDown={(e) => handlePriceEstKeyDown(e)} + // isOnChange={formType == "edit" || formRef.current?.getFieldsValue()?.CustName ? true : false} + /> +
{/* PriceChangefun(e)} diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/ComboSalesBillTable/ComboSalesBillTable.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/ComboSalesBillTable/ComboSalesBillTable.jsx index 91e2bff..5fd5dd8 100644 --- a/src/Pages/BookingScreen/Components/BSBillingTables/ComboSalesBillTable/ComboSalesBillTable.jsx +++ b/src/Pages/BookingScreen/Components/BSBillingTables/ComboSalesBillTable/ComboSalesBillTable.jsx @@ -148,13 +148,13 @@ const ComboSalesBillTable = () => { OrderType === 'Hold' ? tableData?.filter((a, b) => a.BookingTypeName === 'TakeAway') : tableData?.filter( - (a, b) => a.BookingTypeName === 'TakeAway' && !a?.SalesId - ); + (a, b) => a.BookingTypeName === 'TakeAway' && !a?.SalesId + ); const OldtableDataTakeAway = OrderType != 'Hold' ? tableData?.filter( - (a, b) => a.BookingTypeName === 'TakeAway' && a?.SalesId - ) + (a, b) => a.BookingTypeName === 'TakeAway' && a?.SalesId + ) : []; const [EditQuantity, setEditQuantity] = useState(false); @@ -249,27 +249,59 @@ const ComboSalesBillTable = () => { // ); // setBillOrderPre(BillOrder?.SettingValue); // }, [preferenceDatas]); - useEffect(() => { - const handleKeyDown = (event) => { - if (event.ctrlKey && event.key.toLowerCase() === 'q') { - event.preventDefault(); - const getItem = (data = []) => { - if (!data.length) return null; - return BillOrderPre === 'Y' ? data[0] : data[data.length - 1]; - }; - let item = null; - if (tableDataTakeAway?.length > 0) { - item = getItem(tableDataTakeAway); - } else if (tableDataDinein?.length > 0) { - item = getItem(tableDataDinein); - } - if (item) { - handleEditQuantity(item); - } + const getSelectedItem = () => { + const getItem = (data = []) => { + if (!data.length) return null; + return BillOrderPre === 'Y' ? data[0] : data[data.length - 1]; + }; + + if (tableDataTakeAway?.length > 0) { + return getItem(tableDataTakeAway); + } else if (tableDataDinein?.length > 0) { + return getItem(tableDataDinein); } + return null; + }; + + const handleShortcut = (method) => { + const item = getSelectedItem(); + if (!item) return; + + handleEditQuantity(item); + setshortKeyMethod(method); + }; + + const handleKeyDown = (event) => { + const key = event.key.toLowerCase(); + // 👉 ALT + P → Open Edit Total Amount + if (event.altKey && key === 'p') { + event.preventDefault(); + if (tableData?.length > 0) { + OpenEditTotalAmount(); + } + return; + } + // 👉 CTRL shortcuts + if (!event.ctrlKey) return; + + if (key === 'q') { + event.preventDefault(); + handleShortcut('qty'); + } else if (key === 'e') { + event.preventDefault(); + handleShortcut('price'); + } else if (key === 'y') { + event.preventDefault(); + handleShortcut('Parcel'); + } else if (key === 'b') { + event.preventDefault(); + handleShortcut('weightAmount'); + } + }; window.addEventListener('keydown', handleKeyDown); + return () => { window.removeEventListener('keydown', handleKeyDown); }; @@ -1122,9 +1154,9 @@ const ComboSalesBillTable = () => { )?.map((item, idx) => idx === 0 ? { - ...item, - FreeQty, - } + ...item, + FreeQty, + } : item ), }; @@ -2246,20 +2278,20 @@ const ComboSalesBillTable = () => { tableDataDinein?.length >= PreviousdataLength ? 'wheat' : BookingType !== 'Dine In' && - triggerAnimation && - OldtableDataTakeAway?.length + index === 0 && - tableDataDinein?.length >= PreviousdataLength && - !HoldOrderDtl && - !UnpaidData + triggerAnimation && + OldtableDataTakeAway?.length + index === 0 && + tableDataDinein?.length >= PreviousdataLength && + !HoldOrderDtl && + !UnpaidData ? 'wheat' : 'inherit' : 'none', background: row?.SalesId ? 'rgb(243, 248, 213)' : GlobEstBooking === 'ParEst' && - GlobProdwisedata?.includes( - row?.InwardDtlId + ' ' + row?.BookingTypeName - ) + GlobProdwisedata?.includes( + row?.InwardDtlId + ' ' + row?.BookingTypeName + ) ? '#b2d1f7' : (OldtableDataTakeAway?.length + index) % 2 === 0 ? 'white' @@ -2294,37 +2326,37 @@ const ComboSalesBillTable = () => { {/* Product Name / Item */} {(item.OptionName === 'Item' || item.OptionName === 'Product Name') && ( - - row.FullProductIdentifierDtls?.length > 0 || - row.ProductIdentifierDtls?.length > 0 - ? handleImeiDetails(row) - : editField && handleEditQuantity(row) - } - > - {row?.Type !== 'OS' ? row.ProdName : row.ServiceName} - {row?.BrandName ? ` ${row.BrandName}` : ''} - {row?.Type !== 'C' && ( -

- {/* {row?.ProdVariantName} {row?.Size} {row?.UomName} */} - ( - {!row?.ProdVariantName?.toLowerCase()?.includes( - 'variant' - ) && {row?.ProdVariantName} } - {row?.Size} - {row?.SinglePc == 'Y' ? 'PCS' : row?.UomName}) -

- )} - {row?.Type === 'C' && - row.ProdDetail?.map((prod, idx) => ( -

- {prod.ProdName} - {prod.Size} {prod.UomName} + + row.FullProductIdentifierDtls?.length > 0 || + row.ProductIdentifierDtls?.length > 0 + ? handleImeiDetails(row) + : editField && handleEditQuantity(row) + } + > + {row?.Type !== 'OS' ? row.ProdName : row.ServiceName} + {row?.BrandName ? ` ${row.BrandName}` : ''} + {row?.Type !== 'C' && ( +

+ {/* {row?.ProdVariantName} {row?.Size} {row?.UomName} */} + ( + {!row?.ProdVariantName?.toLowerCase()?.includes( + 'variant' + ) && {row?.ProdVariantName} } + {row?.Size} + {row?.SinglePc == 'Y' ? 'PCS' : row?.UomName})

- ))} - - )} + )} + {row?.Type === 'C' && + row.ProdDetail?.map((prod, idx) => ( +

+ {prod.ProdName} - {prod.Size} {prod.UomName} +

+ ))} + + )} {/* Barcode */} {item.OptionName === 'Barcode' && ( @@ -2351,7 +2383,7 @@ const ComboSalesBillTable = () => { onClick={() => editField && handleEditQuantityCombo(row) } - // onClick={() => handleEditQTYcombo()} + // onClick={() => handleEditQTYcombo()} > {(!EditQtyCombo || row?.localId !== Index) && ( <>{row.OrderQty} @@ -2367,7 +2399,7 @@ const ComboSalesBillTable = () => { Index={Index} setIndex={setIndex} setEditQtyCombo={setEditQtyCombo} - // id={`qty-${index}`} + // id={`qty-${index}`} /> )} @@ -2414,9 +2446,9 @@ const ComboSalesBillTable = () => { > {row?.Offer > 0 ? `${( - (row.Offer / (row?.OrderQty * row?.OrderRate)) * - 100 - ).toFixed(2)}%` + (row.Offer / (row?.OrderQty * row?.OrderRate)) * + 100 + ).toFixed(2)}%` : '-'} )} diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/StandardTable/StandardTable.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/StandardTable/StandardTable.jsx index 8136112..c4c9501 100644 --- a/src/Pages/BookingScreen/Components/BSBillingTables/StandardTable/StandardTable.jsx +++ b/src/Pages/BookingScreen/Components/BSBillingTables/StandardTable/StandardTable.jsx @@ -237,7 +237,7 @@ const StandardTable = () => { window.removeEventListener('keydown', handleKeyDown); }; }, [GetCustId, OrderCardDetail]); - + useEffect(() => { if (!preferenceshortcutkey) return; @@ -262,23 +262,40 @@ const StandardTable = () => { handleEditQuantity(item); setshortKeyMethod(method); }; - const handleKeyDown = (event) => { - if (!event.ctrlKey) return; - const key = event.key.toLowerCase(); - + // 👉 ALT + P → Open Edit Total Amount + if (event.altKey && key === 'p') { + event.preventDefault(); + if (OrderCardDetail?.length > 0) { + OpenEditTotalAmount(); + } + return; + } + // 👉 CTRL shortcuts + if (!event.ctrlKey) return; + // if (key === 'q') { + // event.preventDefault(); + // handleShortcut('qty'); + // } + // if (key === 'e') { + // event.preventDefault(); + // handleShortcut('price'); + // } if (key === 'q') { event.preventDefault(); handleShortcut('qty'); - } - - if (key === 'e') { + } else if (key === 'e') { event.preventDefault(); handleShortcut('price'); + } else if (key === 'y') { + event.preventDefault(); + handleShortcut('Parcel'); + } else if (key === 'b') { + event.preventDefault(); + handleShortcut('weightAmount'); } }; - window.addEventListener('keydown', handleKeyDown); return () => { diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/StandardTable/StandardTablePayment.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/StandardTable/StandardTablePayment.jsx index 678f803..1c3f736 100644 --- a/src/Pages/BookingScreen/Components/BSBillingTables/StandardTable/StandardTablePayment.jsx +++ b/src/Pages/BookingScreen/Components/BSBillingTables/StandardTable/StandardTablePayment.jsx @@ -841,7 +841,8 @@ const StandardTablePayment = () => { if (!preOrder) { const totalSum = orderCardDetail?.reduce( - (acc, card) => acc + parseFloat(card.OrderRate * card.OrderQty || 0), + // (acc, card) => acc + parseFloat(card.OrderRate * card.OrderQty || 0), + (acc, card) => acc + parseFloat(card.TotalAmt || 0), 0 ); @@ -1417,7 +1418,8 @@ const StandardTablePayment = () => { Type: a.Type, OrderQty: a.OrderQty, OrderRate: a.OrderRate, - TotalAmt: a.OrderQty * a.OrderRate, + // TotalAmt: a.OrderQty * a.OrderRate, + TotalAmt: a.TotalAmt, TaxAmt: a.TaxAmt, RefundQty: 0, InwardDtlId: a.InwardDtlId, 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 && ( { SelectedGlobalCardColorDetail, shallowEqual ); + const GetmultipleSearchDatas = useSelector(GlobalGetmultipleSearchDatas, shallowEqual) const SelectedCardFont = useSelector(SelectedGlobalCardFont, shallowEqual); const CartOrderDetails = useSelector(GlobalOrderCardDetails, shallowEqual); const SelectedDatas = useSelector(GlobalSelectedDatas, shallowEqual); @@ -244,7 +247,7 @@ const BSComboItemCard = (props) => { const paymentloader = useSelector(GlobalPayementloader, shallowEqual); const SessionData = useSelector(StoredSessionData, shallowEqual); const GlobalCombocarddatas = useSelector(GlobalCombocarddata); -console.log(GlobalCombocarddatas, 'GlobalCombocarddatas combo card'); + console.log(GlobalCombocarddatas, 'GlobalCombocarddatas combo card'); const [messageType, setMessageType] = useState(null); const [messageData, setMessageData] = useState(null); const [repeatedModel, setRepeatedModel] = useState(false); @@ -297,7 +300,7 @@ console.log(GlobalCombocarddatas, 'GlobalCombocarddatas combo card'); : GlobalCombocarddatas : ''; // -console.log(cardData, 'cardData combo card'); + console.log(cardData, 'cardData combo card'); useEffect(() => { // fetchedit(); getPreferenceStock(); @@ -307,10 +310,25 @@ console.log(cardData, 'cardData combo card'); useEffect(() => { if (AppId && CompId && BranchId) { fetchedit(); + GetmultipleSearchData() } // dispatch(changepreOrder(false)); Commented to Add Normal Produts After Adding the Combo Pack !!!!!! Dont Touch Without Shifayath Permission }, [AppId, CompId, BranchId]); + const GetmultipleSearchData = async () => { + const data = { + AppId, + CompId, + BranchId, + }; + + try { + const response = await dispatch(getmultipleSearch(data)) + + } catch (error) { + console.error("Get Search Terms Error:", error); + } + }; useEffect(() => { setPreOrderSelectedProdNames([]); @@ -328,10 +346,13 @@ console.log(cardData, 'cardData combo card'); if (noSubcatCardData) { setNoSubcatCardData(); } - if (ProductSearch?.length > 5) { + + if (ProductSearch?.length > 5 && GetmultipleSearchDatas.some( + e => e.toLowerCase() === "qrcode" +)) { setQuickAdd(true); } - }, [ProductSearch]); + }, [ProductSearch,GetmultipleSearchDatas]); // useEffect(() => { // if ( @@ -4620,7 +4641,9 @@ console.log(cardData, 'cardData combo card'); - ) : ProductSearch?.length > 5 && + ) : ProductSearch?.length > 5 && GetmultipleSearchDatas.some( + e => e.toLowerCase() === "qrcode" +) && (cardData?.length == 0 || cardData == undefined) ? (
{/* cardData mohan 18-04-2025 */} @@ -4632,7 +4655,7 @@ console.log(cardData, 'cardData combo card'); cardData={cardDataForNewPrd} />
- ) : ( + ) : ( <>
{ 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); @@ -244,6 +238,7 @@ const BSItemCard = (props) => { SelectedGlobalCardColorDetail, shallowEqual ); + const GetmultipleSearchDatas = useSelector(GlobalGetmultipleSearchDatas, shallowEqual) const SelectedCardFont = useSelector(SelectedGlobalCardFont, shallowEqual); const CartOrderDetails = useSelector(GlobalOrderCardDetails, shallowEqual); const SelectedDatas = useSelector(GlobalSelectedDatas, shallowEqual); @@ -251,6 +246,7 @@ const BSItemCard = (props) => { const WSProductdata = useSelector(GlobalWSProduct, shallowEqual); const NewQrProductData = useSelector(GlobalNewQrProduct, shallowEqual); const ReportholdData = useSelector(GlobalReorderHoldDetails, shallowEqual); + console.log(GetmultipleSearchDatas, "GetmultipleSearchDatas") const ReorderProductData = useSelector( GlobalReorderProductDetails, shallowEqual @@ -281,12 +277,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 +309,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 +323,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 +614,7 @@ const BSItemCard = (props) => { WithoutTaxRate: availableFreeQty * item.OrderRate - (availableFreeQty * item.OrderRate * item.TaxPercentage) / - 100, + 100, Offer: availableFreeQty * item.OrderRate, }; @@ -662,7 +663,7 @@ const BSItemCard = (props) => { ((existingPaidItem.OrderQty + excessQty) * item.OrderRate * item.TaxPercentage) / - 100, + 100, }; ModifiedData.push(mergedPaidItem); @@ -697,7 +698,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 +718,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 +748,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 +931,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 +951,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 +974,7 @@ const BSItemCard = (props) => { if (TableName === 'BuyXGetXOffers') return true; } ); - setfreeProductsOffers(filteredOffers); + // setfreeProductsOffers(filteredOffers); getOffers(); }, [OrderOfferDetail]); @@ -978,12 +988,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 +997,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 : ''; @@ -1025,10 +1030,27 @@ const BSItemCard = (props) => { useEffect(() => { if (AppId && CompId && BranchId) { fetchedit(); + GetmultipleSearchData() } // dispatch(changepreOrder(false)); Commented to Add Normal Produts After Adding the Combo Pack !!!!!! Dont Touch Without Shifayath Permission }, [AppId, CompId, BranchId]); + + const GetmultipleSearchData = async () => { + const data = { + AppId, + CompId, + BranchId, + }; + + try { + const response = await dispatch(getmultipleSearch(data)) + + } catch (error) { + console.error("Get Search Terms Error:", error); + } + }; + useEffect(() => { setPreOrderSelectedProdNames([]); // dispatch(changePreOrderAdditem(null)); @@ -1043,10 +1065,14 @@ const BSItemCard = (props) => { if (noSubcatCardData) { setNoSubcatCardData(); } - if (ProductSearch?.length > 5) { + + if (ProductSearch?.length > 5 && GetmultipleSearchDatas.some( + e => e.toLowerCase() === "qrcode" + )) { setQuickAdd(true); } - }, [ProductSearch]); + }, [ProductSearch, GetmultipleSearchDatas]); + useEffect(() => { if ( !initialRun && @@ -1076,14 +1102,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 +1156,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 +1181,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 +1214,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 +1225,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 +1320,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 +1368,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 +1383,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 +1427,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 +1440,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 +1481,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 +1505,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 +1523,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 +1537,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 +1588,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 +1609,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 +1624,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 +1652,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 +1717,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 +1736,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 +1794,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 +1810,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 +1893,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 +1909,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 +2009,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 +2025,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 +2047,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 +2161,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 +2236,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 +2250,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 +2267,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 +2283,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 +2307,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 +2334,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 +2562,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 +2618,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 +2638,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 +2956,6 @@ const BSItemCard = (props) => { }; }); - console.log(Postdata, 'Postdata'); const response = await dispatch( bulkpostdata({ ProdDetails: Postdata }) ).unwrap(); @@ -3207,10 +3028,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 +3101,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 +3659,7 @@ const BSItemCard = (props) => { parseInt(totalSelectedProductQty || 0) + parseInt(reorderComboConsumed || 0); } - } catch (_) { } + } catch (_) {} let getCurrentProdDtl = orderDetails?.filter( (a) => a?.ProdName === ProdName ); @@ -4039,7 +3860,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 +3896,7 @@ const BSItemCard = (props) => { }, 0); totalOrderQty = parseInt(totalOrderQty || 0) + parseInt(comboConsumed || 0); - } catch (_) { } + } catch (_) {} let OverallProdQty = totalOrderQty - totalSelectedProductQty; if ( parseInt(ItemQuantity) > @@ -4161,7 +3982,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 +4021,7 @@ const BSItemCard = (props) => { }, 0); totalOrderQty = parseInt(totalOrderQty || 0) + parseInt(comboConsumed || 0); - } catch (_) { } + } catch (_) {} let OverallProdQty = totalOrderQty - totalSelectedProductQty; if ( parseInt(ItemQuantity) > @@ -4292,7 +4113,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 +4156,7 @@ const BSItemCard = (props) => { }, 0); totalOrderQty = parseInt(totalOrderQty || 0) + parseInt(comboConsumed || 0); - } catch (_) { } + } catch (_) {} let OverallProdQty = totalOrderQty - totalSelectedProductQty; if ( @@ -4419,7 +4240,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 +4287,7 @@ const BSItemCard = (props) => { }, 0); totalOrderQty = parseInt(totalOrderQty || 0) + parseInt(comboConsumed || 0); - } catch (_) { } + } catch (_) {} let OverallProdQty = totalOrderQty - totalSelectedProductQty; if ( @@ -4644,7 +4465,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 +4495,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 +4525,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 +4700,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 +4732,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 +5124,8 @@ const BSItemCard = (props) => { setVarItem(0); SingleQuantity(item, onePeiceFlow); } - setexpModel(false); + + closeExpireModal(); setProdexpir(true); setQtydata(item); }; @@ -5409,7 +5231,7 @@ const BSItemCard = (props) => { setQtyIndex(selectedProIndex); setRepeatedModel(true); - setExpQtyModel(false); + closeExpireModal() }; const expVerFun = (item) => { @@ -5426,12 +5248,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 +5285,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 +5896,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 +5932,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 +5958,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 +6018,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 +6098,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 +6150,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 +6215,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 +6239,8 @@ const BSItemCard = (props) => { CardOnclick( item, item?.OnePcsAvailable === 'Y' && - preferenceSingleSales && - 'OnePeiceProduct' + preferenceSingleSales && + 'OnePeiceProduct' ); } }} @@ -6437,39 +6249,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 +6315,7 @@ const BSItemCard = (props) => { height: cardFunction?.SmallImage ? '5.5rem' : !cardFunction?.BigImage && - '5.5rem', + '5.5rem', alignItems: !cardFunction?.BigImage && !cardFunction?.SmallImage && @@ -6526,11 +6338,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 +6364,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 +6420,8 @@ const BSItemCard = (props) => { : '', color: SelectedCardColor ? SelectedCardColor?.[ - 'FontColor' - ] + 'FontColor' + ] : '', }} > @@ -6657,19 +6469,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 +6533,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 +6582,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 +6632,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 +6656,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 +6731,7 @@ const BSItemCard = (props) => { height: cardFunction?.SmallImage ? '5.5rem' : !cardFunction?.BigImage && - '4.5rem', + '4.5rem', alignItems: !cardFunction?.BigImage && !cardFunction?.SmallImage && @@ -6939,11 +6751,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 +6777,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 +6833,8 @@ const BSItemCard = (props) => { : '', color: SelectedCardColor ? SelectedCardColor?.[ - 'FontColor' - ] + 'FontColor' + ] : '', }} > @@ -7067,19 +6879,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 +6942,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 +6964,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 +7001,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 +7026,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 +7069,7 @@ const BSItemCard = (props) => { height={60} src={ item?.ProductDetail?.[0]?.ProdLogo === - '' + '' ? defaultimage : item?.ProductDetail?.[0]?.ProdLogo ? item?.ProductDetail?.[0]?.ProdLogo @@ -7272,21 +7084,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 +7164,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 +7223,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', }} @@ -7433,45 +7245,50 @@ const BSItemCard = (props) => { - ) : ProductSearch?.length > 5 && - (cardData?.length == 0 || cardData == undefined) ? ( -
- {/* cardData mohan 18-04-2025 */} - -
- ) : ( - <> -
-
-
-
-
 
-
-
-
 
-
-
-
 
-
-
-
 
+ ) + + + : ProductSearch?.length > 5 && GetmultipleSearchDatas.some( + e => e.toLowerCase() === "qrcode" + ) && + (cardData?.length == 0 || cardData == undefined) ? ( +
+ {/* cardData mohan 18-04-2025 */} + +
+ ) : ( + <> +
+
+
+
+
 
+
+
+
 
+
+
+
 
+
+
+
 
+
-
- - )} + + )} {paymentloader === true && (
@@ -7502,107 +7319,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 +7622,16 @@ const BSItemCard = (props) => { ]?.ProdVariantName?.toLowerCase()?.includes( 'variant' ) && ( - - ( - { - qtydata?.ProductDetail?.[QtyIndex] - ?.ProdVariantDetails?.[VarientIndex] - ?.ProdVariantName - } - ){' '} - - )} + + ( + { + qtydata?.ProductDetail?.[QtyIndex] + ?.ProdVariantDetails?.[VarientIndex] + ?.ProdVariantName + } + ){' '} + + )}

diff --git a/src/Pages/BookingScreen/Components/BSItemCards/BSOtherServiceItemCard.jsx b/src/Pages/BookingScreen/Components/BSItemCards/BSOtherServiceItemCard.jsx index 1a103f7..b2b0f12 100644 --- a/src/Pages/BookingScreen/Components/BSItemCards/BSOtherServiceItemCard.jsx +++ b/src/Pages/BookingScreen/Components/BSItemCards/BSOtherServiceItemCard.jsx @@ -59,6 +59,8 @@ import { changeCardData, GlobaldraggingComponent, GlobalCombocarddata, + GlobalGetmultipleSearchDatas, + getmultipleSearch, } from '../../../../Features/BookingScreen/BookingData/BookingData'; import { GlobalPreOrderAdditem, @@ -92,7 +94,7 @@ import { import { useSortable } from '@dnd-kit/sortable'; import { CSS } from '@dnd-kit/utilities'; import { getCombolist } from '../../../../Features/ComboMaster/ComboMaster.js'; -import {GlobalOtherServicesdata, OtherServicesCardlistdata} from '../../../../Features/OtherServices/OtherServices.js'; +import { GlobalOtherServicesdata, OtherServicesCardlistdata } from '../../../../Features/OtherServices/OtherServices.js'; export function SortableCard({ id, children, item }) { @@ -124,7 +126,7 @@ export function SortableCard({ id, children, item }) { } const BSOtherServiceItemCard = (props) => { - const cardFunction = props.cardFunctionality; + const cardFunction = props.cardFunctionality; const applyOffer = useApplyOfferto_CardDetail(); const preferenceDatas = useSelector(PreferenceData, shallowEqual); @@ -183,9 +185,10 @@ const BSOtherServiceItemCard = (props) => { SelectedGlobalCardColorDetail, shallowEqual ); + const GetmultipleSearchDatas = useSelector(GlobalGetmultipleSearchDatas, shallowEqual) const SelectedCardFont = useSelector(SelectedGlobalCardFont, shallowEqual); const CartOrderDetails = useSelector(GlobalOrderCardDetails, shallowEqual); - console.log(CartOrderDetails,"CartOrderDetailsOTHERSERVICESITEMCARD"); + console.log(CartOrderDetails, "CartOrderDetailsOTHERSERVICESITEMCARD"); const SelectedDatas = useSelector(GlobalSelectedDatas, shallowEqual); const otherscarddata = useSelector(Globalothersdata, shallowEqual); const WSProductdata = useSelector(GlobalWSProduct, shallowEqual); @@ -247,7 +250,7 @@ const BSOtherServiceItemCard = (props) => { ? [] : SelectedDatas : ItemCard?.length == 0 || - (ItemCard?.[0]?.AppId === 0 && ItemCard?.[0]?.CompId === 0) + (ItemCard?.[0]?.AppId === 0 && ItemCard?.[0]?.CompId === 0) ? noSubcatCardData : ItemCard : ''; @@ -269,11 +272,25 @@ const BSOtherServiceItemCard = (props) => { useEffect(() => { if (AppId && CompId && BranchId) { fetchedit(); + GetmultipleSearchData() } // dispatch(changepreOrder(false)); Commented to Add Normal Produts After Adding the Combo Pack !!!!!! Dont Touch Without Shifayath Permission }, [AppId, CompId, BranchId]); + const GetmultipleSearchData = async () => { + const data = { + AppId, + CompId, + BranchId, + }; + try { + const response = await dispatch(getmultipleSearch(data)) + + } catch (error) { + console.error("Get Search Terms Error:", error); + } + }; useEffect(() => { setPreOrderSelectedProdNames([]); // dispatch(changePreOrderAdditem(null)); @@ -290,10 +307,13 @@ const BSOtherServiceItemCard = (props) => { if (noSubcatCardData) { setNoSubcatCardData(); } - if (ProductSearch?.length > 5) { + if (ProductSearch?.length > 5 && GetmultipleSearchDatas.some( + e => e.toLowerCase() === "qrcode" + )) { setQuickAdd(true); } - }, [ProductSearch]); + + }, [ProductSearch, GetmultipleSearchDatas]); useEffect(() => { if ( @@ -402,103 +422,103 @@ const BSOtherServiceItemCard = (props) => { } }; -let Otherservicedata = [ - { - "CompId": 1, - "BranchId": 101, - "AppId": 2025, - "ConfigTypeId": 10, - "ConfigTypeIdName": "Other Services", - "ServiceCategories": [ - { - "ServiceCategory": 1, - "ServiceCategoryName": "Parking", - "ServiceDetails": [ - { - "ServiceId": "PK2W", - "ServiceCategory": 1, - "ServiceCategoryName": "Parking", - "ServiceName": "2-Wheeler Parking", - "ServiceShortName": "2W", - "TaxId": "T1", - "TaxName": "GST 5%", - "TaxAmt": 1.50, - "Rate": 30.00, - "TotalAmt": 31.50, - "ActiveStatus": "Active" - }, - { - "ServiceId": "PK4W", - "ServiceCategory": 1, - "ServiceCategoryName": "Parking", - "ServiceName": "4-Wheeler Parking", - "ServiceShortName": "4W", - "TaxId": "T1", - "TaxName": "GST 5%", - "TaxAmt": 2.50, - "Rate": 50.00, - "TotalAmt": 52.50, - "ActiveStatus": "Active" - } - ] - }, - { - "ServiceCategory": 2, - "ServiceCategoryName": "Entrance", - "ServiceDetails": [ - { - "ServiceId": "ENAD", - "ServiceCategory": 2, - "ServiceCategoryName": "Entrance", - "ServiceName": "Adult Entry", - "ServiceShortName": "Adult", - "TaxId": "T2", - "TaxName": "GST 12%", - "TaxAmt": 6.00, - "Rate": 50.00, - "TotalAmt": 56.00, - "ActiveStatus": "Active" - }, - { - "ServiceId": "ENCH", - "ServiceCategory": 2, - "ServiceCategoryName": "Entrance", - "ServiceName": "Child Entry", - "ServiceShortName": "Child", - "TaxId": "T2", - "TaxName": "GST 12%", - "TaxAmt": 3.00, - "Rate": 25.00, - "TotalAmt": 28.00, - "ActiveStatus": "Active" - } - ] - } - ] - } - ] + let Otherservicedata = [ + { + "CompId": 1, + "BranchId": 101, + "AppId": 2025, + "ConfigTypeId": 10, + "ConfigTypeIdName": "Other Services", + "ServiceCategories": [ + { + "ServiceCategory": 1, + "ServiceCategoryName": "Parking", + "ServiceDetails": [ + { + "ServiceId": "PK2W", + "ServiceCategory": 1, + "ServiceCategoryName": "Parking", + "ServiceName": "2-Wheeler Parking", + "ServiceShortName": "2W", + "TaxId": "T1", + "TaxName": "GST 5%", + "TaxAmt": 1.50, + "Rate": 30.00, + "TotalAmt": 31.50, + "ActiveStatus": "Active" + }, + { + "ServiceId": "PK4W", + "ServiceCategory": 1, + "ServiceCategoryName": "Parking", + "ServiceName": "4-Wheeler Parking", + "ServiceShortName": "4W", + "TaxId": "T1", + "TaxName": "GST 5%", + "TaxAmt": 2.50, + "Rate": 50.00, + "TotalAmt": 52.50, + "ActiveStatus": "Active" + } + ] + }, + { + "ServiceCategory": 2, + "ServiceCategoryName": "Entrance", + "ServiceDetails": [ + { + "ServiceId": "ENAD", + "ServiceCategory": 2, + "ServiceCategoryName": "Entrance", + "ServiceName": "Adult Entry", + "ServiceShortName": "Adult", + "TaxId": "T2", + "TaxName": "GST 12%", + "TaxAmt": 6.00, + "Rate": 50.00, + "TotalAmt": 56.00, + "ActiveStatus": "Active" + }, + { + "ServiceId": "ENCH", + "ServiceCategory": 2, + "ServiceCategoryName": "Entrance", + "ServiceName": "Child Entry", + "ServiceShortName": "Child", + "TaxId": "T2", + "TaxName": "GST 12%", + "TaxAmt": 3.00, + "Rate": 25.00, + "TotalAmt": 28.00, + "ActiveStatus": "Active" + } + ] + } + ] + } + ] -const processGlobalComboData = () => { + const processGlobalComboData = () => { - const serviceCategories = GlobalOtherServicescarddatas?.[0]?.ServiceDetails; + const serviceCategories = GlobalOtherServicescarddatas?.[0]?.ServiceDetails; - if (!Array.isArray(serviceCategories)) return []; + if (!Array.isArray(serviceCategories)) return []; - // Flatten all ServiceDetails into a single array - const allServiceDetails = serviceCategories.map((category) => category.ServiceDetails || []); + // Flatten all ServiceDetails into a single array + const allServiceDetails = serviceCategories.map((category) => category.ServiceDetails || []); - const comboList = serviceCategories.map((item, index) => ({ - ...item, - id: `${item.ServiceName}-${index}`, - ProdName: item.ServiceName, - ServiceName: item.ServiceName, - })); + const comboList = serviceCategories.map((item, index) => ({ + ...item, + id: `${item.ServiceName}-${index}`, + ProdName: item.ServiceName, + ServiceName: item.ServiceName, + })); - return comboList; -}; + return comboList; + }; -const comboList = processGlobalComboData() || []; + const comboList = processGlobalComboData() || []; useEffect(() => { @@ -661,13 +681,13 @@ const comboList = processGlobalComboData() || []; (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 ); @@ -676,9 +696,9 @@ const comboList = processGlobalComboData() || []; (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 ); @@ -720,11 +740,11 @@ const comboList = processGlobalComboData() || []; (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 ); @@ -733,9 +753,9 @@ const comboList = processGlobalComboData() || []; (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 ); @@ -809,13 +829,13 @@ const comboList = processGlobalComboData() || []; (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 ); @@ -823,11 +843,11 @@ const comboList = processGlobalComboData() || []; 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 ); @@ -897,11 +917,11 @@ const comboList = processGlobalComboData() || []; (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 ); if (onePeiceFlow) { @@ -909,9 +929,9 @@ const comboList = processGlobalComboData() || []; (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 ); @@ -1006,15 +1026,15 @@ const comboList = processGlobalComboData() || []; 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 ); @@ -1022,11 +1042,11 @@ const comboList = processGlobalComboData() || []; 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 ); @@ -1104,15 +1124,15 @@ const comboList = processGlobalComboData() || []; 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 ); @@ -1120,11 +1140,11 @@ const comboList = processGlobalComboData() || []; 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 ); @@ -1555,7 +1575,7 @@ const comboList = processGlobalComboData() || []; 0 || - record.StockCount === 'Stock Not Maintained' + record.StockCount === 'Stock Not Maintained' ? { color: '#000', cursor: 'pointer' } : { color: '#f49898', cursor: 'not-allowed' } } @@ -1585,7 +1605,7 @@ const comboList = processGlobalComboData() || []; 0 || - record.StockCount === 'Stock Not Maintained' + record.StockCount === 'Stock Not Maintained' ? { color: '#000', cursor: 'pointer' } : { color: '#f49898', cursor: 'not-allowed' } } @@ -1615,7 +1635,7 @@ const comboList = processGlobalComboData() || []; 0 || - record.StockCount === 'Stock Not Maintained' + record.StockCount === 'Stock Not Maintained' ? { color: '#000', cursor: 'pointer' } : { color: '#f49898', cursor: 'not-allowed' } } @@ -1659,17 +1679,17 @@ const comboList = processGlobalComboData() || []; 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', }); }); @@ -1678,7 +1698,7 @@ const comboList = processGlobalComboData() || []; if (WeightScalePort === true) { if ( a?.ProductDetail?.[QtyIndex]?.UomName?.toLowerCase() === - 'KGS'?.toLowerCase() && + 'KGS'?.toLowerCase() && a?.ProductDetail?.[QtyIndex]?.Size == '1' ) { if (WeightScaleWeight > 0 && WeightScaleWeight !== null) { @@ -1686,13 +1706,13 @@ const comboList = processGlobalComboData() || []; parseFloat( onePcs ? (a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ - VarientIndex - ]?.StockDetails?.[stockIndex]?.OnePcsPrice / - 1000) * - (parseFloat(WeightScaleWeight) * 1000) + VarientIndex + ]?.StockDetails?.[stockIndex]?.OnePcsPrice / + 1000) * + (parseFloat(WeightScaleWeight) * 1000) : a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ - VarientIndex - ]?.StockDetails?.[stockIndex]?.SellPrice / 1000 + VarientIndex + ]?.StockDetails?.[stockIndex]?.SellPrice / 1000 ) * (parseFloat(WeightScaleWeight) * 1000); let data = { @@ -1755,9 +1775,9 @@ const comboList = processGlobalComboData() || []; ?.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: parseFloat(TotalOrderRate).toFixed(2), SellingPrice: parseFloat(TotalOrderRate).toFixed(2), SuppId: @@ -1869,19 +1889,19 @@ const comboList = processGlobalComboData() || []; ?.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, @@ -2802,8 +2822,8 @@ const comboList = processGlobalComboData() || []; // setModelstock(true); // // form.resetFields(['ProdName']); // } else { - onAutocompleteChange(selectedOption); - // form.resetFields(['ProdName']); + onAutocompleteChange(selectedOption); + // form.resetFields(['ProdName']); // } }; @@ -2885,7 +2905,7 @@ const comboList = processGlobalComboData() || []; const onAutocompleteChange = async (selectedOption) => { -console.log(selectedOption,"selectedOptionselectedOption"); + console.log(selectedOption, "selectedOptionselectedOption"); let data = { @@ -2913,9 +2933,9 @@ console.log(selectedOption,"selectedOptionselectedOption"); TotalSellPrice: selectedOption?.TotalAmt, Price: selectedOption.TotalAmt, - TaxAmt:selectedOption?.TaxAmt, - TaxId:selectedOption?.TaxId, - TaxName:selectedOption?.TaxName, + TaxAmt: selectedOption?.TaxAmt, + TaxId: selectedOption?.TaxId, + TaxName: selectedOption?.TaxName, TaxPercentage: selectedOption?.TaxPercentage, QRCode: selectedOption?.ComboInwardDetails?.[0]?.QRCode, @@ -2927,23 +2947,23 @@ console.log(selectedOption,"selectedOptionselectedOption"); BookingTypeName: BookingType, StockAvailable: 'N', - - // Size: 1, - // UomName: 'PCS', - // OfferPrice: selectedOption?.ComboInwardDetails?.[0]?.OfferPrice, - // OfferValue: - // selectedOption?.ComboInwardDetails?.[0]?.OfferType === 'F' - // ? selectedOption?.ComboInwardDetails?.[0]?.OfferPrice - // : (OrderRate * selectedOption?.ComboInwardDetails?.[0]?.OfferPrice) / - // 100, - // SinglePc: 'N', + + // Size: 1, + // UomName: 'PCS', + // OfferPrice: selectedOption?.ComboInwardDetails?.[0]?.OfferPrice, + // OfferValue: + // selectedOption?.ComboInwardDetails?.[0]?.OfferType === 'F' + // ? selectedOption?.ComboInwardDetails?.[0]?.OfferPrice + // : (OrderRate * selectedOption?.ComboInwardDetails?.[0]?.OfferPrice) / + // 100, + // SinglePc: 'N', }; await AddOrderDetails(data); }; const AddOrderDetails = async (item) => { -console.log("AddOrderDetails item",item) + console.log("AddOrderDetails item", item) if (preOrder) { let Response = await dispatch( getConfigType({ TypeName: 'Booking Type' }) @@ -2963,7 +2983,7 @@ console.log("AddOrderDetails item",item) if (Condition !== undefined && Condition === true) { setMessageData('Dublicate Data'); setMessageType('error'); - } + } else { let OfferPri = item?.OfferType === 'F' @@ -3030,7 +3050,7 @@ console.log("AddOrderDetails item",item) dispatch(changepreOrderList(Data)); } } - } + } else { dispatch(changeHoldOrderDtl(false)); @@ -3099,45 +3119,45 @@ console.log("AddOrderDetails item",item) ); const BookingTypeProd = item?.BookingTypeName; - if (isItemInCart && BookingTypeProd != 'Dine In' && OrderType != 'Hold' ) { + if (isItemInCart && BookingTypeProd != 'Dine In' && OrderType != 'Hold') { if (BillOrderPre === 'Y') { const UpdatedCartItem = - // if the item is already in the cart, increase the quantity of the item - { - ...isItemInCart, - OrderQty: isItemInCart?.OrderQty + 1, - TotalAmt: - isItemInCart?.OfferPrice > 0 - ? (isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate - - (isItemInCart?.OfferType === 'F' - ? (isItemInCart?.OrderQty + 1) * isItemInCart?.OfferPrice - : ((isItemInCart?.OrderQty + 1) * - isItemInCart?.OrderRate * - isItemInCart?.OfferPrice) / - 100) - : (isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate, - // TotalAmt: ((isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate), - OfferValue: - item?.OfferType === 'F' + // if the item is already in the cart, increase the quantity of the item + { + ...isItemInCart, + OrderQty: isItemInCart?.OrderQty + 1, + TotalAmt: + isItemInCart?.OfferPrice > 0 + ? (isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate - + (isItemInCart?.OfferType === 'F' ? (isItemInCart?.OrderQty + 1) * isItemInCart?.OfferPrice - : isItemInCart?.OfferPrice, + : ((isItemInCart?.OrderQty + 1) * + isItemInCart?.OrderRate * + isItemInCart?.OfferPrice) / + 100) + : (isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate, + // TotalAmt: ((isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate), + OfferValue: + item?.OfferType === 'F' + ? (isItemInCart?.OrderQty + 1) * isItemInCart?.OfferPrice + : isItemInCart?.OfferPrice, - TaxAmt: ( + 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), - WithoutTaxRate: - (isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate - - ( - ((isItemInCart?.OrderQty + 1) * - isItemInCart?.OrderRate * - isItemInCart?.TaxPercentage) / - (100 + isItemInCart?.TaxPercentage) - ).toFixed(2), - }; + }; dispatch( changeOrderCardDetails([ @@ -3145,12 +3165,12 @@ console.log("AddOrderDetails item",item) ...OtherorderDataforNormal, ]) ); - } + } else { - const isGroupService = isItemInCart?.ServiceType == 'G'; - if (isGroupService) { - const UpdatedCartItem = + const isGroupService = isItemInCart?.ServiceType == 'G'; + if (isGroupService) { + const UpdatedCartItem = // if the item is already in the cart, increase the quantity of the item { ...isItemInCart, @@ -3158,20 +3178,20 @@ console.log("AddOrderDetails item",item) TotalAmt: isItemInCart?.OfferPrice > 0 ? (isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate - - (isItemInCart?.OfferType === 'F' - ? (isItemInCart?.OrderQty + 1) * isItemInCart?.OfferPrice - : ((isItemInCart?.OrderQty + 1) * - isItemInCart?.OrderRate * - isItemInCart?.OfferPrice) / - 100) + (isItemInCart?.OfferType === 'F' + ? (isItemInCart?.OrderQty + 1) * isItemInCart?.OfferPrice + : ((isItemInCart?.OrderQty + 1) * + isItemInCart?.OrderRate * + isItemInCart?.OfferPrice) / + 100) : (isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate, OfferValue: item?.OfferType === 'F' ? (isItemInCart?.OrderQty + 1) * isItemInCart?.OfferPrice : ((isItemInCart?.OrderQty + 1) * - isItemInCart?.OrderRate * - isItemInCart?.OfferPrice) / - 100, + isItemInCart?.OrderRate * + isItemInCart?.OfferPrice) / + 100, // TotalAmt: ((isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate), TaxAmt: ( ((isItemInCart?.OrderQty + 1) * @@ -3189,59 +3209,59 @@ console.log("AddOrderDetails item",item) ).toFixed(2), }; - dispatch( - changeOrderCardDetails([ - ...OtherorderDataforNormal, - UpdatedCartItem, - ]) - ); - } else { - // ❌ Not a group service - setMessageType('error'); - setMessageData("Service Already Exist") - } + dispatch( + changeOrderCardDetails([ + ...OtherorderDataforNormal, + UpdatedCartItem, + ]) + ); + } else { + // ❌ Not a group service + setMessageType('error'); + setMessageData("Service Already Exist") + } -} + } } else if (isItemInCart && BookingTypeProd === 'Dine In' && OrderType != 'Hold') { if (BillOrderPre === 'Y') { const UpdatedCartItem = - // if the item is already in the cart, increase the quantity of the item - { - ...isItemInCart, - OrderQty: isItemInCart?.OrderQty + 1, - TotalAmt: - isItemInCart?.OfferPrice > 0 - ? (isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate - - (isItemInCart?.OfferType === 'F' - ? (isItemInCart?.OrderQty + 1) * isItemInCart?.OfferPrice - : ((isItemInCart?.OrderQty + 1) * - isItemInCart?.OrderRate * - isItemInCart?.OfferPrice) / - 100) - : (isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate, - OfferValue: - item?.OfferType === 'F' + // if the item is already in the cart, increase the quantity of the item + { + ...isItemInCart, + OrderQty: isItemInCart?.OrderQty + 1, + TotalAmt: + isItemInCart?.OfferPrice > 0 + ? (isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate - + (isItemInCart?.OfferType === 'F' ? (isItemInCart?.OrderQty + 1) * isItemInCart?.OfferPrice - : isItemInCart?.OfferPrice, + : ((isItemInCart?.OrderQty + 1) * + isItemInCart?.OrderRate * + isItemInCart?.OfferPrice) / + 100) + : (isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate, + OfferValue: + item?.OfferType === 'F' + ? (isItemInCart?.OrderQty + 1) * isItemInCart?.OfferPrice + : isItemInCart?.OfferPrice, - // TotalAmt: ((isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate), - TaxAmt: ( + // 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), - WithoutTaxRate: - (isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate - - ( - ((isItemInCart?.OrderQty + 1) * - isItemInCart?.OrderRate * - isItemInCart?.TaxPercentage) / - (100 + isItemInCart?.TaxPercentage) - ).toFixed(2), - }; + }; dispatch( changeOrderCardDetails([ @@ -3249,44 +3269,44 @@ console.log("AddOrderDetails item",item) ...OtherorderDataforNormal, ]) ); - } + } else { const UpdatedCartItem = - // if the item is already in the cart, increase the quantity of the item - { - ...isItemInCart, - OrderQty: isItemInCart?.OrderQty + 1, - TotalAmt: - isItemInCart?.OfferPrice > 0 - ? (isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate - - (isItemInCart?.OfferType === 'F' - ? (isItemInCart?.OrderQty + 1) * isItemInCart?.OfferPrice - : ((isItemInCart?.OrderQty + 1) * - isItemInCart?.OrderRate * - isItemInCart?.OfferPrice) / - 100) - : (isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate, - OfferValue: - item?.OfferType === 'F' + // if the item is already in the cart, increase the quantity of the item + { + ...isItemInCart, + OrderQty: isItemInCart?.OrderQty + 1, + TotalAmt: + isItemInCart?.OfferPrice > 0 + ? (isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate - + (isItemInCart?.OfferType === 'F' ? (isItemInCart?.OrderQty + 1) * isItemInCart?.OfferPrice - : isItemInCart?.OfferPrice, + : ((isItemInCart?.OrderQty + 1) * + isItemInCart?.OrderRate * + isItemInCart?.OfferPrice) / + 100) + : (isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate, + OfferValue: + item?.OfferType === 'F' + ? (isItemInCart?.OrderQty + 1) * isItemInCart?.OfferPrice + : isItemInCart?.OfferPrice, - // TotalAmt: ((isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate), - TaxAmt: ( + // 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), - WithoutTaxRate: - (isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate - - ( - ((isItemInCart?.OrderQty + 1) * - isItemInCart?.OrderRate * - isItemInCart?.TaxPercentage) / - (100 + isItemInCart?.TaxPercentage) - ).toFixed(2), - }; + }; dispatch( changeOrderCardDetails([ @@ -3295,48 +3315,48 @@ console.log("AddOrderDetails item",item) ]) ); } - } + } else if (isItemInCartHold && OrderType === 'Hold') { if (BillOrderPre === 'Y') { const UpdatedCartItem = - // if the item is already in the cart, increase the quantity of the item - { - ...isItemInCartHold, - OrderQty: isItemInCartHold?.OrderQty + 1, - TotalAmt: - isItemInCartHold?.OfferPrice > 0 - ? (isItemInCartHold?.OrderQty + 1) * - isItemInCartHold?.OrderRate - - (isItemInCartHold?.OfferType === 'F' - ? (isItemInCart?.OrderQty + 1) * isItemInCart?.OfferPrice - : ((isItemInCartHold?.OrderQty + 1) * - isItemInCartHold?.OrderRate * - isItemInCartHold?.OfferPrice) / - 100) - : (isItemInCartHold?.OrderQty + 1) * - isItemInCartHold?.OrderRate, - OfferValue: - item?.OfferType === 'F' + // if the item is already in the cart, increase the quantity of the item + { + ...isItemInCartHold, + OrderQty: isItemInCartHold?.OrderQty + 1, + TotalAmt: + isItemInCartHold?.OfferPrice > 0 + ? (isItemInCartHold?.OrderQty + 1) * + isItemInCartHold?.OrderRate - + (isItemInCartHold?.OfferType === 'F' ? (isItemInCart?.OrderQty + 1) * isItemInCart?.OfferPrice - : isItemInCart?.OfferPrice, + : ((isItemInCartHold?.OrderQty + 1) * + isItemInCartHold?.OrderRate * + isItemInCartHold?.OfferPrice) / + 100) + : (isItemInCartHold?.OrderQty + 1) * + isItemInCartHold?.OrderRate, + OfferValue: + item?.OfferType === 'F' + ? (isItemInCart?.OrderQty + 1) * isItemInCart?.OfferPrice + : isItemInCart?.OfferPrice, - // TotalAmt: ((isItemInCartHold?.OrderQty + 1) * isItemInCartHold?.OrderRate), - TaxAmt: ( + // 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), - WithoutTaxRate: - (isItemInCartHold?.OrderQty + 1) * isItemInCartHold?.OrderRate - - ( - ((isItemInCartHold?.OrderQty + 1) * - isItemInCartHold?.OrderRate * - isItemInCartHold?.TaxPercentage) / - (100 + isItemInCartHold?.TaxPercentage) - ).toFixed(2), - }; + }; dispatch( changeOrderCardDetails([ @@ -3344,46 +3364,46 @@ console.log("AddOrderDetails item",item) ...OtherorderDataforNormalWithoutSalesId, ]) ); - } + } else { const UpdatedCartItem = - // if the item is already in the cart, increase the quantity of the item - { - ...isItemInCartHold, - OrderQty: isItemInCartHold?.OrderQty + 1, - TotalAmt: - isItemInCartHold?.OfferPrice > 0 - ? (isItemInCartHold?.OrderQty + 1) * - isItemInCartHold?.OrderRate - - (isItemInCartHold?.OfferType === 'F' - ? (isItemInCart?.OrderQty + 1) * isItemInCart?.OfferPrice - : ((isItemInCartHold?.OrderQty + 1) * - isItemInCartHold?.OrderRate * - isItemInCartHold?.OfferPrice) / - 100) - : (isItemInCartHold?.OrderQty + 1) * - isItemInCartHold?.OrderRate, - OfferValue: - item?.OfferType === 'F' + // if the item is already in the cart, increase the quantity of the item + { + ...isItemInCartHold, + OrderQty: isItemInCartHold?.OrderQty + 1, + TotalAmt: + isItemInCartHold?.OfferPrice > 0 + ? (isItemInCartHold?.OrderQty + 1) * + isItemInCartHold?.OrderRate - + (isItemInCartHold?.OfferType === 'F' ? (isItemInCart?.OrderQty + 1) * isItemInCart?.OfferPrice - : isItemInCart?.OfferPrice, + : ((isItemInCartHold?.OrderQty + 1) * + isItemInCartHold?.OrderRate * + isItemInCartHold?.OfferPrice) / + 100) + : (isItemInCartHold?.OrderQty + 1) * + isItemInCartHold?.OrderRate, + OfferValue: + item?.OfferType === 'F' + ? (isItemInCart?.OrderQty + 1) * isItemInCart?.OfferPrice + : isItemInCart?.OfferPrice, - // TotalAmt: ((isItemInCartHold?.OrderQty + 1) * isItemInCartHold?.OrderRate), - TaxAmt: ( + // 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), - WithoutTaxRate: - (isItemInCartHold?.OrderQty + 1) * isItemInCartHold?.OrderRate - - ( - ((isItemInCartHold?.OrderQty + 1) * - isItemInCartHold?.OrderRate * - isItemInCartHold?.TaxPercentage) / - (100 + isItemInCartHold?.TaxPercentage) - ).toFixed(2), - }; + }; dispatch( changeOrderCardDetails([ @@ -3392,7 +3412,7 @@ console.log("AddOrderDetails item",item) ]) ); } - } + } else if (isItemNotInDine && BookingTypeProd == 'Dine In' && OrderType != 'Hold') { if (BillOrderPre === 'Y') { @@ -3402,12 +3422,12 @@ console.log("AddOrderDetails item",item) TotalAmt: isItemNotInDine?.OfferPrice > 0 ? (isItemNotInDine?.OrderQty + 1) * isItemNotInDine?.OrderRate - - (isItemNotInDine?.OfferType === 'F' - ? (isItemInCart?.OrderQty + 1) * isItemInCart?.OfferPrice - : ((isItemNotInDine?.OrderQty + 1) * - isItemNotInDine?.OrderRate * - isItemNotInDine?.OfferPrice) / - 100) + (isItemNotInDine?.OfferType === 'F' + ? (isItemInCart?.OrderQty + 1) * isItemInCart?.OfferPrice + : ((isItemNotInDine?.OrderQty + 1) * + isItemNotInDine?.OrderRate * + isItemNotInDine?.OfferPrice) / + 100) : (isItemNotInDine?.OrderQty + 1) * isItemNotInDine?.OrderRate, OfferValue: item?.OfferType === 'F' @@ -3438,7 +3458,7 @@ console.log("AddOrderDetails item",item) ...OtherOrderDatawithsales, ]) ); - } + } else { const UpdatedCartItem = { ...isItemNotInDine, @@ -3446,12 +3466,12 @@ console.log("AddOrderDetails item",item) TotalAmt: isItemNotInDine?.OfferPrice > 0 ? (isItemNotInDine?.OrderQty + 1) * isItemNotInDine?.OrderRate - - (isItemNotInDine?.OfferType === 'F' - ? (isItemInCart?.OrderQty + 1) * isItemInCart?.OfferPrice - : ((isItemNotInDine?.OrderQty + 1) * - isItemNotInDine?.OrderRate * - isItemNotInDine?.OfferPrice) / - 100) + (isItemNotInDine?.OfferType === 'F' + ? (isItemInCart?.OrderQty + 1) * isItemInCart?.OfferPrice + : ((isItemNotInDine?.OrderQty + 1) * + isItemNotInDine?.OrderRate * + isItemNotInDine?.OfferPrice) / + 100) : (isItemNotInDine?.OrderQty + 1) * isItemNotInDine?.OrderRate, OfferValue: item?.OfferType === 'F' @@ -3489,137 +3509,137 @@ console.log("AddOrderDetails item",item) if (item?.OtherProduct === 'Others') { BillOrderPre === 'Y' ? dispatch( - changeOrderCardDetails([ - { - ...item, - // TotalAmt: (((item?.OrderQty + 1) * item?.OrderRate)- (item?.OfferType === "F" ?item?.OfferPrice :(((item?.OrderQty + 1) * item?.OrderRate) * item?.OfferPrice)/100)), + changeOrderCardDetails([ + { + ...item, + // TotalAmt: (((item?.OrderQty + 1) * item?.OrderRate)- (item?.OfferType === "F" ?item?.OfferPrice :(((item?.OrderQty + 1) * item?.OrderRate) * item?.OfferPrice)/100)), - 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), - }, - ...CartOrderDetails, - ]) - ) // if the item is not in the cart, add the item to the cart - : dispatch( - changeOrderCardDetails([ - ...CartOrderDetails, - { - ...item, - TotalAmt: item?.OrderQty * item?.OrderRate, - - // TotalAmt: (((item?.OrderQty + 1) * item?.OrderRate)- (item?.OfferType === "F" ?item?.OfferPrice :(((item?.OrderQty + 1) * item?.OrderRate) * item?.OfferPrice)/100)), - 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), - }, - ]) - ); - } - -// else { -// const baseItem = { -// ...item, -// OrderQty: 1, -// OfferPrice: item?.OfferPrice, -// TotalAmt: -// item?.OfferPrice > 0 -// ? item?.OrderRate - -// (item?.OfferType === 'F' -// ? item?.OfferPrice -// : (item?.OrderRate * item?.OfferPrice) / 100) -// : item?.OrderRate, -// TaxAmt: ( -// (item?.OrderRate * item?.TaxPercentage) / -// (100 + item?.TaxPercentage) -// ).toFixed(2), -// WithoutTaxRate: ( -// item?.OrderRate - -// (item?.OrderRate * item?.TaxPercentage) / -// (100 + item?.TaxPercentage) -// ).toFixed(2), -// }; - -// if (item?.ServiceType == 'I') { -// // Always add as a separate entry (individual) -// dispatch(changeOrderCardDetails([ -// ...CartOrderDetails, -// baseItem, -// ])); -// } else { - -// // Use your existing logic with BillOrderPre check -// BillOrderPre === 'Y' -// ? dispatch(changeOrderCardDetails([ -// baseItem, -// ...CartOrderDetails, -// ])) -// : dispatch(changeOrderCardDetails([ -// ...CartOrderDetails, -// baseItem, -// ])); -// } -// } - - else { - const baseItem = { - ...item, - OrderQty: 1, - OfferPrice: item?.OfferPrice, - TotalAmt: - item?.OfferPrice > 0 - ? item?.OrderRate - - (item?.OfferType === 'F' - ? item?.OfferPrice - : (item?.OrderRate * item?.OfferPrice) / 100) - : item?.OrderRate, - TaxAmt: ( - (item?.OrderRate * item?.TaxPercentage) / - (100 + item?.TaxPercentage) - ).toFixed(2), - WithoutTaxRate: ( - item?.OrderRate - - (item?.OrderRate * item?.TaxPercentage) / + TotalAmt: item?.OrderQty * item?.OrderRate, + TaxAmt: ( + (item?.OrderQty * item?.OrderRate * item?.TaxPercentage) / (100 + item?.TaxPercentage) - ).toFixed(2), - }; + ).toFixed(2), + WithoutTaxRate: ( + item?.OrderQty * item?.OrderRate - + (item?.OrderQty * item?.OrderRate * item?.TaxPercentage) / + (100 + item?.TaxPercentage) + ).toFixed(2), + }, + ...CartOrderDetails, + ]) + ) // if the item is not in the cart, add the item to the cart + : dispatch( + changeOrderCardDetails([ + ...CartOrderDetails, + { + ...item, + TotalAmt: item?.OrderQty * item?.OrderRate, - if (item?.ServiceType === 'I') { + // TotalAmt: (((item?.OrderQty + 1) * item?.OrderRate)- (item?.OfferType === "F" ?item?.OfferPrice :(((item?.OrderQty + 1) * item?.OrderRate) * item?.OfferPrice)/100)), + 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), + }, + ]) + ); + } - // Add the item and include a __index to track vehicle number uniquely - const updatedCart = [...CartOrderDetails, baseItem].map((itm, idx) => ({ - ...itm, - __index: idx, // Temporary index used for vehicle number assignment - })); + // else { + // const baseItem = { + // ...item, + // OrderQty: 1, + // OfferPrice: item?.OfferPrice, + // TotalAmt: + // item?.OfferPrice > 0 + // ? item?.OrderRate - + // (item?.OfferType === 'F' + // ? item?.OfferPrice + // : (item?.OrderRate * item?.OfferPrice) / 100) + // : item?.OrderRate, + // TaxAmt: ( + // (item?.OrderRate * item?.TaxPercentage) / + // (100 + item?.TaxPercentage) + // ).toFixed(2), + // WithoutTaxRate: ( + // item?.OrderRate - + // (item?.OrderRate * item?.TaxPercentage) / + // (100 + item?.TaxPercentage) + // ).toFixed(2), + // }; - dispatch(changeOrderCardDetails(updatedCart)); - } else { + // if (item?.ServiceType == 'I') { + // // Always add as a separate entry (individual) + // dispatch(changeOrderCardDetails([ + // ...CartOrderDetails, + // baseItem, + // ])); + // } else { - // Use existing flow with optional BillOrderPre control - // const updatedCart = - // BillOrderPre === 'Y' - // ? [baseItem, ...CartOrderDetails] - // : [...CartOrderDetails, baseItem]; - const updatedCart = [...CartOrderDetails, baseItem].map((itm, idx) => ({ - ...itm, - __index: idx, // Temporary index used for vehicle number assignment - })); - dispatch(changeOrderCardDetails(updatedCart)); - } - } + // // Use your existing logic with BillOrderPre check + // BillOrderPre === 'Y' + // ? dispatch(changeOrderCardDetails([ + // baseItem, + // ...CartOrderDetails, + // ])) + // : dispatch(changeOrderCardDetails([ + // ...CartOrderDetails, + // baseItem, + // ])); + // } + // } + + else { + const baseItem = { + ...item, + OrderQty: 1, + OfferPrice: item?.OfferPrice, + TotalAmt: + item?.OfferPrice > 0 + ? item?.OrderRate - + (item?.OfferType === 'F' + ? item?.OfferPrice + : (item?.OrderRate * item?.OfferPrice) / 100) + : item?.OrderRate, + TaxAmt: ( + (item?.OrderRate * item?.TaxPercentage) / + (100 + item?.TaxPercentage) + ).toFixed(2), + WithoutTaxRate: ( + item?.OrderRate - + (item?.OrderRate * item?.TaxPercentage) / + (100 + item?.TaxPercentage) + ).toFixed(2), + }; + + if (item?.ServiceType === 'I') { + + // Add the item and include a __index to track vehicle number uniquely + const updatedCart = [...CartOrderDetails, baseItem].map((itm, idx) => ({ + ...itm, + __index: idx, // Temporary index used for vehicle number assignment + })); + + dispatch(changeOrderCardDetails(updatedCart)); + } else { + + // Use existing flow with optional BillOrderPre control + // const updatedCart = + // BillOrderPre === 'Y' + // ? [baseItem, ...CartOrderDetails] + // : [...CartOrderDetails, baseItem]; + const updatedCart = [...CartOrderDetails, baseItem].map((itm, idx) => ({ + ...itm, + __index: idx, // Temporary index used for vehicle number assignment + })); + dispatch(changeOrderCardDetails(updatedCart)); + } + } } @@ -3747,8 +3767,8 @@ console.log("AddOrderDetails item",item) Cartdata?.[0]?.OfferType === 'F' ? Cartdata?.[0]?.OfferPrice : (qtydata?.[0]?.ComboInwardDetails?.[0]?.TotalSellPrice * - Cartdata?.[0]?.OfferPrice) / - 100, + Cartdata?.[0]?.OfferPrice) / + 100, OfferPrice: Cartdata?.[0]?.OfferPrice, SinglePc: 'N', }; @@ -3790,9 +3810,9 @@ console.log("AddOrderDetails item",item) return DropDown && Array.isArray(DropDown) ? DropDown.map((item) => ({ - label: `${item.ComboName}`, // Display the combo name - value: `${item.ComboId}`, // Use combo ID as the value - })) + label: `${item.ComboName}`, // Display the combo name + value: `${item.ComboId}`, // Use combo ID as the value + })) : []; // }); }; @@ -3919,38 +3939,38 @@ console.log("AddOrderDetails item",item) 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' : 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: @@ -3965,56 +3985,56 @@ console.log("AddOrderDetails item",item) : 'BSItemCard-container' } onClick={(e) => { - // if ( - // !( - // ( - // item?.OverallQuantity !== - // undefined && - // returnCount( - // item?.ComboName, - // item?.OverallQuantity, - // CartOrderDetails - // ) > 0 - // ) - // // || - // // item?.OverallQuantity > 0 - // ) - // ) { - // e.stopPropagation(); - // } else { - CardOnclick(item); - // } + // if ( + // !( + // ( + // item?.OverallQuantity !== + // undefined && + // returnCount( + // item?.ComboName, + // item?.OverallQuantity, + // CartOrderDetails + // ) > 0 + // ) + // // || + // // item?.OverallQuantity > 0 + // ) + // ) { + // e.stopPropagation(); + // } else { + CardOnclick(item); + // } }} data-aos="zoom-in" data-aos-duration="600" > {(cardFunction?.BigImage || cardFunction?.SmallImage) && ( - - )} + cardFunction?.ImageLeft || + cardFunction?.ImageUp || + cardFunction?.ImageDown + ? '3rem' + : cardFunction?.BigImage && '7rem' + : '5rem', + }} + className={ + cardFunction?.SmallImage + ? 'BSItemCard-image-smallimage' + : 'BSItemCard-image' + } + src={item?.ImageUrl === null ? defaultimage : item?.ImageUrl ? item?.ImageUrl + : defaultimage + } + alt="" + /> + )}
)} */}

- { cardFunction?.Price && ( -

- ₹{' '} - { - item?.TotalAmt - } -   - {/* {item?.TotalAmt}  */} - {/* {ItemSellingPrice(item)} */} - {/* + {cardFunction?.Price && ( +

+ ₹{' '} + { + item?.TotalAmt + } +   + {/* {item?.TotalAmt}  */} + {/* {ItemSellingPrice(item)} */} + {/* {'(1 Combo Pack)'} */} -

- ) - } +

+ ) + }
{cardFunction?.StockCount && @@ -4186,213 +4206,213 @@ console.log("AddOrderDetails item",item) )}
- ) : + ) : - ( - <> - {globaldata && ( - pickData(e, item)} - style={{ - position: 'absolute', - zIndex: 1, - transform: 'scale(1.5)', - cursor: 'pointer', - }} - checked={( - globalAllItemdata || EditfavItems - )?.some( - // (a) => a?.ProdName === item?.ProdName - (a) => - a?.ProdName === item?.ProdName && - a?.ProdCat === item?.ProdCat - )} - /> - )} - -
{ - // if ( - // !( - // item?.OverallQuantity !== undefined && - // returnCount( - // item?.ComboName, - // item?.OverallQuantity, - // CartOrderDetails - // ) > 0 - // ) - // ) { - // e.stopPropagation(); - // } else { - CardOnclick(item); - // } - }} - // data-aos="zoom-in" data-aos-duration="600" - > - {(cardFunction?.BigImage || - cardFunction?.SmallImage) && ( - + {globaldata && ( + pickData(e, item)} style={{ - objectFit: - cardFunction?.BigImage && '', - height: !cardFunction?.BigImage - ? (!cardFunction?.BigImage && - cardFunction?.SmallImage) || - cardFunction?.ImageLeft || - cardFunction?.ImageUp || - cardFunction?.ImageDown - ? '3rem' - : cardFunction?.BigImage && '7rem' - : '4rem', + position: 'absolute', + zIndex: 1, + transform: 'scale(1.5)', + cursor: 'pointer', }} - className={ - cardFunction?.SmallImage - ? 'BSItemCard-image-smallimage' - : 'BSItemCard-image' - } - src={ - item?.ProductDetail?.[0]?.ProdLogo === - '' - ? defaultimage - : item?.ProductDetail?.[0]?.ProdLogo - ? item?.ProductDetail?.[0] - ?.ProdLogo - : defaultimage - } - alt="" + checked={( + globalAllItemdata || EditfavItems + )?.some( + // (a) => a?.ProdName === item?.ProdName + (a) => + a?.ProdName === item?.ProdName && + a?.ProdCat === item?.ProdCat + )} /> )} +
{ + // if ( + // !( + // item?.OverallQuantity !== undefined && + // returnCount( + // item?.ComboName, + // item?.OverallQuantity, + // CartOrderDetails + // ) > 0 + // ) + // ) { + // e.stopPropagation(); + // } else { + CardOnclick(item); + // } + }} + // data-aos="zoom-in" data-aos-duration="600" > -

+ )} +

+

- {item?.ProdName}{' '} - {/* {(item?.OverallQuantity !== undefined && + // Width: cardFunction?.BigImage && "70px", + fontSize: + !cardFunction?.BigImage && + !cardFunction?.SmallImage && + '12px', //naresh27 + whiteSpace: + !cardFunction?.BigImage && + 'pre-wrap', + margin: 'auto', + fontFamily: SelectedCardFont + ? SelectedCardFont + : '', + color: SelectedCardColor + ? SelectedCardColor?.['FontColor'] + : '', + textOverflow: 'ellipsis', + }} + className="BSItemCard-itemName" + > + {item?.ProdName}{' '} + {/* {(item?.OverallQuantity !== undefined && returnCount( item?.ComboName, item?.OverallQuantity, @@ -4412,80 +4432,80 @@ console.log("AddOrderDetails item",item) No Stock

)} */} -

- {cardFunction?.Price && - ((item?.OverallQuantity !== undefined && - item?.OverallQuantity !== 0 && - item?.OverallQuantity !== null) || - item?.ProductDetail?.some( - (item) => - item?.StockAvailable !== 'Y' - )) && ( -

+ {cardFunction?.Price && + ((item?.OverallQuantity !== undefined && + item?.OverallQuantity !== 0 && + item?.OverallQuantity !== null) || + item?.ProductDetail?.some( + (item) => + item?.StockAvailable !== 'Y' + )) && ( +

+ ₹ {ItemSellingPrice(item)}  + {/* {item?.ProductDetail?.[0]?.ProdVariantDetails?.[0]?.StockDetails?.[0]?.SellPrice}  */} + {/* {ItemSellingPrice(item)} */} + + ({ItemSize(item)} + {ItemUomName(item)}) + +

+ )} +
+ + {cardFunction?.StockCount && + item?.OverallQuantity !== undefined && + item?.OverallQuantity !== 0 && ( +
- ₹ {ItemSellingPrice(item)}  - {/* {item?.ProductDetail?.[0]?.ProdVariantDetails?.[0]?.StockDetails?.[0]?.SellPrice}  */} - {/* {ItemSellingPrice(item)} */} - - ({ItemSize(item)} - {ItemUomName(item)}) - -

+ {item?.OverallQuantity !== null && ( + + )} +
)}
- - {cardFunction?.StockCount && - item?.OverallQuantity !== undefined && - item?.OverallQuantity !== 0 && ( -
- {item?.OverallQuantity !== null && ( - - )} -
- )} -
- - ) - } + + ) + }
))} @@ -4493,7 +4513,9 @@ console.log("AddOrderDetails item",item) - ) : ProductSearch?.length > 5 && + ) : ProductSearch?.length > 5 && GetmultipleSearchDatas.some( + e => e.toLowerCase() === "qrcode" + ) && (cardData?.length == 0 || cardData == undefined) ? (
{/* cardData mohan 18-04-2025 */} @@ -4821,16 +4843,16 @@ console.log("AddOrderDetails item",item) ]?.ProdVariantName?.toLowerCase()?.includes( 'variant' ) && ( - - ( - { - qtydata?.ProductDetail?.[QtyIndex] - ?.ProdVariantDetails?.[VarientIndex] - ?.ProdVariantName - } - ){' '} - - )} + + ( + { + qtydata?.ProductDetail?.[QtyIndex] + ?.ProdVariantDetails?.[VarientIndex] + ?.ProdVariantName + } + ){' '} + + )}

diff --git a/src/Pages/BookingScreen/Components/BSItemCards/BsBookingitemCard.jsx b/src/Pages/BookingScreen/Components/BSItemCards/BsBookingitemCard.jsx index 9c5b35c..cd14777 100644 --- a/src/Pages/BookingScreen/Components/BSItemCards/BsBookingitemCard.jsx +++ b/src/Pages/BookingScreen/Components/BSItemCards/BsBookingitemCard.jsx @@ -69,6 +69,8 @@ import { slotTimeStatus, changeAddBookingDetailsTrigger, GlobalAddBookingDetailsTrigger, + GlobalGetmultipleSearchDatas, + getmultipleSearch, } from '../../../../Features/BookingScreen/BookingData/BookingData'; import { GlobalPreOrderAdditem, @@ -216,6 +218,7 @@ const BsBookingitemCard = (props) => { shallowEqual ); // const SelectedCust = useSelector(GlobalSelOption, shallowEqual); + const GetmultipleSearchDatas = useSelector(GlobalGetmultipleSearchDatas, shallowEqual) const RetailWSSalesType = useSelector(GlobalRetailWSSalesType, shallowEqual); // const CustDetails = SelectedCust ? SelectedCust : AddCustomerDetails?.[0]; const BookingTypeBoth = useSelector(GlobalBookingTypeBoth); @@ -446,9 +449,9 @@ const BsBookingitemCard = (props) => { AppId: AppId, ...(AvailableDate && selectedDate ? { - fromDate: selectedDate?.[0], - toDate: selectedDate?.[1], - } + fromDate: selectedDate?.[0], + toDate: selectedDate?.[1], + } : {}), }; await dispatch(getSelectedFavItems(data)).unwrap(); @@ -681,9 +684,9 @@ const BsBookingitemCard = (props) => { AppId: AppId, ...(AvailableDate && selectedDate ? { - fromDate: selectedDate?.[0], - toDate: selectedDate?.[1], - } + fromDate: selectedDate?.[0], + toDate: selectedDate?.[1], + } : {}), }; await dispatch(getSelectedFavItems(data)).unwrap(); @@ -775,9 +778,9 @@ const BsBookingitemCard = (props) => { AppId: AppId, ...(AvailableDate && selectedDate ? { - fromDate: selectedDate?.[0], - toDate: selectedDate?.[1], - } + fromDate: selectedDate?.[0], + toDate: selectedDate?.[1], + } : {}), }; await dispatch(getSelectedFavItems(data)).unwrap(); @@ -1022,7 +1025,7 @@ const BsBookingitemCard = (props) => { ? [] : SelectedDatas : ItemCard?.length == 0 || - (ItemCard?.[0]?.AppId === 0 && ItemCard?.[0]?.CompId === 0) + (ItemCard?.[0]?.AppId === 0 && ItemCard?.[0]?.CompId === 0) ? noSubcatCardData : ItemCard : ''; @@ -1090,10 +1093,25 @@ const BsBookingitemCard = (props) => { useEffect(() => { if (AppId && CompId && BranchId) { fetchedit(); + GetmultipleSearchData() } // dispatch(changepreOrder(false)); Commented to Add Normal Produts After Adding the Combo Pack !!!!!! Dont Touch Without Shifayath Permission }, [AppId, CompId, BranchId]); + const GetmultipleSearchData = async () => { + const data = { + AppId, + CompId, + BranchId, + }; + + try { + const response = await dispatch(getmultipleSearch(data)) + + } catch (error) { + console.error("Get Search Terms Error:", error); + } + }; useEffect(() => { setPreOrderSelectedProdNames([]); // dispatch(changePreOrderAdditem(null)); @@ -1112,9 +1130,9 @@ const BsBookingitemCard = (props) => { AppId: AppId, ...(AvailableDate && selectedDate ? { - fromDate: selectedDate?.[0], - toDate: selectedDate?.[1], - } + fromDate: selectedDate?.[0], + toDate: selectedDate?.[1], + } : {}), }; dispatch(getSelectedFavItems(data)).unwrap(); @@ -1126,10 +1144,12 @@ const BsBookingitemCard = (props) => { if (noSubcatCardData) { setNoSubcatCardData(); } - if (ProductSearch?.length > 5) { + if (ProductSearch?.length > 5 && GetmultipleSearchDatas.some( + e => e.toLowerCase() === "qrcode" + )) { setQuickAdd(true); } - }, [ProductSearch]); + }, [ProductSearch, GetmultipleSearchDatas]); useEffect(() => { if ( !initialRun && @@ -1173,9 +1193,9 @@ const BsBookingitemCard = (props) => { ProdSubCat: currentProdSubCat, ...(AvailableDate && currentDateRef ? { - fromDate: currentDateRef?.[0], - toDate: currentDateRef?.[1], - } + fromDate: currentDateRef?.[0], + toDate: currentDateRef?.[1], + } : {}), }; //mohan @@ -1196,9 +1216,9 @@ const BsBookingitemCard = (props) => { prodCat: currentProdCat, ...(AvailableDate && currentDateRef ? { - fromDate: currentDateRef?.[0], - toDate: currentDateRef?.[1], - } + fromDate: currentDateRef?.[0], + toDate: currentDateRef?.[1], + } : {}), }; @@ -1222,9 +1242,9 @@ const BsBookingitemCard = (props) => { prodCat: currentProdCat, ...(AvailableDate && currentDateRef ? { - fromDate: currentDateRef?.[0], - toDate: currentDateRef?.[1], - } + fromDate: currentDateRef?.[0], + toDate: currentDateRef?.[1], + } : {}), }; @@ -1280,9 +1300,9 @@ const BsBookingitemCard = (props) => { AppId: AppId, ...(AvailableDate && selectedDate ? { - fromDate: selectedDate?.[0], - toDate: selectedDate?.[1], - } + fromDate: selectedDate?.[0], + toDate: selectedDate?.[1], + } : {}), }; let res = await dispatch(getEditFavItems(data)).unwrap(); @@ -1488,13 +1508,13 @@ const BsBookingitemCard = (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 ); @@ -1502,11 +1522,11 @@ const BsBookingitemCard = (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 ); @@ -1599,13 +1619,13 @@ const BsBookingitemCard = (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 ); @@ -1614,9 +1634,9 @@ const BsBookingitemCard = (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 ); @@ -1764,15 +1784,15 @@ const BsBookingitemCard = (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 ); @@ -1780,11 +1800,11 @@ const BsBookingitemCard = (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 ); @@ -1863,15 +1883,15 @@ const BsBookingitemCard = (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 ); @@ -1879,11 +1899,11 @@ const BsBookingitemCard = (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 ); @@ -2318,7 +2338,7 @@ const BsBookingitemCard = (props) => { parseInt(totalSelectedProductQty || 0) + parseInt(reorderComboConsumed || 0); } - } catch (_) {} + } catch (_) { } let getCurrentProdDtl = orderDetails?.filter( (a) => a?.ProdName === ProdName ); @@ -2519,7 +2539,7 @@ const BsBookingitemCard = (props) => { parseInt(totalSelectedProductQty || 0) + parseInt(reorderComboConsumed || 0); } - } catch (_) {} + } catch (_) { } let getCurrentProdDtl = orderDetails?.filter((a) => a?.ProdId === ProdId); let totalOrderQty = getCurrentProdDtl?.reduce((accumulator, card) => { return ( @@ -2555,7 +2575,7 @@ const BsBookingitemCard = (props) => { }, 0); totalOrderQty = parseInt(totalOrderQty || 0) + parseInt(comboConsumed || 0); - } catch (_) {} + } catch (_) { } let OverallProdQty = totalOrderQty - totalSelectedProductQty; if ( parseInt(ItemQuantity) > @@ -2641,7 +2661,7 @@ const BsBookingitemCard = (props) => { parseInt(totalSelectedProductQty || 0) + parseInt(reorderComboConsumed || 0); } - } catch (_) {} + } catch (_) { } let getCurrentProdDtl = orderDetails?.filter((a) => a?.ProdId === ProdId); let totalOrderQty = getCurrentProdDtl?.reduce((accumulator, card) => { return ( @@ -2680,7 +2700,7 @@ const BsBookingitemCard = (props) => { }, 0); totalOrderQty = parseInt(totalOrderQty || 0) + parseInt(comboConsumed || 0); - } catch (_) {} + } catch (_) { } let OverallProdQty = totalOrderQty - totalSelectedProductQty; if ( parseInt(ItemQuantity) > @@ -2772,7 +2792,7 @@ const BsBookingitemCard = (props) => { parseInt(totalSelectedProductQty || 0) + parseInt(reorderComboConsumed || 0); } - } catch (_) {} + } catch (_) { } let getCurrentProdDtl = orderDetails?.filter( (a) => a?.ProdId === ProdId && a?.InwardDtlId === InwardDtlId ); @@ -2815,7 +2835,7 @@ const BsBookingitemCard = (props) => { }, 0); totalOrderQty = parseInt(totalOrderQty || 0) + parseInt(comboConsumed || 0); - } catch (_) {} + } catch (_) { } let OverallProdQty = totalOrderQty - totalSelectedProductQty; if ( @@ -2899,7 +2919,7 @@ const BsBookingitemCard = (props) => { parseInt(totalSelectedProductQty || 0) + parseInt(reorderComboConsumed || 0); } - } catch (_) {} + } catch (_) { } let getCurrentProdDtl = orderDetails?.filter( (a) => a?.ProdId === ProdId && a?.InwardDtlId === InwardDtlId ); @@ -2946,7 +2966,7 @@ const BsBookingitemCard = (props) => { }, 0); totalOrderQty = parseInt(totalOrderQty || 0) + parseInt(comboConsumed || 0); - } catch (_) {} + } catch (_) { } let OverallProdQty = totalOrderQty - totalSelectedProductQty; if ( @@ -2985,7 +3005,7 @@ const BsBookingitemCard = (props) => { const same = item?.InwardDtlId === data?.InwardDtlId && item?.ProdVariantName?.toLowerCase() === - data?.VarientName?.toLowerCase() && + data?.VarientName?.toLowerCase() && item?.VariantAvailableFrom === data?.VariantAvailableFrom && item?.VariantAvailableTo === data?.VariantAvailableTo && item?.BookedDate && @@ -3010,7 +3030,7 @@ const BsBookingitemCard = (props) => { 0 || - record.StockCount === 'Stock Not Maintained' + record.StockCount === 'Stock Not Maintained' ? { color: '#000', cursor: 'pointer' } : { color: '#f49898', cursor: 'not-allowed' } } @@ -3040,7 +3060,7 @@ const BsBookingitemCard = (props) => { 0 || - record.StockCount === 'Stock Not Maintained' + record.StockCount === 'Stock Not Maintained' ? { color: '#000', cursor: 'pointer' } : { color: '#f49898', cursor: 'not-allowed' } } @@ -3070,7 +3090,7 @@ const BsBookingitemCard = (props) => { 0 || - record.StockCount === 'Stock Not Maintained' + record.StockCount === 'Stock Not Maintained' ? { color: '#000', cursor: 'pointer' } : { color: '#f49898', cursor: 'not-allowed' } } @@ -3324,20 +3344,20 @@ const BsBookingitemCard = (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: @@ -3641,9 +3661,9 @@ const BsBookingitemCard = (props) => { AppId, ...(AvailableDate && selectedDate ? { - fromDate: selectedDate?.[0], - toDate: selectedDate?.[1], - } + fromDate: selectedDate?.[0], + toDate: selectedDate?.[1], + } : {}), }; @@ -3675,9 +3695,9 @@ const BsBookingitemCard = (props) => { prodCat: ProdCat, ...(AvailableDate && selectedDate ? { - fromDate: selectedDate?.[0], - toDate: selectedDate?.[1], - } + fromDate: selectedDate?.[0], + toDate: selectedDate?.[1], + } : {}), }; @@ -4503,9 +4523,9 @@ const BsBookingitemCard = (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'; @@ -4539,13 +4559,13 @@ const BsBookingitemCard = (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; const getDatePickerValue = (selectedDate) => { @@ -4602,8 +4622,8 @@ const BsBookingitemCard = (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' : '', }} @@ -4715,39 +4735,39 @@ const BsBookingitemCard = (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: @@ -4769,39 +4789,39 @@ const BsBookingitemCard = (props) => { > {(cardFunction?.BigImage || cardFunction?.SmallImage) && ( - - )} + : defaultimage + } + alt="" + /> + )}
{ cardFunction?.Background && (SelectedCardColor ? SelectedCardColor?.[ - 'BackgroundColor' - ] + 'BackgroundColor' + ] : ''), position: !cardFunction?.BigImage @@ -4835,7 +4855,7 @@ const BsBookingitemCard = (props) => { height: cardFunction?.SmallImage ? '5.5rem' : !cardFunction?.BigImage && - '5.5rem', + '5.5rem', alignItems: !cardFunction?.BigImage && !cardFunction?.SmallImage && @@ -4858,11 +4878,11 @@ const BsBookingitemCard = (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 && @@ -4883,7 +4903,7 @@ const BsBookingitemCard = (props) => { className="BSItemCard-itemName" > {item?.ProdName} - {} + { }

{cardFunction?.Price && (

{ fontSize: !cardFunction?.SmallImage ? cardFunction?.BigImage && - '12px' + '12px' : '12px', textAlign: 'center', lineHeight: '2', @@ -4901,8 +4921,8 @@ const BsBookingitemCard = (props) => { : '', color: SelectedCardColor ? SelectedCardColor?.[ - 'FontColor' - ] + 'FontColor' + ] : '', }} > @@ -4988,39 +5008,39 @@ const BsBookingitemCard = (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: @@ -5037,43 +5057,43 @@ const BsBookingitemCard = (props) => { onClick={(e) => { CardOnclick(item, index); }} - // data-aos="zoom-in" data-aos-duration="600" + // data-aos="zoom-in" data-aos-duration="600" > {(cardFunction?.BigImage || cardFunction?.SmallImage) && ( - - )} + : defaultimage + } + alt="" + /> + )}

{ cardFunction?.Background && (SelectedCardColor ? SelectedCardColor?.[ - 'BackgroundColor' - ] + 'BackgroundColor' + ] : ''), position: !cardFunction?.BigImage @@ -5107,7 +5127,7 @@ const BsBookingitemCard = (props) => { height: cardFunction?.SmallImage ? '5.5rem' : !cardFunction?.BigImage && - '4.5rem', + '4.5rem', alignItems: !cardFunction?.BigImage && !cardFunction?.SmallImage && @@ -5127,11 +5147,11 @@ const BsBookingitemCard = (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 && @@ -5167,7 +5187,7 @@ const BsBookingitemCard = (props) => { fontSize: !cardFunction?.SmallImage ? cardFunction?.BigImage && - '12px' + '12px' : '12px', textAlign: 'center', lineHeight: '2', @@ -5176,8 +5196,8 @@ const BsBookingitemCard = (props) => { : '', color: SelectedCardColor ? SelectedCardColor?.[ - 'FontColor' - ] + 'FontColor' + ] : '', }} > @@ -5276,7 +5296,7 @@ const BsBookingitemCard = (props) => { height={60} src={ item?.ProductDetail?.[0]?.ProdLogo === - '' + '' ? defaultimage : item?.ProductDetail?.[0]?.ProdLogo ? item?.ProductDetail?.[0]?.ProdLogo @@ -5293,15 +5313,15 @@ const BsBookingitemCard = (props) => {
{item?.ProductDetail?.[0]?.ProdVariantDetails ?.length > 0 && ( -
-
- ₹ {ItemSellingPrice(item)} +
+
+ ₹ {ItemSellingPrice(item)} +
+
+ {ItemSize(item)} {ItemUomName(item)} +
-
- {ItemSize(item)} {ItemUomName(item)} -
-
- )} + )}
{/* Stock Count Badge */} @@ -5340,7 +5360,9 @@ const BsBookingitemCard = (props) => { - ) : ProductSearch?.length > 5 && + ) : ProductSearch?.length > 5 && GetmultipleSearchDatas.some( + e => e.toLowerCase() === "qrcode" + ) && (cardData?.length == 0 || cardData == undefined) ? (
{/* cardData mohan 18-04-2025 */} @@ -5991,30 +6013,30 @@ const BsBookingitemCard = (props) => { {slots.map((timeSlot, idx) => { const isBooked = timeSlot?.SlotStatus?.toLowerCase() == - 'booked' || false; + 'booked' || false; const isBlocked = timeSlot?.SlotStatus?.toLowerCase() == - 'blocked' || false; + 'blocked' || false; const isPartiallyBooked = timeSlot?.SlotStatus?.toLowerCase() === - 'partially booked' || false; + 'partially booked' || false; const isPartiallyBlocked = timeSlot?.SlotStatus?.toLowerCase() === - 'partially blocked' || false; + 'partially blocked' || false; const isSelected = CartOrderDetails?.some( (selected) => selected.ProdId === - timeSlot?.ProdId && + timeSlot?.ProdId && selected.InwardDtlId === - timeSlot?.InwardDtlId && + timeSlot?.InwardDtlId && selected.VariantAvailableFrom === - timeSlot?.VariantAvailableFrom && + timeSlot?.VariantAvailableFrom && selected.VariantAvailableTo === - timeSlot?.VariantAvailableTo && + timeSlot?.VariantAvailableTo && selected.BookedDate === - timeSlot?.BookedDate + timeSlot?.BookedDate ); const isAlreadyAdded = @@ -6022,25 +6044,25 @@ const BsBookingitemCard = (props) => { const itemDate = item?.BookedDate ? new Date( - item?.BookedDate - ).toLocaleDateString() + item?.BookedDate + ).toLocaleDateString() : null; return ( item?.InwardDtlId === - timeSlot?.InwardDtlId && + timeSlot?.InwardDtlId && item?.VariantAvailableFrom === - timeSlot?.VariantAvailableFrom && + timeSlot?.VariantAvailableFrom && item?.VariantAvailableTo === - timeSlot?.VariantAvailableTo && + timeSlot?.VariantAvailableTo && item?.ProdVariantName?.toLowerCase() === - timeSlot?.VarientName?.toLowerCase() && + timeSlot?.VarientName?.toLowerCase() && itemDate === dataDate && (item?.SinglePc === 'Y' ? returnVariantStock( - data, - CartOrderDetails - ) === 0 + data, + CartOrderDetails + ) === 0 : true) ); }); @@ -6053,13 +6075,13 @@ const BsBookingitemCard = (props) => { selectedSlots?.some( (selected) => selected.InwardDtlId === - timeSlot?.InwardDtlId && + timeSlot?.InwardDtlId && selected.VariantAvailableFrom === - timeSlot?.VariantAvailableFrom && + timeSlot?.VariantAvailableFrom && selected.VariantAvailableTo === - timeSlot?.VariantAvailableTo && + timeSlot?.VariantAvailableTo && selected.TempDate === - timeSlot?.BookedDate + timeSlot?.BookedDate ); const isDisabled = isBooked || @@ -6072,26 +6094,25 @@ const BsBookingitemCard = (props) => { return (
{ @@ -6110,7 +6131,7 @@ const BsBookingitemCard = (props) => { timeSlot, product, onePeiceFlow || - isPartiallyBooked, + isPartiallyBooked, !slotEnded ); } @@ -6128,7 +6149,7 @@ const BsBookingitemCard = (props) => {
₹ {onePeiceFlow || - isPartiallyBooked + isPartiallyBooked ? timeSlot?.OnePcsPrice : timeSlot?.SellPrice || 0}
@@ -6154,15 +6175,15 @@ const BsBookingitemCard = (props) => { !CartOrderDetails?.some( (selected) => selected.ProdId === - timeSlot.ProdId && + timeSlot.ProdId && selected.InwardDtlId === - timeSlot.InwardDtlId && + timeSlot.InwardDtlId && selected.VariantAvailableFrom === - timeSlot.VariantAvailableFrom && + timeSlot.VariantAvailableFrom && selected.VariantAvailableTo === - timeSlot.VariantAvailableTo && + timeSlot.VariantAvailableTo && selected.BookedDate === - timeSlot.BookedDate + timeSlot.BookedDate ) } icon={ @@ -6227,7 +6248,7 @@ const BsBookingitemCard = (props) => { (timeSlot?.SlotStatus === 'Partially Booked' || timeSlot?.SlotStatus === - 'Booked') && ( + 'Booked') && (
{ e.stopPropagation(); @@ -6413,7 +6434,7 @@ const BsBookingitemCard = (props) => { {customer.CustMobile || 'N/A'} {customer?.CustBookDetails?.length > - 1 ? ( + 1 ? ( ) : customer?.CustBookDetails - ?.length === 1 ? ( + ?.length === 1 ? ( <>
)}
- {preferenceshortcutkey && ( + {/* {preferenceshortcutkey && (
-
)} +
)} */}
{/*
*/} diff --git a/src/Pages/BookingScreen/Template/SalesCountComponent.jsx b/src/Pages/BookingScreen/Template/SalesCountComponent.jsx index c247949..2fa0f76 100644 --- a/src/Pages/BookingScreen/Template/SalesCountComponent.jsx +++ b/src/Pages/BookingScreen/Template/SalesCountComponent.jsx @@ -85,6 +85,13 @@ const SalesCountComponent = React.memo( type?.PreferredSubCatName?.toLowerCase() === 'take away' && type?.PreferredStatus === 'Y' ); + const preferenceshortcutkey = preferencedata?.[0]?.[ + 'SettingDtlDetails' + ]?.some( + (item) => + item.SettingIdName.toLowerCase() === 'shortcutkeys' && + item.SettingValue === 'Y' + ); const [messageType, setMessageType] = useState(null); @@ -1085,6 +1092,11 @@ const SalesCountComponent = React.memo( )}
+ {/* {preferenceshortcutkey && } */} + {preferenceshortcutkey && ( +
+ +
)} { const sampleDataMap = { - 'Restaurant': { + Restaurant: { productName: 'Chicken Biryani', quantity: 1, uom: 'PLT', @@ -58,7 +68,7 @@ const getApplicationSampleData = (appName) => { uom: 'PLT', salesPrice: 120, category: 'Vegetarian', - subCategory: 'South Indian' + subCategory: 'South Indian', }, { productName: 'Paneer Butter Masala', @@ -66,11 +76,11 @@ const getApplicationSampleData = (appName) => { uom: 'PLT', salesPrice: 200, category: 'Vegetarian', - subCategory: 'North Indian' - } - ] + subCategory: 'North Indian', + }, + ], }, - 'Bakery': { + Bakery: { productName: 'Chocolate Cake', quantity: 1, uom: 'PCS', @@ -89,7 +99,7 @@ const getApplicationSampleData = (appName) => { uom: 'PCS', salesPrice: 45, category: 'Pastries', - subCategory: 'French Pastries' + subCategory: 'French Pastries', }, { productName: 'Whole Wheat Bread', @@ -97,9 +107,9 @@ const getApplicationSampleData = (appName) => { uom: 'LOAF', salesPrice: 35, category: 'Breads', - subCategory: 'Wheat Breads' - } - ] + subCategory: 'Wheat Breads', + }, + ], }, 'Electrical, Electronics and Computers': { productName: 'LED Bulb 9W', @@ -120,7 +130,7 @@ const getApplicationSampleData = (appName) => { uom: 'PCS', salesPrice: 299, category: 'Mobile Accessories', - subCategory: 'Chargers' + subCategory: 'Chargers', }, { productName: 'Extension Board 4 Socket', @@ -128,9 +138,9 @@ const getApplicationSampleData = (appName) => { uom: 'PCS', salesPrice: 350, category: 'Electrical Accessories', - subCategory: 'Power Strips' - } - ] + subCategory: 'Power Strips', + }, + ], }, 'Mobile Phone and Accessories': { productName: 'Smartphone Screen Guard', @@ -151,7 +161,7 @@ const getApplicationSampleData = (appName) => { uom: 'PCS', salesPrice: 149, category: 'Protection', - subCategory: 'Back Covers' + subCategory: 'Back Covers', }, { productName: 'Wireless Earbuds', @@ -159,11 +169,11 @@ const getApplicationSampleData = (appName) => { uom: 'PAIR', salesPrice: 1599, category: 'Audio', - subCategory: 'Bluetooth Earphones' - } - ] + subCategory: 'Bluetooth Earphones', + }, + ], }, - 'Grocery': { + Grocery: { productName: 'Basmati Rice', quantity: 1, uom: 'KG', @@ -182,7 +192,7 @@ const getApplicationSampleData = (appName) => { uom: 'KG', salesPrice: 120, category: 'Pulses', - subCategory: 'Arhar Dal' + subCategory: 'Arhar Dal', }, { productName: 'Refined Oil', @@ -190,9 +200,9 @@ const getApplicationSampleData = (appName) => { uom: 'LITER', salesPrice: 110, category: 'Cooking Oil', - subCategory: 'Sunflower Oil' - } - ] + subCategory: 'Sunflower Oil', + }, + ], }, 'Departmental Stores': { productName: 'Shampoo', @@ -213,7 +223,7 @@ const getApplicationSampleData = (appName) => { uom: 'TUBE', salesPrice: 45, category: 'Oral Care', - subCategory: 'Toothpaste' + subCategory: 'Toothpaste', }, { productName: 'Laundry Detergent', @@ -221,11 +231,11 @@ const getApplicationSampleData = (appName) => { uom: 'KG', salesPrice: 85, category: 'Household', - subCategory: 'Washing Powder' - } - ] + subCategory: 'Washing Powder', + }, + ], }, - 'Jewellery': { + Jewellery: { productName: 'Gold Ring', quantity: 1, uom: 'PCS', @@ -244,7 +254,7 @@ const getApplicationSampleData = (appName) => { uom: 'PAIR', salesPrice: 1200, category: 'Silver Jewellery', - subCategory: 'Earrings' + subCategory: 'Earrings', }, { productName: 'Diamond Pendant', @@ -252,9 +262,9 @@ const getApplicationSampleData = (appName) => { uom: 'PCS', salesPrice: 15000, category: 'Diamond Jewellery', - subCategory: 'Pendants' - } - ] + subCategory: 'Pendants', + }, + ], }, 'Lifestyle and Fashion': { productName: 'Cotton T-Shirt', @@ -275,7 +285,7 @@ const getApplicationSampleData = (appName) => { uom: 'PCS', salesPrice: 1299, category: 'Bottoms', - subCategory: 'Denim' + subCategory: 'Denim', }, { productName: 'Sneakers', @@ -283,9 +293,9 @@ const getApplicationSampleData = (appName) => { uom: 'PAIR', salesPrice: 2499, category: 'Footwear', - subCategory: 'Casual Shoes' - } - ] + subCategory: 'Casual Shoes', + }, + ], }, 'Salon, Spa and Beauty Parlour': { productName: 'Hair Cut Service', @@ -306,7 +316,7 @@ const getApplicationSampleData = (appName) => { uom: 'SERVICE', salesPrice: 800, category: 'Skin Care', - subCategory: 'Facial' + subCategory: 'Facial', }, { productName: 'Hair Color', @@ -314,11 +324,11 @@ const getApplicationSampleData = (appName) => { uom: 'SERVICE', salesPrice: 1200, category: 'Hair Services', - subCategory: 'Coloring' - } - ] + subCategory: 'Coloring', + }, + ], }, - 'Stationery': { + Stationery: { productName: 'A4 Paper Pack', quantity: 1, uom: 'PACK', @@ -337,7 +347,7 @@ const getApplicationSampleData = (appName) => { uom: 'PCS', salesPrice: 15, category: 'Writing Instruments', - subCategory: 'Pens' + subCategory: 'Pens', }, { productName: 'Notebook', @@ -345,11 +355,11 @@ const getApplicationSampleData = (appName) => { uom: 'PCS', salesPrice: 45, category: 'Books & Notebooks', - subCategory: 'Exercise Books' - } - ] + subCategory: 'Exercise Books', + }, + ], }, - 'Pharmacy': { + Pharmacy: { productName: 'Paracetamol 500mg', quantity: 1, uom: 'STRIP', @@ -368,7 +378,7 @@ const getApplicationSampleData = (appName) => { uom: 'BTL', salesPrice: 65, category: 'Healthcare', - subCategory: 'Sanitizers' + subCategory: 'Sanitizers', }, { productName: 'Bandage Roll', @@ -376,11 +386,11 @@ const getApplicationSampleData = (appName) => { uom: 'PCS', salesPrice: 25, category: 'Medical Supplies', - subCategory: 'First Aid' - } - ] + subCategory: 'First Aid', + }, + ], }, - 'Furniture': { + Furniture: { productName: 'Wooden Dining Table', quantity: 1, uom: 'PCS', @@ -399,7 +409,7 @@ const getApplicationSampleData = (appName) => { uom: 'PCS', salesPrice: 5500, category: 'Office Furniture', - subCategory: 'Chairs' + subCategory: 'Chairs', }, { productName: 'Queen Size Bed', @@ -407,11 +417,11 @@ const getApplicationSampleData = (appName) => { uom: 'PCS', salesPrice: 12000, category: 'Bedroom Furniture', - subCategory: 'Beds' - } - ] + subCategory: 'Beds', + }, + ], }, - 'Fruits': { + Fruits: { productName: 'Fresh Apples', quantity: 1, uom: 'KG', @@ -430,7 +440,7 @@ const getApplicationSampleData = (appName) => { uom: 'DOZEN', salesPrice: 60, category: 'Fresh Fruits', - subCategory: 'Tropical Fruits' + subCategory: 'Tropical Fruits', }, { productName: 'Orange Juice', @@ -438,11 +448,11 @@ const getApplicationSampleData = (appName) => { uom: 'LITER', salesPrice: 120, category: 'Fruit Juices', - subCategory: 'Fresh Juice' - } - ] + subCategory: 'Fresh Juice', + }, + ], }, - 'Textiles': { + Textiles: { productName: 'Cotton Fabric', quantity: 1, uom: 'METER', @@ -461,7 +471,7 @@ const getApplicationSampleData = (appName) => { uom: 'PCS', salesPrice: 2500, category: 'Ready Made', - subCategory: 'Sarees' + subCategory: 'Sarees', }, { productName: 'Woolen Shawl', @@ -469,9 +479,9 @@ const getApplicationSampleData = (appName) => { uom: 'PCS', salesPrice: 800, category: 'Accessories', - subCategory: 'Shawls' - } - ] + subCategory: 'Shawls', + }, + ], }, 'Computer Sales Shop': { productName: 'Gaming Laptop', @@ -492,7 +502,7 @@ const getApplicationSampleData = (appName) => { uom: 'PCS', salesPrice: 1200, category: 'Computer Accessories', - subCategory: 'Mouse' + subCategory: 'Mouse', }, { productName: 'SSD 500GB', @@ -500,33 +510,34 @@ const getApplicationSampleData = (appName) => { uom: 'PCS', salesPrice: 4500, category: 'Storage', - subCategory: 'Solid State Drive' - } - ] - } + subCategory: 'Solid State Drive', + }, + ], + }, }; // Return sample data for the specified app, or generic data if not found - return sampleDataMap[appName] || { - productName: 'Sample Product Name', - quantity: 1, - uom: 'PCS', - salesPrice: 100, - mrp: 100, - category: 'Sample Category', - subCategory: 'Sample Sub Category', - brand: 'Sample Brand', - variantName: 'Sample Variant Name', - tax: 'NIL - 0%', - hsn: '12345678', - additionalSamples: [] - }; + return ( + sampleDataMap[appName] || { + productName: 'Sample Product Name', + quantity: 1, + uom: 'PCS', + salesPrice: 100, + mrp: 100, + category: 'Sample Category', + subCategory: 'Sample Sub Category', + brand: 'Sample Brand', + variantName: 'Sample Variant Name', + tax: 'NIL - 0%', + hsn: '12345678', + additionalSamples: [], + } + ); }; - const allowedExcelTypes = [ 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', // .xlsx - 'application/vnd.ms-excel' // .xls + 'application/vnd.ms-excel', // .xls ]; const ProductExcel = ({ @@ -545,13 +556,28 @@ const ProductExcel = ({ CategoryName1, Catconfigid, }) => { - + useWhyDidYouUpdate('ProductExcel', { + handleSubmit, + CategoryId, + CategoryNames, + SubcatId, + SubCatData, + AllBrandId, + Allbranddata, + Allbranddatanumfid, + Subcatnumfid, + Unit, + TaxDatas, + SuplierNames, + CategoryName1, + Catconfigid, + }); const dispatch = useDispatch(); const formRef = useRef(null); - const CompId = getSession("CompId") - const BranchId = getSession("BranchId") - const AppId = getSession("AppId"); - const UserId = getSession("UserId"); + const CompId = getSession('CompId'); + const BranchId = getSession('BranchId'); + const AppId = getSession('AppId'); + const UserId = getSession('UserId'); const fileInputRef = useRef(fileInputRefSelector); const excelData = useSelector(excelDataSelector); @@ -559,7 +585,7 @@ const ProductExcel = ({ const excelFileError = useSelector(excelFileErrorSelector); const ApplicationPreferenceData = useSelector(ApplicationPreferences); const productBulkUploadCatId = ApplicationPreferenceData?.find( - p => p?.PreferredCatName?.toLowerCase() === "product bulk upload" + (p) => p?.PreferredCatName?.toLowerCase() === 'product bulk upload' )?.PreferredCatId; const [appName, setAppName] = useState(null); @@ -569,7 +595,7 @@ const ProductExcel = ({ const [tableFieldPreferences, setTableFieldPreferences] = useState([]); const [worksheet, setWorksheet] = useState(null); const [worksheet1, setWorksheet1] = useState(null); - const [editdelete, seteditdelete] = useState(""); + const [editdelete, seteditdelete] = useState(''); const [fieldSetup, setFieldSetup] = useState(false); const [selectedImageIndex, setSelectedImageIndex] = useState(null); const [selectedProductName, setSelectedProductName] = useState(null); @@ -588,54 +614,57 @@ const ProductExcel = ({ const [ExcelData, setExcelData] = useState([]); const [originalUploadedRawData, setOriginalUploadedRawData] = useState([]); const [FieldValues, setFieldValues] = useState([]); - + const [OrginalData, setOrginalData] = useState([]); const handleTableChange = (pagination, filters, sorter) => { setCurrentPage(pagination.current); }; + console.log(tableFieldPreferences, 'tableFieldPreferences'); useEffect(() => { if (excelData && excelData?.length > 0) { let ExecelToJsConvertion = []; let slicedData = excelData?.slice(1); - let filteredData = slicedData?.filter(item => item?.[item?.length - 1]?.trim() !== "sample row"); + let filteredData = slicedData?.filter( + (item) => item?.[item?.length - 1]?.trim() !== 'sample row' + ); filteredData?.map((item, index) => { ExecelToJsConvertion.push({ key: index, - ProductName: item?.["0"], - Quantity: item?.["1"], - UOM: item?.["2"], - SellPrice: item?.["3"], - Category: item?.["4"], - SubCategory: item?.["5"], - Brand: item?.["6"], - ProductVariantName: item?.["7"] ? item?.["7"] : "Variant 1", - MRP: item?.["8"], - WhSalePrice: item?.["9"], - StockAvailable: item?.["10"] ? item?.["10"] : "No", - TokenAvailable: item?.["11"] ? item?.["11"] : "No", - ProductType: item?.["12"], - Tax: item?.["13"], - AutoGenerateQrcode: item?.["14"], - AddQrCode: item?.["15"], - OnePeiceAvailable: item?.["16"] ? item?.["16"] : "No", - OnePeicePrice: item?.["17"], - AutoGenerateOnePieceQrcode: item?.["18"] ? item?.["18"] : "No", - AutoGenerateOnePieceQrcodeNumber: item?.["19"], - CESS: item?.["20"], - HSN: item?.["21"], - PartNumber: item?.["22"], - Rack: item?.["23"], - ManufactureDate: item?.["24"], - ExpireDate: item?.["25"], - AvailableFrom: item?.["26"] ? item?.["26"] : "", - AvailableTo: item?.["27"] ? item?.["27"] : "", - Productimage: "", + ProductName: item?.['0'], + Quantity: item?.['1'], + UOM: item?.['2'], + SellPrice: item?.['3'], + Category: item?.['4'], + SubCategory: item?.['5'], + Brand: item?.['6'], + ProductVariantName: item?.['7'] ? item?.['7'] : 'Variant 1', + MRP: item?.['8'], + WhSalePrice: item?.['9'], + StockAvailable: item?.['10'] ? item?.['10'] : 'No', + TokenAvailable: item?.['11'] ? item?.['11'] : 'No', + ProductType: item?.['12'], + Tax: item?.['13'], + AutoGenerateQrcode: item?.['14'], + AddQrCode: item?.['15'], + OnePeiceAvailable: item?.['16'] ? item?.['16'] : 'No', + OnePeicePrice: item?.['17'], + AutoGenerateOnePieceQrcode: item?.['18'] ? item?.['18'] : 'No', + AutoGenerateOnePieceQrcodeNumber: item?.['19'], + CESS: item?.['20'], + HSN: item?.['21'], + PartNumber: item?.['22'], + Rack: item?.['23'], + ManufactureDate: item?.['24'], + ExpireDate: item?.['25'], + AvailableFrom: item?.['26'] ? item?.['26'] : '', + AvailableTo: item?.['27'] ? item?.['27'] : '', + Productimage: '', }); }); setDatas(ExecelToJsConvertion); // setExcelData(ExecelToJsConvertion); - // setOriginalUploadedRawData(ExecelToJsConvertion); + // setOriginalUploadedRawData(ExecelToJsConvertion); const style = document.createElement('style'); style.type = 'text/css'; style.innerHTML = ` @@ -648,19 +677,20 @@ const ProductExcel = ({ return () => { document.head.removeChild(style); }; - } }, [excelData]); useEffect(() => { const fetchData = async () => { if (AppId) { - const response = await dispatch(getApplicationDetails({ AppId }))?.unwrap(); - setAppName(response?.data?.data?.[0]?.AppName) + const response = await dispatch( + getApplicationDetails({ AppId }) + )?.unwrap(); + setAppName(response?.data?.data?.[0]?.AppName); } }; fetchData(); - }, [AppId]) + }, [AppId]); useEffect(() => { // Call handleSubmit when Datas is updated @@ -670,11 +700,18 @@ const ProductExcel = ({ }, [Datas, handleSubmit]); // Automatically update preview data on mapping change - const mandatoryFields = ["ProductName", "Quantity", "UOM", "SellPrice", "Category"]; + const mandatoryFields = [ + 'ProductName', + 'Quantity', + 'UOM', + 'SellPrice', + 'Category', + ]; useEffect(() => { if (UploadedRawData.length > 0) { const updatedMappedData = UploadedRawData.map((row, index) => { const newRow = { key: index }; + newRow['isModified'] = row?.isModified; // ✅ Process mandatory fields (retain value even if unmapped) mandatoryFields.forEach((field) => { @@ -699,11 +736,10 @@ const ProductExcel = ({ } }); - // ✅ Process non-mandatory mapped fields Object.entries(fieldMapping).forEach(([field, header]) => { if (!mandatoryFields.includes(field)) { - newRow[field] = headers.includes(header) ? row[header] ?? '' : ''; + newRow[field] = headers.includes(header) ? (row[header] ?? '') : ''; } }); @@ -716,7 +752,7 @@ const ProductExcel = ({ const isMandatory = mandatoryFields.includes(mappedField); if (!isMapped && !(header in newRow)) { - newRow[header] = isMandatory ? row[header] ?? '' : ''; + newRow[header] = isMandatory ? (row[header] ?? '') : ''; } }); return newRow; @@ -727,7 +763,11 @@ const ProductExcel = ({ } }, [fieldMapping, UploadedRawData, headers]); - + useEffect(() => { + if (AppId && BranchId && CompId) { + handleExportBulkdata(); + } + }, [AppId, BranchId, CompId]); // useEffect(() => { // if (UploadedRawData.length > 0) { // const updatedMappedData = UploadedRawData.map((row, index) => { @@ -765,30 +805,43 @@ const ProductExcel = ({ useEffect(() => { getFieldSetup(); - }, [productBulkUploadCatId]) + }, [productBulkUploadCatId]); const getFieldSetup = async () => { try { - const response = await dispatch(getFieldSetupData({ AppId, CompId, BranchId, categoryId: productBulkUploadCatId, Type: 'EB' })).unwrap(); + const response = await dispatch( + getFieldSetupData({ + AppId, + CompId, + BranchId, + categoryId: productBulkUploadCatId, + Type: 'EB', + }) + ).unwrap(); if (response?.data?.statusCode === 1) { - console.log(response?.data?.data?.[0]?.ConfigDtl, "Field Setup Data"); - setSelectedFields(response?.data?.data?.[0]?.ConfigDtl?.filter(c => c.ConfigId && c.Access === 'Y')?.map(c => c.ConfigId) || []); - setTableFieldPreferences(response?.data?.data?.[0]?.ConfigDtl?.map(c => ({ - value: c.ConfigId, - label: c.ConfigName, - access: c.Access - })) || []); + console.log(response?.data?.data?.[0]?.ConfigDtl, 'Field Setup Data'); + setSelectedFields( + response?.data?.data?.[0]?.ConfigDtl?.filter( + (c) => c.ConfigId && c.Access === 'Y' + )?.map((c) => c.ConfigId) || [] + ); + setTableFieldPreferences( + response?.data?.data?.[0]?.ConfigDtl?.map((c) => ({ + value: c.ConfigId, + label: c.ConfigName, + access: c.Access, + })) || [] + ); setFieldValues(response?.data?.data?.[0]?.ConfigDtl); } else { - setMessageType("error"); - setMessageData("Failed to fetch field setup"); + setMessageType('error'); + setMessageData('Failed to fetch field setup'); } } catch (error) { console.error('Error fetching field setup:', error); } }; - const handleFileUpload = (e) => { const file = e.target.files[0]; const reader = new FileReader(); @@ -800,7 +853,7 @@ const ProductExcel = ({ title: 'Invalid File Type', content: 'Only Excel files (.xls, .xlsx) are allowed.', }); - handleCancelData() + handleCancelData(); } else { reader.readAsDataURL(file); uploadAndProcessExcel(file); @@ -814,43 +867,107 @@ const ProductExcel = ({ // Programmatically trigger the file input click event fileInputRef.current.click(); }; + const getFieldValue = (product, field) => { + const aliasField = FIELD_ALIAS[field]; + return normalize(product[field] ?? product[aliasField]); + }; + const normalize = (value) => { + // Empty / invalid values + if ( + value === undefined || + value === null || + value === '' || + value === 'NaN-NaN-NaN' + ) { + return ''; + } + + // Y / N flags + if (value === 'Y') return true; + if (value === 'N') return false; + + // Numbers (handles "150", 150, "0") + if ( + typeof value === 'number' || + (typeof value === 'string' && + value.trim() !== '' && + !Number.isNaN(Number(value))) + ) { + return Number(value); + } + + // Default string + return String(value).trim(); + }; + const hashProduct = (product) => + COMPARE_FIELDS.map((field) => getFieldValue(product, field)).join('§'); + function findModifiedProducts(originalData, updatedData) { + + if (!originalData?.length || !updatedData?.length) return []; + + const originalHashMap = new Map(); + + for (const product of originalData) { + if (!product.ProdId) continue; + originalHashMap.set(product.ProdId, hashProduct(product)); + } + + // Step 2: Compare updated products + const modifiedProducts = []; + + for (const product of updatedData) { + if (!product.ProdId) continue; + + const originalHash = originalHashMap.get(product.ProdId); + if (!originalHash) continue; // new product, not modified + + const updatedHash = hashProduct(product); + + if (originalHash !== updatedHash) { + modifiedProducts.push(product); + } + } + + return modifiedProducts; + } + const FIELD_ALIAS = { + 'Product Variant Name': 'Product Varient Name', + }; const uploadAndProcessExcel = (file) => { - const reader = new FileReader(); reader.onload = (e) => { const data = new Uint8Array(e.target.result); - const workbook = read(data, { type: "array" }); + const workbook = read(data, { type: 'array' }); const worksheet = workbook.Sheets[workbook.SheetNames[0]]; - const jsonData = utils.sheet_to_json(worksheet, { header: 1, raw: false, - dateNF: "DD/MM/YY", + dateNF: 'DD/MM/YY', }); const nonEmptyRows = jsonData.filter((row) => - row.some((cell) => cell !== "") + row.some((cell) => cell !== '') ); const header = nonEmptyRows[0]; const rows = nonEmptyRows.slice(1); const dateFields = [ - "Available From", - "Available To", - "Manufacture Date", - "Expire Date", - "Stock Date", + 'Available From', + 'Available To', + 'Manufacture Date', + 'Expire Date', + 'Stock Date', ]; function convertToDisplayFormat(dateString) { const date = new Date(dateString); - const day = date.getDate().toString().padStart(2, "0"); - const month = (date.getMonth() + 1).toString().padStart(2, "0"); + const day = date.getDate().toString().padStart(2, '0'); + const month = (date.getMonth() + 1).toString().padStart(2, '0'); const year = date.getFullYear().toString(); return `${day}-${month}-${year}`; } @@ -871,22 +988,40 @@ const ProductExcel = ({ if (jsonData.length > 0) { const extractedHeaders = Object.keys(formattedData[0]); - const filteredData = formattedData.filter((item) => - !Object.values(item)?.includes("sample row") + const filteredData = formattedData.filter( + (item) => !Object.values(item)?.includes('sample row') ); // ✅ Add default variant name if missing const updatedData = filteredData.map((item) => ({ ...item, - "Product Varient Name": - item["Product Varient Name"] === undefined ? "Variant 1" : item["Product Varient Name"], - "Available To": - item["Available To"] == "NaN-NaN-NaN" ? "" : item["Available To"], + 'Product Varient Name': + item['Product Varient Name'] === undefined + ? 'Variant 1' + : item['Product Varient Name'], + 'Available To': + item['Available To'] == 'NaN-NaN-NaN' ? '' : item['Available To'], + ProdId: item['ProdId'] || null, })); + // Detect modified products + + const modifiedProducts = findModifiedProducts(OrginalData, updatedData); + const modifiedIds = new Set(modifiedProducts.map((p) => p.ProdId)); + const originalIds = new Set(OrginalData?.map((p) => p.ProdId) || []); + const markedData = updatedData + .map((item) => ({ + ...item, + isModified: + modifiedIds.has(item.ProdId) || !originalIds.has(item.ProdId), + })) + .sort((a, b) => b.isModified - a.isModified); + setUploadedRawData(markedData); + console.log(modifiedProducts, 'modifiedProducts'); + // ✅ Set only once with final data setHeaders(extractedHeaders); - setUploadedRawData(updatedData); // Final, cleaned and enriched data + autoMapFields(extractedHeaders); dispatch(uploadExcel({ file, jsonData: nonEmptyRows })); setWorksheet(worksheet); @@ -900,7 +1035,6 @@ const ProductExcel = ({ setWorksheet1(worksheet1); setDatas(formattedData); // Update Datas state here // setExcelData(formattedData); - }; reader.readAsArrayBuffer(file); @@ -932,7 +1066,6 @@ const ProductExcel = ({ setDatas(newData1); setExcelData(newData1); - }; const handleimage = () => { @@ -949,10 +1082,10 @@ const ProductExcel = ({ const response = await fetch(selectedImage.image); const datas = await response.blob(); const metadata = { - type: "image/jpeg", + type: 'image/jpeg', }; - const file = new File([datas], "image.jpg", metadata); + const file = new File([datas], 'image.jpg', metadata); const uploadImgData = await dispatch(uploadImage(file)).unwrap(); @@ -976,46 +1109,46 @@ const ProductExcel = ({ }; const fieldOrder = [ - "Product Name", - "Quantity", - "UOM", - "Sales Price", - "MRP", - "WholeSale Price", - "Category", - "Sub Category", - "Brand", - "Product Variant Name", - "Stock Available", - "Token Available", - "Product Type", - "Tax", - "Auto Generate QRCode", - "Add Qr Code", - "One Piece Available", - "OnePiece Price", - "Auto Generate One Piece Qrcode", - "Auto Generate One Piece Qrcode Number", - "CESS", - "HSN", - "Part Number", - "Rack", - "Manufacture Date", - "Expire Date", - "Available From", - "Available To" + 'Product Name', + 'Quantity', + 'UOM', + 'Sales Price', + 'MRP', + 'WholeSale Price', + 'Category', + 'Sub Category', + 'Brand', + 'Product Variant Name', + 'Stock Available', + 'Token Available', + 'Product Type', + 'Tax', + 'Auto Generate QRCode', + 'Add Qr Code', + 'One Piece Available', + 'OnePiece Price', + 'Auto Generate One Piece Qrcode', + 'Auto Generate One Piece Qrcode Number', + 'CESS', + 'HSN', + 'Part Number', + 'Rack', + 'Manufacture Date', + 'Expire Date', + 'Available From', + 'Available To', ]; const sortPreferredFields = (fields) => { const fieldMap = {}; - fields.forEach(field => { + fields.forEach((field) => { fieldMap[field.ConfigName] = field; }); const sorted = []; - fieldOrder.forEach(name => { - if (fieldMap[name] && fieldMap[name].Access === "Y") { + fieldOrder.forEach((name) => { + if (fieldMap[name] && fieldMap[name].Access === 'Y') { sorted.push(fieldMap[name]); } }); @@ -1025,14 +1158,22 @@ const ProductExcel = ({ // Usage inside your Fielddatas const Fielddatas = async () => { - const res = await dispatch(getCommonAppPreference(AppId)).unwrap(); - const productbulkUploadCatId = res?.data?.data?.[0]?.PreferenceDetails?.find( - p => p?.PreferredCatName?.toLowerCase() === "product bulk upload" - )?.PreferredCatId; + const productbulkUploadCatId = + res?.data?.data?.[0]?.PreferenceDetails?.find( + (p) => p?.PreferredCatName?.toLowerCase() === 'product bulk upload' + )?.PreferredCatId; - const response = await dispatch(getFieldSetupData({ AppId, CompId, BranchId, categoryId: productbulkUploadCatId, Type: 'EB' })).unwrap(); + const response = await dispatch( + getFieldSetupData({ + AppId, + CompId, + BranchId, + categoryId: productbulkUploadCatId, + Type: 'EB', + }) + ).unwrap(); const productBulkUploadFields = response?.data?.data?.[0]?.ConfigDtl || []; const sortedFields = sortPreferredFields(productBulkUploadFields); @@ -1041,357 +1182,471 @@ const ProductExcel = ({ }; const handleDownload = async () => { - const workbook = new ExcelJS.Workbook(); - const worksheet = workbook.addWorksheet("Sheet1"); - const worksheet1 = workbook.addWorksheet("Sheet2"); + const worksheet = workbook.addWorksheet('Sheet1'); + const worksheet1 = workbook.addWorksheet('Sheet2'); const headerStyle = { font: { bold: true }, border: { - top: { style: "thin" }, - left: { style: "thin" }, - bottom: { style: "thin" }, - right: { style: "thin" }, + top: { style: 'thin' }, + left: { style: 'thin' }, + bottom: { style: 'thin' }, + right: { style: 'thin' }, }, - alignment: { horizontal: "center", vertical: "middle" }, + alignment: { horizontal: 'center', vertical: 'middle' }, }; // Define all possible field configurations const sampleData = getApplicationSampleData(appName); - console.log(sampleData, "sampleData") + console.log(sampleData, 'sampleData'); const fieldConfigs = { - 'ProdName': { - header: "Product Name", - key: "ProdName", + ProdId: { + header: 'ProdId', + key: 'ProdId', + width: 15, + style: { + ...headerStyle, + font: { bold: true, color: { argb: '#000000' } }, + }, + validation: null, + sampleValue: '', + headerColor: 'D3D3D3', + locked: true, + }, + ProdName: { + header: 'Product Name', + key: 'ProdName', width: 20, Height: 20, - style: { ...headerStyle, font: { bold: true, color: { argb: "#000000" } } }, + style: { + ...headerStyle, + font: { bold: true, color: { argb: '#000000' } }, + }, validation: null, - sampleValue: sampleData?.productName || "Sample Product Name", - headerColor: "FF2929" + sampleValue: sampleData?.productName || 'Sample Product Name', + headerColor: 'FF2929', }, - 'Size': { - header: "Quantity", - key: "Size", + Size: { + header: 'Quantity', + key: 'Size', width: 10, - style: { ...headerStyle, font: { bold: true, color: { argb: "#000000" } } }, + style: { + ...headerStyle, + font: { bold: true, color: { argb: '#000000' } }, + }, validation: { - type: "custom", + type: 'custom', allowBlank: true, - formulae: ["ISNUMBER({COLUMN}{ROW})"], + formulae: ['ISNUMBER({COLUMN}{ROW})'], showErrorMessage: true, - errorTitle: "Validation Error", - error: "Please enter a Number.", + errorTitle: 'Validation Error', + error: 'Please enter a Number.', }, sampleValue: sampleData?.quantity || 1, - headerColor: "FF2929" + headerColor: 'FF2929', }, - 'UOM': { - header: "UOM", - key: "UOM", + UOM: { + header: 'UOM', + key: 'UOM', width: 10, - style: { ...headerStyle, font: { bold: true, color: { argb: "#000000" } } }, - validation: { - type: "list", - allowBlank: true, - formulae: ['"' + (typeof Unit !== 'undefined' ? Unit.join(",") : "KGS,PCS,LITER") + '"'], + style: { + ...headerStyle, + font: { bold: true, color: { argb: '#000000' } }, }, - sampleValue: sampleData?.uom || "KGS", - headerColor: "FF2929" - }, - 'SellPrice': { - header: "Sales Price", - key: "SellPrice", - width: 15, - style: { ...headerStyle, font: { bold: true, color: { argb: "#000000" } } }, validation: { - type: "custom", + type: 'list', allowBlank: true, - formulae: ["ISNUMBER({COLUMN}{ROW})"], + formulae: [ + '"' + + (typeof Unit !== 'undefined' ? Unit.join(',') : 'KGS,PCS,LITER') + + '"', + ], + }, + sampleValue: sampleData?.uom || 'KGS', + headerColor: 'FF2929', + }, + SellPrice: { + header: 'Sales Price', + key: 'SellPrice', + width: 15, + style: { + ...headerStyle, + font: { bold: true, color: { argb: '#000000' } }, + }, + validation: { + type: 'custom', + allowBlank: true, + formulae: ['ISNUMBER({COLUMN}{ROW})'], showErrorMessage: true, - errorTitle: "Validation Error", - error: "Please enter a Number.", + errorTitle: 'Validation Error', + error: 'Please enter a Number.', }, sampleValue: sampleData?.salesPrice || 100, - headerColor: "FF2929" + headerColor: 'FF2929', }, - 'ProdCat': { - header: "Category", - key: "ProdCat", + ProdCat: { + header: 'Category', + key: 'ProdCat', width: 20, - style: { ...headerStyle, font: { bold: true, color: { argb: "#000000" } } }, - validation: { - type: "list", - allowBlank: true, - formulae: ['"' + (typeof CategoryNames !== 'undefined' ? CategoryNames.join(",") : "Sample Category") + '"'], + style: { + ...headerStyle, + font: { bold: true, color: { argb: '#000000' } }, }, - sampleValue: sampleData?.category || "Sample Category", - headerColor: "FF2929" + validation: { + type: 'list', + allowBlank: true, + formulae: [ + '"' + + (typeof CategoryNames !== 'undefined' + ? CategoryNames.join(',') + : 'Sample Category') + + '"', + ], + }, + sampleValue: sampleData?.category || 'Sample Category', + headerColor: 'FF2929', }, - 'ProdSubCat': { - header: "Sub Category", - key: "ProdSubCat", + ProdSubCat: { + header: 'Sub Category', + key: 'ProdSubCat', width: 20, - style: { ...headerStyle, font: { bold: true, color: { argb: "#000000" } } }, + style: { + ...headerStyle, + font: { bold: true, color: { argb: '#000000' } }, + }, validation: null, - sampleValue: sampleData?.subCategory || "Sample Sub Category", - headerColor: "52c41a" + sampleValue: sampleData?.subCategory || 'Sample Sub Category', + headerColor: '52c41a', }, - 'Brand': { - header: "Brand", - key: "Brand", + Brand: { + header: 'Brand', + key: 'Brand', width: 20, - style: { ...headerStyle, font: { bold: true, color: { argb: "#000000" } } }, + style: { + ...headerStyle, + font: { bold: true, color: { argb: '#000000' } }, + }, validation: null, - sampleValue: sampleData?.brand || "Sample Brand", - headerColor: "52c41a" + sampleValue: sampleData?.brand || 'Sample Brand', + headerColor: '52c41a', }, - 'ProdVarientName': { - header: "Product Variant Name", - key: "ProdVarientName", + ProdVarientName: { + header: 'Product Variant Name', + key: 'ProdVarientName', width: 20, Height: 20, - style: { ...headerStyle, font: { bold: true, color: { argb: "#000000" } } }, + style: { + ...headerStyle, + font: { bold: true, color: { argb: '#000000' } }, + }, validation: null, - sampleValue: sampleData?.variantName || "Sample Variant Name", - headerColor: "52c41a" + sampleValue: sampleData?.variantName || 'Sample Variant Name', + headerColor: '52c41a', }, - 'MRP': { - header: "MRP", - key: "MRP", + MRP: { + header: 'MRP', + key: 'MRP', width: 10, - style: { ...headerStyle, font: { bold: true, color: { argb: "#000000" } } }, + style: { + ...headerStyle, + font: { bold: true, color: { argb: '#000000' } }, + }, validation: { - type: "custom", + type: 'custom', allowBlank: true, - formulae: ["ISNUMBER({COLUMN}{ROW})"], + formulae: ['ISNUMBER({COLUMN}{ROW})'], showErrorMessage: true, - errorTitle: "Validation Error", - error: "Please enter a Number.", + errorTitle: 'Validation Error', + error: 'Please enter a Number.', }, sampleValue: sampleData?.mrp || 100, - headerColor: "52c41a" + headerColor: '52c41a', }, - 'WhSalePrice': { - header: "WholeSale Price", - key: "WhSalePrice", + WhSalePrice: { + header: 'WholeSale Price', + key: 'WhSalePrice', width: 15, - style: { ...headerStyle, font: { bold: true, color: { argb: "#000000" } } }, + style: { + ...headerStyle, + font: { bold: true, color: { argb: '#000000' } }, + }, validation: { - type: "custom", + type: 'custom', allowBlank: true, - formulae: ["ISNUMBER({COLUMN}{ROW})"], + formulae: ['ISNUMBER({COLUMN}{ROW})'], showErrorMessage: true, - errorTitle: "Validation Error", - error: "Please enter a Number.", + errorTitle: 'Validation Error', + error: 'Please enter a Number.', }, sampleValue: 100, - headerColor: "52c41a" + headerColor: '52c41a', }, - 'StockAvailable': { - header: "Stock Available", - key: "StockAvailable", + StockAvailable: { + header: 'Stock Available', + key: 'StockAvailable', width: 20, - style: { ...headerStyle, font: { bold: true, color: { argb: "#000000" } } }, + style: { + ...headerStyle, + font: { bold: true, color: { argb: '#000000' } }, + }, validation: { - type: "list", + type: 'list', allowBlank: true, formulae: ['"Yes,No"'], }, - sampleValue: "Choose Yes or No", - headerColor: "52c41a" + sampleValue: 'Choose Yes or No', + headerColor: '52c41a', }, - 'OfferPrice': { - header: "Token Available", - key: "OfferPrice", + OfferPrice: { + header: 'Token Available', + key: 'OfferPrice', width: 15, - style: { ...headerStyle, font: { bold: true, color: { argb: "#000000" } } }, + style: { + ...headerStyle, + font: { bold: true, color: { argb: '#000000' } }, + }, validation: { - type: "list", + type: 'list', allowBlank: true, formulae: ['"Yes,No"'], }, - sampleValue: "Choose Yes or No", - headerColor: "52c41a" + sampleValue: 'Choose Yes or No', + headerColor: '52c41a', }, - 'Supplier': { - header: "Product Type", - key: "Supplier", + Supplier: { + header: 'Product Type', + key: 'Supplier', width: 20, - style: { ...headerStyle, font: { bold: true, color: { argb: "#000000" } } }, + style: { + ...headerStyle, + font: { bold: true, color: { argb: '#000000' } }, + }, validation: { - type: "list", + type: 'list', allowBlank: true, formulae: ['"Product"'], }, - sampleValue: "Product", - headerColor: "52c41a" + sampleValue: 'Product', + headerColor: '52c41a', }, - 'TaxId': { - header: "Tax", - key: "TaxId", + TaxId: { + header: 'Tax', + key: 'TaxId', width: 20, - style: { ...headerStyle, font: { bold: true, color: { argb: "#000000" } } }, - validation: { - type: "list", - allowBlank: true, - formulae: ['"' + (typeof TaxDatas !== 'undefined' ? TaxDatas.map(item => item.replace(/,/g, "").replace("-", "-").trim()).join(",") : "NIL - 0%") + '"'], + style: { + ...headerStyle, + font: { bold: true, color: { argb: '#000000' } }, }, - sampleValue: "NIL - 0%", - headerColor: "52c41a" - }, - 'AutoGenerateQr': { - header: "Auto Generate Qrcode", - key: "AutoGenerateQr", - width: 20, - style: { ...headerStyle, font: { bold: true, color: { argb: "#000000" } } }, validation: { - type: "list", + type: 'list', + allowBlank: true, + formulae: [ + '"' + + (typeof TaxDatas !== 'undefined' + ? TaxDatas.map((item) => + item.replace(/,/g, '').replace('-', '-').trim() + ).join(',') + : 'NIL - 0%') + + '"', + ], + }, + sampleValue: 'NIL - 0%', + headerColor: '52c41a', + }, + AutoGenerateQr: { + header: 'Auto Generate Qrcode', + key: 'AutoGenerateQr', + width: 20, + style: { + ...headerStyle, + font: { bold: true, color: { argb: '#000000' } }, + }, + validation: { + type: 'list', allowBlank: true, formulae: ['"Yes,No"'], }, - sampleValue: "Choose Yes or No", - headerColor: "52c41a" + sampleValue: 'Choose Yes or No', + headerColor: '52c41a', }, - 'AddQrCode': { - header: "Add Qr Code", - key: "AddQrCode", + AddQrCode: { + header: 'Add Qr Code', + key: 'AddQrCode', width: 20, - style: { ...headerStyle, font: { bold: true, color: { argb: "#000000" } } }, + style: { + ...headerStyle, + font: { bold: true, color: { argb: '#000000' } }, + }, validation: null, - sampleValue: "Sample Qr eg:12345", - headerColor: "52c41a" + sampleValue: 'Sample Qr eg:12345', + headerColor: '52c41a', }, - 'SpecialPrice': { - header: "One Piece Available", - key: "SpecialPrice", + SpecialPrice: { + header: 'One Piece Available', + key: 'SpecialPrice', width: 20, - style: { ...headerStyle, font: { bold: true, color: { argb: "#000000" } } }, + style: { + ...headerStyle, + font: { bold: true, color: { argb: '#000000' } }, + }, validation: { - type: "list", + type: 'list', allowBlank: true, formulae: ['"Yes,No"'], }, - sampleValue: "Choose Yes or No", - headerColor: "52c41a" + sampleValue: 'Choose Yes or No', + headerColor: '52c41a', }, - 'OnePiecePrice': { - header: "OnePiece Price", - key: "StockAvailable", + OnePiecePrice: { + header: 'OnePiece Price', + key: 'StockAvailable', width: 20, - style: { ...headerStyle, font: { bold: true, color: { argb: "#000000" } } }, + style: { + ...headerStyle, + font: { bold: true, color: { argb: '#000000' } }, + }, validation: { - type: "custom", + type: 'custom', allowBlank: true, - formulae: ["ISNUMBER({COLUMN}{ROW})"], + formulae: ['ISNUMBER({COLUMN}{ROW})'], showErrorMessage: true, - errorTitle: "Validation Error", - error: "Please enter a Number.", + errorTitle: 'Validation Error', + error: 'Please enter a Number.', }, - sampleValue: "OnePiecePrice", - headerColor: "52c41a" + sampleValue: 'OnePiecePrice', + headerColor: '52c41a', }, - 'AutoGenOnePieceQr': { - header: "Auto Generate One Piece Qrcode", - key: "StockDate", + AutoGenOnePieceQr: { + header: 'Auto Generate One Piece Qrcode', + key: 'StockDate', width: 30, - style: { ...headerStyle, font: { bold: true, color: { argb: "#000000" } } }, + style: { + ...headerStyle, + font: { bold: true, color: { argb: '#000000' } }, + }, validation: { - type: "list", + type: 'list', allowBlank: true, formulae: ['"Yes,No"'], }, - sampleValue: "Choose Yes or No", - headerColor: "52c41a" + sampleValue: 'Choose Yes or No', + headerColor: '52c41a', }, - 'AutoGenOnePieceQrNum': { - header: "Auto Generate One Piece Qrcode Number", - key: "StockDate", + AutoGenOnePieceQrNum: { + header: 'Auto Generate One Piece Qrcode Number', + key: 'StockDate', width: 40, - style: { ...headerStyle, font: { bold: true, color: { argb: "#000000" } } }, + style: { + ...headerStyle, + font: { bold: true, color: { argb: '#000000' } }, + }, validation: null, - sampleValue: "Qr Number eg:ABC123", - headerColor: "52c41a" + sampleValue: 'Qr Number eg:ABC123', + headerColor: '52c41a', }, - 'CESS': { - header: "CESS", - key: "CESS", + CESS: { + header: 'CESS', + key: 'CESS', width: 20, - style: { ...headerStyle, font: { bold: true, color: { argb: "#000000" } } }, + style: { + ...headerStyle, + font: { bold: true, color: { argb: '#000000' } }, + }, validation: null, - sampleValue: "Cess eg:0.5", - headerColor: "52c41a" + sampleValue: 'Cess eg:0.5', + headerColor: '52c41a', }, - 'HSNCode': { - header: "HSN", - key: "HSNCode", + HSNCode: { + header: 'HSN', + key: 'HSNCode', width: 20, - style: { ...headerStyle, font: { bold: true, color: { argb: "#000000" } } }, + style: { + ...headerStyle, + font: { bold: true, color: { argb: '#000000' } }, + }, validation: null, - sampleValue: "Hsn Number eg:100190", - headerColor: "52c41a" + sampleValue: 'Hsn Number eg:100190', + headerColor: '52c41a', }, - 'PartNumber': { - header: "Part Number", - key: "PartNumber", + PartNumber: { + header: 'Part Number', + key: 'PartNumber', width: 20, - style: { ...headerStyle, font: { bold: true, color: { argb: "#000000" } } }, + style: { + ...headerStyle, + font: { bold: true, color: { argb: '#000000' } }, + }, validation: null, - sampleValue: "Part Number eg:1234-5678", - headerColor: "52c41a" + sampleValue: 'Part Number eg:1234-5678', + headerColor: '52c41a', }, - 'Rack': { - header: "Rack", - key: "Rack", + Rack: { + header: 'Rack', + key: 'Rack', width: 20, - style: { ...headerStyle, font: { bold: true, color: { argb: "#000000" } } }, + style: { + ...headerStyle, + font: { bold: true, color: { argb: '#000000' } }, + }, validation: null, - sampleValue: "Rack Number eg:2200302", - headerColor: "52c41a" + sampleValue: 'Rack Number eg:2200302', + headerColor: '52c41a', }, - 'ManufDate': { - header: "Manufacture Date", - key: "ManufDate DATETIME", + ManufDate: { + header: 'Manufacture Date', + key: 'ManufDate DATETIME', width: 20, - style: { ...headerStyle, font: { bold: true, color: { argb: "#000000" } } }, + style: { + ...headerStyle, + font: { bold: true, color: { argb: '#000000' } }, + }, validation: null, sampleValue: new Date(), - headerColor: "52c41a" + headerColor: '52c41a', }, - 'ExpDate': { - header: "Expire Date", - key: "ExpDate DATETIME", + ExpDate: { + header: 'Expire Date', + key: 'ExpDate DATETIME', width: 20, - style: { ...headerStyle, font: { bold: true, color: { argb: "#000000" } } }, + style: { + ...headerStyle, + font: { bold: true, color: { argb: '#000000' } }, + }, validation: null, sampleValue: new Date(), - headerColor: "52c41a" + headerColor: '52c41a', }, - 'AvailableFrom': { - header: "Available From", - key: "AvailableFrom TIME", + AvailableFrom: { + header: 'Available From', + key: 'AvailableFrom TIME', width: 20, - style: { ...headerStyle, font: { bold: true, color: { argb: "#000000" } } }, + style: { + ...headerStyle, + font: { bold: true, color: { argb: '#000000' } }, + }, validation: null, sampleValue: new Date(), - headerColor: "52c41a" + headerColor: '52c41a', }, - 'AvailableTo': { - header: "Available To", - key: "AvailableTo TIME", + AvailableTo: { + header: 'Available To', + key: 'AvailableTo TIME', width: 20, - style: { ...headerStyle, font: { bold: true, color: { argb: "#000000" } } }, + style: { + ...headerStyle, + font: { bold: true, color: { argb: '#000000' } }, + }, validation: null, sampleValue: new Date(), - headerColor: "52c41a" - } + headerColor: '52c41a', + }, }; function getExcelColumnLetter(colIndex) { - let temp = ""; - let letter = ""; + let temp = ''; + let letter = ''; while (colIndex > 0) { temp = (colIndex - 1) % 26; letter = String.fromCharCode(temp + 65) + letter; @@ -1400,44 +1655,44 @@ const ProductExcel = ({ return letter; } - const mandatoryFields = ["ProdName", "Size", "UOM", "SellPrice", "ProdCat"]; + const mandatoryFields = ['ProdName', 'Size', 'UOM', 'SellPrice', 'ProdCat']; const apiToInternalFieldMap = { - "Product Name": "ProdName", - "Quantity": "Size", - "UOM": "UOM", - "Sales Price": "SellPrice", - "MRP": "MRP", - "WholeSale Price": "WhSalePrice", - "Category": "ProdCat", - "Sub Category": "ProdSubCat", - "Brand": "Brand", - "Product Variant Name": "ProdVarientName", - "Token Available": "OfferPrice", - "Stock Available": "StockAvailable", - "Tax": "TaxId", - "Auto Generate QRCode": "AutoGenerateQr", - "Add Qr Code": "AddQrCode", - "One Piece Available": "SpecialPrice", - "OnePiece Price": "OnePiecePrice", - "Auto Generate One Piece Qrcode": "AutoGenOnePieceQr", - "Auto Generate One Piece Qrcode Number": "AutoGenOnePieceQrNum", - "CESS": "CESS", - "HSN": "HSNCode", - "Part Number": "PartNumber", - "Rack": "Rack", - "Manufacture Date": "ManufDate", - "Expire Date": "ExpDate", - "Available From": "AvailableFrom", - "Available To": "AvailableTo", - "Product Type": "Supplier" + 'Product Name': 'ProdName', + Quantity: 'Size', + UOM: 'UOM', + 'Sales Price': 'SellPrice', + MRP: 'MRP', + 'WholeSale Price': 'WhSalePrice', + Category: 'ProdCat', + 'Sub Category': 'ProdSubCat', + Brand: 'Brand', + 'Product Variant Name': 'ProdVarientName', + 'Token Available': 'OfferPrice', + 'Stock Available': 'StockAvailable', + Tax: 'TaxId', + 'Auto Generate QRCode': 'AutoGenerateQr', + 'Add Qr Code': 'AddQrCode', + 'One Piece Available': 'SpecialPrice', + 'OnePiece Price': 'OnePiecePrice', + 'Auto Generate One Piece Qrcode': 'AutoGenOnePieceQr', + 'Auto Generate One Piece Qrcode Number': 'AutoGenOnePieceQrNum', + CESS: 'CESS', + HSN: 'HSNCode', + 'Part Number': 'PartNumber', + Rack: 'Rack', + 'Manufacture Date': 'ManufDate', + 'Expire Date': 'ExpDate', + 'Available From': 'AvailableFrom', + 'Available To': 'AvailableTo', + 'Product Type': 'Supplier', }; // Define dependent relationships const dependentFieldMap = { - "Auto Generate QRCode": "Add Qr Code", - "One Piece Available": "OnePiece Price", - "Auto Generate One Piece Qrcode": "Auto Generate One Piece Qrcode Number" + 'Auto Generate QRCode': 'Add Qr Code', + 'One Piece Available': 'OnePiece Price', + 'Auto Generate One Piece Qrcode': 'Auto Generate One Piece Qrcode Number', }; // Step 1: Sort preferred fields @@ -1447,14 +1702,14 @@ const ProductExcel = ({ const preferredFieldKeys = []; const preferredFieldSet = new Set(); - sortedPreferredFields.forEach(field => { + sortedPreferredFields.forEach((field) => { const fieldName = field.ConfigName; const status = field.Access; // Skip dependent fields for now if (Object.values(dependentFieldMap).includes(fieldName)) return; - if (status === "Y") { + if (status === 'Y') { const internalKey = apiToInternalFieldMap[fieldName]; if (internalKey) { preferredFieldKeys.push(internalKey); @@ -1464,7 +1719,8 @@ const ProductExcel = ({ // If this field has a dependent field, and it's enabled, add dependent too const dependentFieldName = dependentFieldMap[fieldName]; if (dependentFieldName) { - const dependentInternalKey = apiToInternalFieldMap[dependentFieldName]; + const dependentInternalKey = + apiToInternalFieldMap[dependentFieldName]; if (dependentInternalKey) { preferredFieldKeys.push(dependentInternalKey); } @@ -1473,25 +1729,30 @@ const ProductExcel = ({ }); // Step 3: Merge Mandatory + Preferred (no duplicates) - const finalFieldKeys = [...mandatoryFields, ...preferredFieldKeys.filter(key => !mandatoryFields.includes(key))]; + const finalFieldKeys = [ + ...mandatoryFields, + ...preferredFieldKeys.filter((key) => !mandatoryFields.includes(key)), + ]; // Step 4: Map to ExcelJS column configs - const selectedColumns = finalFieldKeys.map(fieldKey => { - const config = fieldConfigs[fieldKey]; - if (!config) { - console.warn(`Field configuration not found for: ${fieldKey}`); - return null; - } - return config; - }).filter(Boolean); + const selectedColumns = finalFieldKeys + .map((fieldKey) => { + const config = fieldConfigs[fieldKey]; + if (!config) { + console.warn(`Field configuration not found for: ${fieldKey}`); + return null; + } + return config; + }) + .filter(Boolean); selectedColumns.push({ - header: "__isSampleRow", - key: "__isSampleRow", + header: '__isSampleRow', + key: '__isSampleRow', width: 10, // width can be any value - style: { font: { size: 1 }, alignment: { horizontal: "left" } }, - sampleValue: "sample row", // Mark sample row - headerColor: "FFFFFF" + style: { font: { size: 1 }, alignment: { horizontal: 'left' } }, + sampleValue: 'sample row', // Mark sample row + headerColor: 'FFFFFF', }); worksheet.columns = selectedColumns; @@ -1504,10 +1765,10 @@ const ProductExcel = ({ headerCell.style = { ...config.style, fill: { - type: "pattern", - pattern: "solid", - fgColor: { argb: config.headerColor } - } + type: 'pattern', + pattern: 'solid', + fgColor: { argb: config.headerColor }, + }, }; }); @@ -1530,8 +1791,10 @@ const ProductExcel = ({ let validation = { ...config.validation }; if (validation.formulae) { - validation.formulae = validation.formulae.map(formula => - formula.replace('{COLUMN}', columnLetter).replace('{ROW}', rowNumber.toString()) + validation.formulae = validation.formulae.map((formula) => + formula + .replace('{COLUMN}', columnLetter) + .replace('{ROW}', rowNumber.toString()) ); } @@ -1540,7 +1803,6 @@ const ProductExcel = ({ } }); - // Add empty rows for data entry for (let i = 1; i <= 1000; i++) { worksheet.addRow({}); @@ -1550,8 +1812,9 @@ const ProductExcel = ({ // First, unlock ALL cells in the worksheet for (let rowNum = 1; rowNum <= worksheet.rowCount; rowNum++) { const row = worksheet.getRow(rowNum); - row.eachCell({ includeEmpty: true }, (cell) => { - cell.protection = { locked: false }; + row.eachCell({ includeEmpty: true }, (cell, colNumber) => { + const config = selectedColumns[colNumber - 1]; + cell.protection = { locked: config?.locked || false }; }); } @@ -1566,353 +1829,436 @@ const ProductExcel = ({ // Protect the worksheet await worksheet.protect('', { - selectLockedCells: true, // Allow selecting locked cells (header/sample) - selectUnlockedCells: true, // Allow selecting unlocked cells (data rows) + selectLockedCells: true, // Allow selecting locked cells (header/sample) + selectUnlockedCells: true, // Allow selecting unlocked cells (data rows) formatCells: false, formatColumns: false, formatRows: false, insertColumns: false, insertRows: false, deleteColumns: false, - deleteRows: false + deleteRows: false, }); // Configure Sheet2 with all original columns and functionality worksheet1.columns = [ { - header: "Category Id", - key: "CategoryId", + header: 'Category Id', + key: 'CategoryId', width: 15, - style: { ...headerStyle, font: { bold: true, color: { argb: "#000000" } } }, + style: { + ...headerStyle, + font: { bold: true, color: { argb: '#000000' } }, + }, }, { - header: "Category Name", - key: "Category", + header: 'Category Name', + key: 'Category', width: 30, - style: { ...headerStyle, font: { bold: true, color: { argb: "#000000" } } }, + style: { + ...headerStyle, + font: { bold: true, color: { argb: '#000000' } }, + }, }, { - header: "SUBCAT DATAS OF PARTICULAR CATEGORY", - key: "SDPC", + header: 'SUBCAT DATAS OF PARTICULAR CATEGORY', + key: 'SDPC', width: 180, - style: { ...headerStyle, font: { bold: true, color: { argb: "#000000" } } }, + style: { + ...headerStyle, + font: { bold: true, color: { argb: '#000000' } }, + }, }, { - header: "SUBCAT ID", - key: "SubcayID", + header: 'SUBCAT ID', + key: 'SubcayID', width: 10, - style: { ...headerStyle, font: { bold: true, color: { argb: "#000000" } } }, + style: { + ...headerStyle, + font: { bold: true, color: { argb: '#000000' } }, + }, }, { - header: "Sub Category name", - key: "SubCategory", + header: 'Sub Category name', + key: 'SubCategory', width: 25, - style: { ...headerStyle, font: { bold: true, color: { argb: "#000000" } } }, + style: { + ...headerStyle, + font: { bold: true, color: { argb: '#000000' } }, + }, }, { - header: "", - key: "", + header: '', + key: '', width: 5, - style: { ...headerStyle, font: { bold: true, color: { argb: "#000000" } } }, + style: { + ...headerStyle, + font: { bold: true, color: { argb: '#000000' } }, + }, }, { - header: "SUBCAT NUMFID", - key: "SubcatnumfId", + header: 'SUBCAT NUMFID', + key: 'SubcatnumfId', width: 20, - style: { ...headerStyle, font: { bold: true, color: { argb: "#000000" } } }, + style: { + ...headerStyle, + font: { bold: true, color: { argb: '#000000' } }, + }, }, { - header: "", - key: "smallIcon", + header: '', + key: 'smallIcon', width: 5, - style: { ...headerStyle, font: { bold: true, color: { argb: "#000000" } } }, + style: { + ...headerStyle, + font: { bold: true, color: { argb: '#000000' } }, + }, }, { - header: "Brand ID", - key: "BrandId", + header: 'Brand ID', + key: 'BrandId', width: 20, - style: { ...headerStyle, font: { bold: true, color: { argb: "#000000" } } }, + style: { + ...headerStyle, + font: { bold: true, color: { argb: '#000000' } }, + }, }, { - header: "Brand Name", - key: "Brandname", + header: 'Brand Name', + key: 'Brandname', width: 20, - style: { ...headerStyle, font: { bold: true, color: { argb: "#000000" } } }, + style: { + ...headerStyle, + font: { bold: true, color: { argb: '#000000' } }, + }, }, { - header: "Brand NumfId", - key: "BrandnumfId", + header: 'Brand NumfId', + key: 'BrandnumfId', width: 20, - style: { ...headerStyle, font: { bold: true, color: { argb: "#000000" } } }, + style: { + ...headerStyle, + font: { bold: true, color: { argb: '#000000' } }, + }, }, { - header: "", - key: "smallIcon", + header: '', + key: 'smallIcon', width: 5, - style: { ...headerStyle, font: { bold: true, color: { argb: "#000000" } } }, + style: { + ...headerStyle, + font: { bold: true, color: { argb: '#000000' } }, + }, }, { - header: "Brand Details", - key: "Branddetails", + header: 'Brand Details', + key: 'Branddetails', width: 150, - style: { ...headerStyle, font: { bold: true, color: { argb: "#000000" } } }, + style: { + ...headerStyle, + font: { bold: true, color: { argb: '#000000' } }, + }, }, ]; // Add data to Sheet2 for (let i = 1; i <= 100; i++) { worksheet1.addRow({ - CategoryId: "", - Category: "", - SDPC: "", - SubcayID: "", - SubCategory: "", - SubcatnumfId: "", - BrandId: "", - Brandname: "", - BrandnumfId: "", - Branddetails: "", + CategoryId: '', + Category: '', + SDPC: '', + SubcayID: '', + SubCategory: '', + SubcatnumfId: '', + BrandId: '', + Brandname: '', + BrandnumfId: '', + Branddetails: '', }); } // All the original dropdown and validation logic for Sheet2 const dropdownOptions = { - Option1: ["Yes", "No"], - Option2: ["Product"], - Option3: ["ValueX", "ValueY", "ValueZ"], + Option1: ['Yes', 'No'], + Option2: ['Product'], + Option3: ['ValueX', 'ValueY', 'ValueZ'], }; - const selectedOptionA = "Option1"; - const selectedOptionB = "Option2"; + const selectedOptionA = 'Option1'; + const selectedOptionB = 'Option2'; // Create category and brand data maps (original logic) const categoryDataMap = {}; if (typeof CategoryId !== 'undefined') { CategoryId.forEach((categoryId, index) => { - categoryDataMap[categoryId] = typeof SubCatData !== 'undefined' ? SubCatData[index] : ''; + categoryDataMap[categoryId] = + typeof SubCatData !== 'undefined' ? SubCatData[index] : ''; }); } const BrandDataMap = {}; if (typeof AllBrandId !== 'undefined') { AllBrandId.forEach((AllBrandId, index) => { - BrandDataMap[AllBrandId] = typeof SubCatData !== 'undefined' ? SubCatData[index] : ''; + BrandDataMap[AllBrandId] = + typeof SubCatData !== 'undefined' ? SubCatData[index] : ''; }); } // Apply all original Sheet2 validations and logic if (typeof CategoryId !== 'undefined') { - worksheet1.getColumn("A").eachCell({ includeEmpty: true }, function (cell, rowNumber) { - if (rowNumber > 1) { - const dynamicValidValues = '"' + CategoryId.join(",") + '"'; - const defaultCategoryId = CategoryId[rowNumber - 2]; - cell.value = defaultCategoryId; + worksheet1 + .getColumn('A') + .eachCell({ includeEmpty: true }, function (cell, rowNumber) { + if (rowNumber > 1) { + const dynamicValidValues = '"' + CategoryId.join(',') + '"'; + const defaultCategoryId = CategoryId[rowNumber - 2]; + cell.value = defaultCategoryId; - cell.dataValidation = { - type: "list", - allowBlank: true, - formulae: [dynamicValidValues], - }; - } - }); + cell.dataValidation = { + type: 'list', + allowBlank: true, + formulae: [dynamicValidValues], + }; + } + }); } if (typeof CategoryNames !== 'undefined') { - worksheet1.getColumn("B").eachCell({ includeEmpty: true }, function (cell, rowNumber) { - if (rowNumber > 1) { - const dynamicValidValues = '"' + CategoryNames.join(",") + '"'; - const defaultCategoryName = CategoryNames[rowNumber - 2]; - cell.value = defaultCategoryName; + worksheet1 + .getColumn('B') + .eachCell({ includeEmpty: true }, function (cell, rowNumber) { + if (rowNumber > 1) { + const dynamicValidValues = '"' + CategoryNames.join(',') + '"'; + const defaultCategoryName = CategoryNames[rowNumber - 2]; + cell.value = defaultCategoryName; - cell.dataValidation = { - type: "list", - allowBlank: true, - formulae: [dynamicValidValues], - }; - } - }); + cell.dataValidation = { + type: 'list', + allowBlank: true, + formulae: [dynamicValidValues], + }; + } + }); } if (typeof SubcatId !== 'undefined') { - worksheet1.getColumn("D").eachCell({ includeEmpty: true }, function (cell, rowNumber) { - if (rowNumber > 1) { - const dynamicValidValues = '"' + SubcatId.join(",") + '"'; - const defaultCategorysubName = SubcatId[rowNumber - 2]; - cell.value = defaultCategorysubName; + worksheet1 + .getColumn('D') + .eachCell({ includeEmpty: true }, function (cell, rowNumber) { + if (rowNumber > 1) { + const dynamicValidValues = '"' + SubcatId.join(',') + '"'; + const defaultCategorysubName = SubcatId[rowNumber - 2]; + cell.value = defaultCategorysubName; - cell.dataValidation = { - type: "list", - allowBlank: true, - formulae: [dynamicValidValues], - }; - } - }); + cell.dataValidation = { + type: 'list', + allowBlank: true, + formulae: [dynamicValidValues], + }; + } + }); } if (typeof SubCatData !== 'undefined') { - worksheet1.getColumn("E").eachCell({ includeEmpty: true }, function (cell, rowNumber) { - if (rowNumber > 1) { - const dynamicValidValues = '"' + SubCatData.join(",") + '"'; - const defaultCategorysubName = SubCatData[rowNumber - 2]; - cell.value = defaultCategorysubName; + worksheet1 + .getColumn('E') + .eachCell({ includeEmpty: true }, function (cell, rowNumber) { + if (rowNumber > 1) { + const dynamicValidValues = '"' + SubCatData.join(',') + '"'; + const defaultCategorysubName = SubCatData[rowNumber - 2]; + cell.value = defaultCategorysubName; - cell.dataValidation = { - type: "list", - allowBlank: true, - formulae: [dynamicValidValues], - }; - } - }); + cell.dataValidation = { + type: 'list', + allowBlank: true, + formulae: [dynamicValidValues], + }; + } + }); } if (typeof Subcatnumfid !== 'undefined') { - worksheet1.getColumn("G").eachCell({ includeEmpty: true }, function (cell, rowNumber) { - if (rowNumber > 1) { - const dynamicValidValues = '"' + Subcatnumfid.join(",") + '"'; - const defaultCategorysubName = Subcatnumfid[rowNumber - 2]; - cell.value = defaultCategorysubName; + worksheet1 + .getColumn('G') + .eachCell({ includeEmpty: true }, function (cell, rowNumber) { + if (rowNumber > 1) { + const dynamicValidValues = '"' + Subcatnumfid.join(',') + '"'; + const defaultCategorysubName = Subcatnumfid[rowNumber - 2]; + cell.value = defaultCategorysubName; - cell.dataValidation = { - type: "list", - allowBlank: true, - formulae: [dynamicValidValues], - }; - } - }); + cell.dataValidation = { + type: 'list', + allowBlank: true, + formulae: [dynamicValidValues], + }; + } + }); } if (typeof AllBrandId !== 'undefined') { - worksheet1.getColumn("I").eachCell({ includeEmpty: true }, function (cell, rowNumber) { - if (rowNumber > 1) { - const dynamicValidValues = '"' + AllBrandId.join(",") + '"'; - const defaultCategorysubName = AllBrandId[rowNumber - 2]; - cell.value = defaultCategorysubName; + worksheet1 + .getColumn('I') + .eachCell({ includeEmpty: true }, function (cell, rowNumber) { + if (rowNumber > 1) { + const dynamicValidValues = '"' + AllBrandId.join(',') + '"'; + const defaultCategorysubName = AllBrandId[rowNumber - 2]; + cell.value = defaultCategorysubName; - cell.dataValidation = { - type: "list", - allowBlank: true, - formulae: [dynamicValidValues], - }; - } - }); + cell.dataValidation = { + type: 'list', + allowBlank: true, + formulae: [dynamicValidValues], + }; + } + }); } if (typeof Allbranddata !== 'undefined') { - worksheet1.getColumn("J").eachCell({ includeEmpty: true }, function (cell, rowNumber) { - if (rowNumber > 1) { - const dynamicValidValues = '"' + Allbranddata.join(",") + '"'; - const defaultCategorysubName = Allbranddata[rowNumber - 2]; - cell.value = defaultCategorysubName; + worksheet1 + .getColumn('J') + .eachCell({ includeEmpty: true }, function (cell, rowNumber) { + if (rowNumber > 1) { + const dynamicValidValues = '"' + Allbranddata.join(',') + '"'; + const defaultCategorysubName = Allbranddata[rowNumber - 2]; + cell.value = defaultCategorysubName; - cell.dataValidation = { - type: "list", - allowBlank: true, - formulae: [dynamicValidValues], - }; - } - }); + cell.dataValidation = { + type: 'list', + allowBlank: true, + formulae: [dynamicValidValues], + }; + } + }); } if (typeof Allbranddatanumfid !== 'undefined') { - worksheet1.getColumn("K").eachCell({ includeEmpty: true }, function (cell, rowNumber) { - if (rowNumber > 1) { - const dynamicValidValues = '"' + Allbranddatanumfid.join(",") + '"'; - const defaultCategorysubName = Allbranddatanumfid[rowNumber - 2]; - cell.value = defaultCategorysubName; + worksheet1 + .getColumn('K') + .eachCell({ includeEmpty: true }, function (cell, rowNumber) { + if (rowNumber > 1) { + const dynamicValidValues = '"' + Allbranddatanumfid.join(',') + '"'; + const defaultCategorysubName = Allbranddatanumfid[rowNumber - 2]; + cell.value = defaultCategorysubName; - cell.dataValidation = { - type: "list", - allowBlank: true, - formulae: [dynamicValidValues], - }; - } - }); + cell.dataValidation = { + type: 'list', + allowBlank: true, + formulae: [dynamicValidValues], + }; + } + }); } // Original complex logic for column C (SUBCAT DATAS) - worksheet1.getColumn("C").eachCell({ includeEmpty: true }, function (cell, rowNumber) { - if (rowNumber > 1) { - const categoryId = worksheet1.getCell(`A${rowNumber}`).value; - if (categoryId !== null) { - const uniqueSubCategoryData = new Set(); - const matchedData = []; + worksheet1 + .getColumn('C') + .eachCell({ includeEmpty: true }, function (cell, rowNumber) { + if (rowNumber > 1) { + const categoryId = worksheet1.getCell(`A${rowNumber}`).value; + if (categoryId !== null) { + const uniqueSubCategoryData = new Set(); + const matchedData = []; - worksheet1.getColumn("G").eachCell({ includeEmpty: true }, function (subCatCell, subCatRowNumber) { - if (subCatRowNumber > 1 && subCatCell.value === categoryId) { - const subCategoryName = worksheet1.getCell(`E${subCatRowNumber}`).value; - const subCatId = worksheet1.getCell(`D${subCatRowNumber}`).value; + worksheet1 + .getColumn('G') + .eachCell( + { includeEmpty: true }, + function (subCatCell, subCatRowNumber) { + if (subCatRowNumber > 1 && subCatCell.value === categoryId) { + const subCategoryName = worksheet1.getCell( + `E${subCatRowNumber}` + ).value; + const subCatId = worksheet1.getCell( + `D${subCatRowNumber}` + ).value; - const fullSubCategoryName = `${subCatId} - ${subCategoryName}`; + const fullSubCategoryName = `${subCatId} - ${subCategoryName}`; - uniqueSubCategoryData.add({ - subCategoryId: subCatId, - subCategoryName: subCategoryName, - }); + uniqueSubCategoryData.add({ + subCategoryId: subCatId, + subCategoryName: subCategoryName, + }); - const subCatData = categoryDataMap[categoryId] ? categoryDataMap[categoryId].subCatData : null; + const subCatData = categoryDataMap[categoryId] + ? categoryDataMap[categoryId].subCatData + : null; - const data = { - subCategoryId: subCatId, - subCategoryName: subCategoryName, - subCatData: subCatData, - }; - matchedData.push(data); - } - }); + const data = { + subCategoryId: subCatId, + subCategoryName: subCategoryName, + subCatData: subCatData, + }; + matchedData.push(data); + } + } + ); - cell.value = JSON.stringify(Array.from(uniqueSubCategoryData)); + cell.value = JSON.stringify(Array.from(uniqueSubCategoryData)); + } } - } - }); + }); // Original complex logic for column M (Brand Details) - worksheet1.getColumn("M").eachCell({ includeEmpty: true }, function (cell, rowNumber) { - if (rowNumber > 1) { - const SubcatId = worksheet1.getCell(`D${rowNumber}`).value; - if (SubcatId !== null) { - const uniqueSubCategoryData = new Set(); - const matchedData = []; + worksheet1 + .getColumn('M') + .eachCell({ includeEmpty: true }, function (cell, rowNumber) { + if (rowNumber > 1) { + const SubcatId = worksheet1.getCell(`D${rowNumber}`).value; + if (SubcatId !== null) { + const uniqueSubCategoryData = new Set(); + const matchedData = []; - worksheet1.getColumn("K").eachCell({ includeEmpty: true }, function (BrandCell, BrandRowNumber) { - if (BrandRowNumber > 1 && BrandCell.value === SubcatId) { - const BrandName = worksheet1.getCell(`J${BrandRowNumber}`).value; - const BrandId = worksheet1.getCell(`I${BrandRowNumber}`).value; + worksheet1 + .getColumn('K') + .eachCell( + { includeEmpty: true }, + function (BrandCell, BrandRowNumber) { + if (BrandRowNumber > 1 && BrandCell.value === SubcatId) { + const BrandName = worksheet1.getCell( + `J${BrandRowNumber}` + ).value; + const BrandId = worksheet1.getCell( + `I${BrandRowNumber}` + ).value; - const fullSubCategoryName = `${BrandId} - ${BrandName}`; + const fullSubCategoryName = `${BrandId} - ${BrandName}`; - uniqueSubCategoryData.add({ - BrandId: BrandId, - BrandName: BrandName, - }); + uniqueSubCategoryData.add({ + BrandId: BrandId, + BrandName: BrandName, + }); - const BrandData = BrandDataMap[SubcatId] ? BrandDataMap[SubcatId].BrandData : null; + const BrandData = BrandDataMap[SubcatId] + ? BrandDataMap[SubcatId].BrandData + : null; - const data = { - BrandId: BrandId, - BrandName: BrandName, - BrandData: BrandData, - }; - matchedData.push(data); - } - }); + const data = { + BrandId: BrandId, + BrandName: BrandName, + BrandData: BrandData, + }; + matchedData.push(data); + } + } + ); - cell.value = JSON.stringify(Array.from(uniqueSubCategoryData)); + cell.value = JSON.stringify(Array.from(uniqueSubCategoryData)); + } } - } - }); + }); // Generate and download the file const buffer = await workbook.xlsx.writeBuffer(); const blob = new Blob([buffer], { - type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", + type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', }); - const filename = "Product Data.xlsx"; + const filename = 'Product Data.xlsx'; - if (typeof window !== "undefined") { + if (typeof window !== 'undefined') { if (window.navigator && window.navigator.msSaveOrOpenBlob) { window.navigator.msSaveOrOpenBlob(blob, filename); } else { - const downloadLink = document.createElement("a"); + const downloadLink = document.createElement('a'); downloadLink.href = window.URL.createObjectURL(blob); downloadLink.download = filename; downloadLink.click(); @@ -1927,15 +2273,15 @@ const ProductExcel = ({ // handleDownload(['ProdName', 'Size', 'UOM', 'SellPrice', 'ProdCat', 'Brand']); // More fields // Available field names: - // 'ProdName', 'Size', 'UOM', 'SellPrice', 'ProdCat', 'ProdSubCat', 'Brand', - // 'ProdVarientName', 'MRP', 'StockAvailable', 'OfferPrice', 'Supplier', 'TaxId', - // 'AutoGenerateQr', 'AddQrCode', 'SpecialPrice', 'OnePiecePrice', 'AutoGenOnePieceQr', - // 'AutoGenOnePieceQrNum', 'CESS', 'HSNCode', 'PartNumber', 'Rack', 'ManufDate', + // 'ProdName', 'Size', 'UOM', 'SellPrice', 'ProdCat', 'ProdSubCat', 'Brand', + // 'ProdVarientName', 'MRP', 'StockAvailable', 'OfferPrice', 'Supplier', 'TaxId', + // 'AutoGenerateQr', 'AddQrCode', 'SpecialPrice', 'OnePiecePrice', 'AutoGenOnePieceQr', + // 'AutoGenOnePieceQrNum', 'CESS', 'HSNCode', 'PartNumber', 'Rack', 'ManufDate', // 'ExpDate', 'AvailableFrom', 'AvailableTo' const handleFileSubmit = (e) => { e.preventDefault(); if (excelFile === null) { - excelFileError("Please select an Excel file."); + excelFileError('Please select an Excel file.'); } else { handleSubmit(Datas); } @@ -1946,33 +2292,32 @@ const ProductExcel = ({ }; const handleFieldSetupSubmit = async () => { - const postData = { - "AppId": AppId, - "CompId": CompId, - "BranchId": BranchId, - "Type": "EB", - "FormType": "Product", - "TypeId": productBulkUploadCatId, - "ConfigDtl": selectedFields?.map((field) => ({ - "ConfigId": field, - "Access": 'Y', + AppId: AppId, + CompId: CompId, + BranchId: BranchId, + Type: 'EB', + FormType: 'Product', + TypeId: productBulkUploadCatId, + ConfigDtl: selectedFields?.map((field) => ({ + ConfigId: field, + Access: 'Y', })), - "CreatedBy": UserId - } + CreatedBy: UserId, + }; const response = await dispatch(postFieldSetup(postData))?.unwrap(); if (response?.data?.statusCode === 1) { - setMessageType("success"); + setMessageType('success'); setMessageData(response?.data?.response); setFieldSetup(false); await getFieldSetup(); } else { - setMessageType("error"); - setMessageData("Failed to set up fields"); + setMessageType('error'); + setMessageData('Failed to set up fields'); } - } + }; const handleFieldSelect = (value) => { setSelectedFields((prev) => { @@ -1987,187 +2332,186 @@ const ProductExcel = ({ setSelectedFields((prev) => prev.filter((field) => field !== id)); }; - const handleCancelData = () => { dispatch(emptyExcelData()); if (fileInputRef.current) { - fileInputRef.current.value = ""; + fileInputRef.current.value = ''; } }; const columns = [ { - title: "Product Name", - dataIndex: "ProductName", - key: "ProductName", + title: 'Product Name', + dataIndex: 'ProductName', + key: 'ProductName', editable: true, }, { - title: "Qty", - dataIndex: "Quantity", - key: "Quantity", + title: 'Qty', + dataIndex: 'Quantity', + key: 'Quantity', editable: true, }, { - title: "UOM", - dataIndex: "UOM", - key: "UOM", + title: 'UOM', + dataIndex: 'UOM', + key: 'UOM', editable: true, }, { - title: "Sales Price", - dataIndex: "SellPrice", - key: "SellPrice", + title: 'Sales Price', + dataIndex: 'SellPrice', + key: 'SellPrice', editable: true, }, { - title: "Category", - dataIndex: "Category", - key: "Category", + title: 'Category', + dataIndex: 'Category', + key: 'Category', editable: true, }, { - title: "Sub Category", - dataIndex: "SubCategory", - key: "SubCategory", + title: 'Sub Category', + dataIndex: 'SubCategory', + key: 'SubCategory', editable: true, }, { - title: "Brand", - dataIndex: "Brand", - key: "Brand", + title: 'Brand', + dataIndex: 'Brand', + key: 'Brand', editable: true, }, { - title: "Variant Name", - dataIndex: "ProductVariantName", - key: "ProductVariantName", + title: 'Variant Name', + dataIndex: 'ProductVariantName', + key: 'ProductVariantName', editable: true, }, { - title: "MRP", - dataIndex: "MRP", - key: "MRP", + title: 'MRP', + dataIndex: 'MRP', + key: 'MRP', editable: true, }, { - title: "WholeSale Price", - dataIndex: "WhSalePrice", - key: "WhSalePrice", + title: 'WholeSale Price', + dataIndex: 'WhSalePrice', + key: 'WhSalePrice', editable: true, }, { - title: "Auto Qrcode", - dataIndex: "AutoGenerateQrcode", - key: "AutoGenerateQrcode", + title: 'Auto Qrcode', + dataIndex: 'AutoGenerateQrcode', + key: 'AutoGenerateQrcode', editable: true, }, { - title: "Add QrCode", - dataIndex: "AddQrCode", - key: "AddQrCode", + title: 'Add QrCode', + dataIndex: 'AddQrCode', + key: 'AddQrCode', editable: true, }, { - title: "Stock Available", - dataIndex: "StockAvailable", - key: "StockAvailable", + title: 'Stock Available', + dataIndex: 'StockAvailable', + key: 'StockAvailable', editable: true, }, { - title: "Token Available", - dataIndex: "TokenAvailable", - key: "TokenAvailable", + title: 'Token Available', + dataIndex: 'TokenAvailable', + key: 'TokenAvailable', editable: true, }, { - title: "One Piece Available", - dataIndex: "OnePieceAvailable", - key: "OnePieceAvailable", + title: 'One Piece Available', + dataIndex: 'OnePieceAvailable', + key: 'OnePieceAvailable', editable: true, }, { - title: "One Piece Price", - dataIndex: "OnePiecePrice", - key: "OnePiecePrice", + title: 'One Piece Price', + dataIndex: 'OnePiecePrice', + key: 'OnePiecePrice', editable: true, }, { - title: "Auto Gen One Piece Qr", - dataIndex: "AutoGenerateOnePieceQrcode", - key: "AutoGenerateOnePieceQrcode", + title: 'Auto Gen One Piece Qr', + dataIndex: 'AutoGenerateOnePieceQrcode', + key: 'AutoGenerateOnePieceQrcode', editable: true, }, { - title: "Auto Gen One Piece Qr No", - dataIndex: "AutoGenerateOnePieceQrcodeNumber", - key: "AutoGenerateOnePieceQrcodeNumber", + title: 'Auto Gen One Piece Qr No', + dataIndex: 'AutoGenerateOnePieceQrcodeNumber', + key: 'AutoGenerateOnePieceQrcodeNumber', editable: true, }, { - title: "Product Type", - dataIndex: "ProductType", - key: "ProductType", + title: 'Product Type', + dataIndex: 'ProductType', + key: 'ProductType', editable: true, }, { - title: "Tax", - dataIndex: "Tax", - key: "Tax", + title: 'Tax', + dataIndex: 'Tax', + key: 'Tax', editable: true, }, { - title: "Cess", - dataIndex: "CESS", - key: "CESS", + title: 'Cess', + dataIndex: 'CESS', + key: 'CESS', editable: true, }, { - title: "HSN", - dataIndex: "HSN", - key: "HSN", + title: 'HSN', + dataIndex: 'HSN', + key: 'HSN', editable: true, }, { - title: "Part Number", - dataIndex: "PartNumber", - key: "PartNumber", + title: 'Part Number', + dataIndex: 'PartNumber', + key: 'PartNumber', editable: true, }, { - title: "Rack", - dataIndex: "Rack", - key: "Rack", + title: 'Rack', + dataIndex: 'Rack', + key: 'Rack', editable: true, }, { - title: "Mfg Date", - dataIndex: "ManufactureDate", - key: "ManufactureDate", + title: 'Mfg Date', + dataIndex: 'ManufactureDate', + key: 'ManufactureDate', editable: true, }, { - title: "Exp Date", - dataIndex: "ExpireDate", - key: "ExpireDate", + title: 'Exp Date', + dataIndex: 'ExpireDate', + key: 'ExpireDate', editable: true, }, { - title: "Avl From", - dataIndex: "AvailableFrom", - key: "AvailableFrom", + title: 'Avl From', + dataIndex: 'AvailableFrom', + key: 'AvailableFrom', editable: true, }, { - title: "Avl To", - dataIndex: "AvailableTo", - key: "AvailableTo", + title: 'Avl To', + dataIndex: 'AvailableTo', + key: 'AvailableTo', editable: true, }, { - title: "Image", - dataIndex: "Productimage", - key: "Productimage", + title: 'Image', + dataIndex: 'Productimage', + key: 'Productimage', render: (ProdImage, record, index) => { const Img = ProdImage; return ( @@ -2176,7 +2520,7 @@ const ProductExcel = ({ {record.Productimage} ) : ( <> @@ -2190,7 +2534,7 @@ const ProductExcel = ({ ? onlineImage : record.Productimage ? record.Productimage - : "" + : '' } listType="picture-card" // onlineImage={onlineImage?onlineImage:""} @@ -2202,7 +2546,7 @@ const ProductExcel = ({ addOnlineImage(record, index)} /> @@ -2215,7 +2559,6 @@ const ProductExcel = ({ }, ]; - const column = columns?.map((col) => { if (!col.editable) { return col; @@ -2223,7 +2566,7 @@ const ProductExcel = ({ let onClickHandler = null; - if (editdelete === "Delete") { + if (editdelete === 'Delete') { onClickHandler = (record) => removeFromTable(record); } @@ -2243,7 +2586,6 @@ const ProductExcel = ({ const EditableContext = React.createContext(null); const EditableRow = ({ index, dataIndex, ...props }) => { - const [form] = Form.useForm(); return (
@@ -2328,18 +2670,20 @@ const ProductExcel = ({ }; const handleSave = (row) => { - const newDatas = [...Datas]; - const item = newDatas.filter(item => item.key === row.key); + const item = newDatas.filter((item) => item.key === row.key); // const item = newDatas[index]; const UpdatedData = { ProductName: row?.ProductName, - ProductVariantName: row?.ProductVariantName ? row?.ProductVariantName : "Variant 1", + ProductVariantName: row?.ProductVariantName + ? row?.ProductVariantName + : 'Variant 1', Quantity: row?.Quantity, UOM: row?.UOM, MRP: row?.MRP, + isModified: true, WhSalePrice: row?.WhSalePrice, SellPrice: row?.SellPrice, Category: row?.Category, @@ -2366,7 +2710,6 @@ const ProductExcel = ({ AvailableTo: row?.AvailableTo, Productimage: row?.Productimage, key: row?.key, - }; newDatas.splice(item?.[0]?.key, 1, { ...item?.[0], @@ -2377,10 +2720,10 @@ const ProductExcel = ({ }; const handlechange22 = (index) => { - if (editdelete === "Delete") { - seteditdelete(""); + if (editdelete === 'Delete') { + seteditdelete(''); } else { - seteditdelete("Delete"); + seteditdelete('Delete'); } }; @@ -2396,91 +2739,175 @@ const ProductExcel = ({ }; const handleExportData = async () => { - setLoading(true) - let response = await dispatch(getProductData({ CompId: CompId, BranchId: BranchId, AppId: AppId })).unwrap(); + setLoading(true); + let response = await dispatch( + getProductData({ CompId: CompId, BranchId: BranchId, AppId: AppId }) + ).unwrap(); if (response?.data?.statusCode == 1 && response?.data?.data?.length > 0) { - const formattedData = response?.data?.data?.map(item => { + const formattedData = response?.data?.data?.map((item) => { return { - "Product Name": item.ProdName, - "Product Variant Name": item.ProdVarientName, - "Quantity": item.Size, - "UOM": item.UomName, - "MRP": item.MRP, - "WholeSale Price": item.WhSalePrice, - "Sales Price": item.SellPrice, - "Category": item.CategoryName, - "Sub Category": item.SubCategoryName, - "Brand": item.BrandName, - "Auto Generate Qrcode": item.AutoGenerateQr ? item.AutoGenerateQr : "N", - "Add Qr Code": item.QRCode, - "Stock Available": item.StockAvailable ? item.StockAvailable : "N", - "Token Available": item.TokenAvailable ? item.TokenAvailable : "N", - "One Piece Available": item.OnePcsAvailable ? item.OnePcsAvailable : "N", - "One Piece Price": item.OnePcsPrice, - "Auto Generate One Piece Qrcode": item.AutoGenerateSingleQr ? item.AutoGenerateSingleQr : "N", - "Auto Generate One Piece Qrcode Number": item.OnePcQR, - "Product Type": item.ProdTypeName ? item.ProdTypeName : "Product", - "Tax": `${item.TaxName || "NIL"} - ${item.TaxPercentage || 0}%`, // Ensures a valid tax format - "CESS": item.CESS, - "HSN": item.HSNCode, - "Part Number": item.PartNumber, - "Rack": item.Rack, - "Manufacture Date": null, - "Expire Date": null, - "Available From": item.AvailableFrom != "00:00:00" ? item.AvailableFrom : null, - "Available To": item.AvailableTo != "00:00:00" ? item.AvailableTo : null + ProdId: item.ProdId, + 'Product Name': item.ProdName, + 'Product Variant Name': item.ProdVarientName, + Quantity: item.Size, + UOM: item.UomName, + MRP: item.MRP, + 'WholeSale Price': item.WhSalePrice, + 'Sales Price': item.SellPrice, + Category: item.CategoryName, + 'Sub Category': item.SubCategoryName, + Brand: item.BrandName, + 'Auto Generate Qrcode': item.AutoGenerateQr + ? item.AutoGenerateQr + : 'N', + 'Add Qr Code': item.QRCode, + 'Stock Available': item.StockAvailable ? item.StockAvailable : 'N', + 'Token Available': item.TokenAvailable ? item.TokenAvailable : 'N', + 'One Piece Available': item.OnePcsAvailable + ? item.OnePcsAvailable + : 'N', + 'One Piece Price': item.OnePcsPrice, + 'Auto Generate One Piece Qrcode': item.AutoGenerateSingleQr + ? item.AutoGenerateSingleQr + : 'N', + 'Auto Generate One Piece Qrcode Number': item.OnePcQR, + 'Product Type': item.ProdTypeName ? item.ProdTypeName : 'Product', + Tax: `${item.TaxName || 'NIL'} - ${item.TaxPercentage || 0}%`, + CESS: item.CESS, + HSN: item.HSNCode, + 'Part Number': item.PartNumber, + Rack: item.Rack, + 'Manufacture Date': null, + 'Expire Date': null, + 'Available From': + item.AvailableFrom != '00:00:00' ? item.AvailableFrom : null, + 'Available To': + item.AvailableTo != '00:00:00' ? item.AvailableTo : null, }; }); - const ws = XLSX.utils.json_to_sheet(formattedData); + const workbook = new ExcelJS.Workbook(); + const worksheet = workbook.addWorksheet('Products'); - // Create a new workbook and append the worksheet - const wb = XLSX.utils.book_new(); - XLSX.utils.book_append_sheet(wb, ws, "Products"); - setLoading(false) - // Trigger the file download - XLSX.writeFile(wb, "Product_Data.xlsx"); + worksheet.columns = Object.keys(formattedData[0]).map((key) => ({ + header: key, + key: key, + width: 20, + })); + formattedData.forEach((row) => worksheet.addRow(row)); + + worksheet.eachRow((row, rowNumber) => { + row.eachCell((cell, colNumber) => { + cell.protection = { locked: colNumber === 1 }; + }); + }); + + await worksheet.protect('', { + selectLockedCells: true, + selectUnlockedCells: true, + }); + + const buffer = await workbook.xlsx.writeBuffer(); + const blob = new Blob([buffer], { + type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', + }); + const downloadLink = document.createElement('a'); + downloadLink.href = window.URL.createObjectURL(blob); + downloadLink.download = 'Product_Data.xlsx'; + downloadLink.click(); + + setLoading(false); + } else { + setLoading(false); + setMessage(true); } - else { - setLoading(false) - setMessage(true) + }; + + const handleExportBulkdata = async () => { + let response = await dispatch( + getProductData({ CompId: CompId, BranchId: BranchId, AppId: AppId }) + ).unwrap(); + if (response?.data?.statusCode == 1 && response?.data?.data?.length > 0) { + const formattedData = response?.data?.data?.map((item) => { + return { + ProdId: item.ProdId, + 'Product Name': item.ProdName, + 'Product Variant Name': item.ProdVarientName, + Quantity: item.Size, + UOM: item.UomName, + MRP: item.MRP, + 'WholeSale Price': item.WhSalePrice, + 'Sales Price': item.SellPrice, + Category: item.CategoryName, + 'Sub Category': item.SubCategoryName, + Brand: item.BrandName, + 'Auto Generate Qrcode': item.AutoGenerateQr + ? item.AutoGenerateQr + : 'N', + 'Add Qr Code': item.QRCode, + 'Stock Available': item.StockAvailable ? item.StockAvailable : 'N', + 'Token Available': item.TokenAvailable ? item.TokenAvailable : 'N', + 'One Piece Available': item.OnePcsAvailable + ? item.OnePcsAvailable + : 'N', + 'One Piece Price': item.OnePcsPrice, + 'Auto Generate One Piece Qrcode': item.AutoGenerateSingleQr + ? item.AutoGenerateSingleQr + : 'N', + 'Auto Generate One Piece Qrcode Number': item.OnePcQR, + 'Product Type': item.ProdTypeName ? item.ProdTypeName : 'Product', + Tax: `${item.TaxName || 'NIL'} - ${item.TaxPercentage || 0}%`, + CESS: item.CESS, + HSN: item.HSNCode, + 'Part Number': item.PartNumber, + Rack: item.Rack, + 'Manufacture Date': null, + 'Expire Date': null, + 'Available From': + item.AvailableFrom != '00:00:00' ? item.AvailableFrom : null, + 'Available To': + item.AvailableTo != '00:00:00' ? item.AvailableTo : null, + }; + }); + + setOrginalData(formattedData); } - } + }; const requiredFields = [ - "ProductName", - "ProductVariantName", - "Quantity", - "UOM", - "MRP", - "SellPrice", - "WhSalePrice", - "Category", - "SubCategory", - "Brand", - "StockAvailable", - "TokenAvailable", - "ProductType", - "Tax", - "AutoGenerateQrcode", - "AddQrCode", - "OnePieceAvailable", - "OnePiecePrice", - "AutoGenerateOnePieceQrcode", - "AutoGenerateOnePieceQrcodeNumber", - "CESS", - "HSN", - "PartNumber", - "Rack", - "ManufactureDate", - "ExpireDate", - "AvailableFrom", - "AvailableTo" + 'ProductName', + 'ProductVariantName', + 'Quantity', + 'UOM', + 'MRP', + 'SellPrice', + 'WhSalePrice', + 'Category', + 'SubCategory', + 'Brand', + 'StockAvailable', + 'TokenAvailable', + 'ProductType', + 'Tax', + 'AutoGenerateQrcode', + 'AddQrCode', + 'OnePieceAvailable', + 'OnePiecePrice', + 'AutoGenerateOnePieceQrcode', + 'AutoGenerateOnePieceQrcodeNumber', + 'CESS', + 'HSN', + 'PartNumber', + 'Rack', + 'ManufactureDate', + 'ExpireDate', + 'AvailableFrom', + 'AvailableTo', ]; - const enhancedColumns = columns.map((col) => { - if (col.dataIndex === "Productimage") return col; + const enhancedColumns = column.map((col) => { + if (col.dataIndex === 'Productimage') return col; // Get all used fields *except* the current column (to allow remap) const usedFields = Object.entries(fieldMapping) @@ -2488,24 +2915,31 @@ const ProductExcel = ({ .map(([, value]) => value); // Fields left for dropdown (excluding already selected ones) - const availableHeaders = headers?.filter(h => !usedFields?.includes(h) && h !== "__isSampleRow"); + const availableHeaders = headers?.filter( + (h) => !usedFields?.includes(h) && h !== '__isSampleRow' + ); const isMapped = !!fieldMapping[col.dataIndex]; return { ...col, title: ( -
+
{col.title} {!isMapped && ( - - Not mapped - + Not mapped )}
-
+
- Upload Sheet + + {' '} + Upload Sheet{' '} +
@@ -2759,14 +3274,16 @@ const ProductExcel = ({ )} {excelFileError && ( -
+
{excelFileError}
)}
-
- +
{excelData && excelData?.length > 0 ? ( + record.isModified ? 'modified-row' : 'old-row' + } >
- ) : - ( -

- )} + ) : ( +

+ )}
-
- +
{/*
@@ -2790,23 +3316,23 @@ const ProductExcel = ({
*/} - - - - - {excelData && excelData?.length > 0 && + {excelData && excelData?.length > 0 && (
- + Remove File - -
- } - + )}
- +
@@ -2824,11 +3352,16 @@ const ProductExcel = ({ label="Select fields" // valueData={selectedFields} onChangeFunction={handleFieldSelect} - options={tableFieldPreferences?.filter(p => !selectedFields?.some(s => s === p.value))} /> + options={tableFieldPreferences?.filter( + (p) => !selectedFields?.some((s) => s === p.value) + )} + />
{selectedFields - ?.map((id) => tableFieldPreferences?.find((p) => p.value === id)) + ?.map((id) => + tableFieldPreferences?.find((p) => p.value === id) + ) .filter(Boolean) .map((field) => (
@@ -2857,7 +3390,6 @@ const ProductExcel = ({ />
- {imagedata?.map((item, index) => (
setSelectedImage(item)} > - no image + no image
))}
@@ -2883,7 +3419,6 @@ const ProductExcel = ({ handleSubmit={submitimage} handleCancel={handleimage} > -
key !== field) .map(([, value]) => value); - const availableHeaders = headers?.filter(header => !usedHeaders?.includes(header)); + const availableHeaders = headers?.filter( + (header) => !usedHeaders?.includes(header) + ); return (
@@ -2907,7 +3444,9 @@ const ProductExcel = ({ style={{ width: '100%' }} placeholder="Select column" value={fieldMapping[field] || undefined} - clearIcon={} + clearIcon={ + + } onChange={(value) => { setFieldMapping((prev) => { const updated = { ...prev }; @@ -2931,9 +3470,7 @@ const ProductExcel = ({ })}
- ); - }; export default ProductExcel; diff --git a/src/Pages/Product/ProductForm.jsx b/src/Pages/Product/ProductForm.jsx index 5d2393a..9a3add1 100644 --- a/src/Pages/Product/ProductForm.jsx +++ b/src/Pages/Product/ProductForm.jsx @@ -4035,7 +4035,7 @@ const ProductForm = ({ formType }) => {
)} -
+
{ formRef?.current?.resetFields(); }; - const handleCancel = () => { + + + + const handleResetExcelData = useCallback(() => { + dispatch(emptyExcelData()); + }, []); + + const handleCancel = useCallback(() => { setOpenExcel(false); handleResetExcelData(); - }; + }, [handleResetExcelData]); - const openModal = () => { + const openModal = useCallback(() => { setOpenExcel(true); - }; - - const handleResetExcelData = () => { - dispatch(emptyExcelData()); - }; - - const handleSubmitbulk = (excelData) => { + }, []); + const handleSubmitbulk = useCallback((excelData) => { setExceldatasubmit(excelData?.filter((e) => e?.isModified)); - }; + }, []); - const handleSubmit = async () => { + const handleSubmit = useCallback(async () => { setBulkpost(true); - let FilterData = Exceldatasubmit?.filter((a) => a['ProductName'] != ''); - if (FilterData && FilterData.length > 0) { - const formattedData = FilterData?.map((data) => ({ - AppId: getSession('AppId'), - CompId: getSession('CompId'), - BranchId: getSession('BranchId'), - CreatedBy: getSession('UserId'), + const FilterData = Exceldatasubmit?.filter( + a => a.ProductName !== '' + ); - ProdName: data?.ProductName, - ProdVariantName: data?.ProductVariantName, - Size: data?.Quantity, - UOM: data?.UOM, - MRP: data?.MRP, - WhSalePrice: data?.WhSalePrice, - SellPrice: data?.SellPrice, - ProdCat: data?.Category ? data?.Category : 'General', - ProdSubCat: data?.SubCategory, - Brand: data?.Brand ? data?.Brand : '', - AutoGenerateQr: data?.AutoGenerateQrcode - ? data?.AutoGenerateQrcode - : 'No', - QRCode: data?.AddQrCode, - StockAvailable: data?.StockAvailable ? data?.StockAvailable : 'No', - TaxId: data?.Tax ? data?.Tax : 'NIL - 0%', - Cess: data?.Cess, - HSNCode: data?.HSN, - PartNumber: data?.PartNumber, - Rack: data?.Rack, - ManufDate: moment(data?.ManufactureDate, ['M/D/YY']).format( - 'YYYY-MM-DDTHH:mm:ss' - ), - ExpDate: moment(data?.ExpireDate, ['M/D/YY']).format( - 'YYYY-MM-DDTHH:mm:ss' - ), - AvailableFrom: data?.AvailableFrom - ? moment(data?.AvailableFrom, ['M/D/YY']).format('HH:mm:ss') - : '', - AvailableTo: data?.AvailableTo - ? moment(data?.AvailableTo, ['M/D/YY']).format('HH:mm:ss') - : '', - OnePcsAvailable: data?.Amountperpiece ? data?.Amountperpiece : 'No', - OnePcsPrice: data?.AmountperpiecePrice, - // NoOfPcs:data?.NumberOfPieceInside, - AutoGenerateSingleQr: data?.AutoGenerateOnePieceQrcode - ? data?.AutoGenerateOnePieceQrcode - : 'No', - OnePcQR: data?.AutoGenerateOnePieceQrcodeNumber, - // ProductType:data?.ProductType, - TokenAvailable: data?.TokenAvailable ? data?.TokenAvailable : 'No', - ProdLogo: data?.Productimage, - })); - - let postDatas = { prodDetails: formattedData }; - - let response = await dispatch(bulkpostdata(postDatas)).unwrap(); - if (response?.data?.statusCode == 1) { - setMessageType('success'); - setMessageData(response?.data?.response); - setBulkpost(false); - setpage(1); - - var responseData = await dispatch( - getProductDataPageNo({ CompId, BranchId, AppId, PageNumber: 1 }) - ).unwrap(); - setCurrentPage(1); - - if (responseData?.data?.statusCode === 1) { - setCachedData({ [currentPage]: responseData?.data?.data }); - setproductData(responseData?.data?.data); - } - } else { - setMessageType('error'); - setMessageData(responseData?.data?.response); - } - - handleResetExcelData(); - handleCancel(); - } else { + if (!FilterData || FilterData.length === 0) { setBulkpost(false); setMessageType('error'); setMessageData('No data to submit. Please upload an Excel file.'); + return; } - }; - const Unit = UomPreference?.map((e) => e.ConfigName); - const CategoryId = ProdCatData?.map((e) => e.ConfigId); - const CategoryNames = ProdCatData?.map((e) => e.ConfigName); - const CatconfigId = ProdCatData?.map((e) => e.ConfigId); - const Subcatnames = subCatData?.map((e) => e.ConfigName); - const SubcatId = subCatData?.map((e) => e.ConfigId); - const SubcatNumFId = subCatData?.map((e) => e.NumFId); - const BrandNumFId = allBrandData?.map((e) => e.NumFId); - const BrandId = allBrandData?.map((e) => e.ConfigId); - const BrandName = allBrandData?.map((e) => e.ConfigName); - const SuplierNames = SupplierData?.map((e) => e.SuppName); - const TaxDatas = TaxData?.map((e) => e.TaxIdName); - const TaxData1 = TaxData?.map((e) => e.TaxPercentage); - const combinedTaxData = TaxDatas?.map( - (taxIdName, index) => `${taxIdName} - ${TaxData1[index]}%` + const formattedData = FilterData.map(data => ({ + AppId: getSession('AppId'), + CompId: getSession('CompId'), + BranchId: getSession('BranchId'), + CreatedBy: getSession('UserId'), + + ProdName: data.ProductName, + ProdVariantName: data.ProductVariantName, + Size: data.Quantity, + UOM: data.UOM, + MRP: data.MRP, + WhSalePrice: data.WhSalePrice, + SellPrice: data.SellPrice, + ProdCat: data.Category || 'General', + ProdSubCat: data.SubCategory, + Brand: data.Brand || '', + AutoGenerateQr: data.AutoGenerateQrcode || 'No', + QRCode: data.AddQrCode, + StockAvailable: data.StockAvailable || 'No', + TaxId: data.Tax || 'NIL - 0%', + Cess: data.Cess, + HSNCode: data.HSN, + PartNumber: data.PartNumber, + Rack: data.Rack, + ManufDate: moment(data.ManufactureDate, ['M/D/YY']).format( + 'YYYY-MM-DDTHH:mm:ss' + ), + ExpDate: moment(data.ExpireDate, ['M/D/YY']).format( + 'YYYY-MM-DDTHH:mm:ss' + ), + AvailableFrom: data.AvailableFrom + ? moment(data.AvailableFrom, ['M/D/YY']).format('HH:mm:ss') + : '', + AvailableTo: data.AvailableTo + ? moment(data.AvailableTo, ['M/D/YY']).format('HH:mm:ss') + : '', + OnePcsAvailable: data.Amountperpiece || 'No', + OnePcsPrice: data.AmountperpiecePrice, + AutoGenerateSingleQr: data.AutoGenerateOnePieceQrcode || 'No', + OnePcQR: data.AutoGenerateOnePieceQrcodeNumber, + TokenAvailable: data.TokenAvailable || 'No', + ProdLogo: data.Productimage, + })); + + const postDatas = { prodDetails: formattedData }; + + const response = await dispatch(bulkpostdata(postDatas)).unwrap(); + + if (response?.data?.statusCode === 1) { + setMessageType('success'); + setMessageData(response.data.response); + setpage(1); + + const responseData = await dispatch( + getProductDataPageNo({ CompId, BranchId, AppId, PageNumber: 1 }) + ).unwrap(); + + if (responseData?.data?.statusCode === 1) { + setCachedData({ 1: responseData.data.data }); + setproductData(responseData.data.data); + setCurrentPage(1); + } + } else { + setMessageType('error'); + setMessageData(response?.data?.response); + } + + setBulkpost(false); + handleResetExcelData(); + handleCancel(); + }, [ + Exceldatasubmit, + + CompId, + BranchId, + AppId, + handleResetExcelData, + handleCancel + ]); + + const Unit = useMemo( + () => UomPreference?.map((e) => e.ConfigName), + [UomPreference] + ); + + const CategoryId = useMemo( + () => ProdCatData?.map((e) => e.ConfigId), + [ProdCatData] + ); + + const CategoryNames = useMemo( + () => ProdCatData?.map((e) => e.ConfigName), + [ProdCatData] + ); + + const CatconfigId = useMemo( + () => ProdCatData?.map((e) => e.ConfigId), + [ProdCatData] + ); + + const Subcatnames = useMemo( + () => subCatData?.map((e) => e.ConfigName), + [subCatData] + ); + + const SubcatId = useMemo( + () => subCatData?.map((e) => e.ConfigId), + [subCatData] + ); + + const SubcatNumFId = useMemo( + () => subCatData?.map((e) => e.NumFId), + [subCatData] + ); + + const BrandNumFId = useMemo( + () => allBrandData?.map((e) => e.NumFId), + [allBrandData] + ); + + const BrandId = useMemo( + () => allBrandData?.map((e) => e.ConfigId), + [allBrandData] + ); + + const BrandName = useMemo( + () => allBrandData?.map((e) => e.ConfigName), + [allBrandData] + ); + + const SuplierNames = useMemo( + () => SupplierData?.map((e) => e.SuppName), + [SupplierData] + ); + + const TaxDatas = useMemo( + () => TaxData?.map((e) => e.TaxIdName), + [TaxData] + ); + + const TaxData1 = useMemo( + () => TaxData?.map((e) => e.TaxPercentage), + [TaxData] + ); + + const combinedTaxData = useMemo( + () => + TaxDatas?.map( + (taxIdName, index) => `${taxIdName} - ${TaxData1[index]}%` + ), + [TaxDatas, TaxData1] ); const Deletebulk = async () => { let data = { @@ -2641,7 +2706,7 @@ const ProductList = () => { generateQRCodeCopy={(code) => generateQRCodeCopy(QrandbarcodeDatas, code) } - generateCodeImage={(code, codeType = 'Q') => generateCodeImage(code, codeType, QrandbarcodeDatas) } + generateCodeImage={(code, codeType = 'Q') => generateCodeImage(code, codeType, QrandbarcodeDatas)} imageTagBarcodeAndQR={imageTagBarcodeAndQR} dropdownValue={dropdownValue} barcodeTemplateDetails={barcodeTemplateDetails} diff --git a/src/Pages/StockPriceUpdate/StockPriceUpdate.jsx b/src/Pages/StockPriceUpdate/StockPriceUpdate.jsx index 9e93125..de6ca38 100644 --- a/src/Pages/StockPriceUpdate/StockPriceUpdate.jsx +++ b/src/Pages/StockPriceUpdate/StockPriceUpdate.jsx @@ -4,76 +4,77 @@ import React, { useRef, useContext, useCallback, -} from "react"; -import { useDispatch, useSelector } from "react-redux"; -import { Select, Tooltip } from "antd"; -import { Form, Input, Table } from "antd"; +} from 'react'; +import { useDispatch, useSelector } from 'react-redux'; +import { Select, Tooltip } from 'antd'; +import { Form, Input, Table } from 'antd'; import { EditFilled, DeleteFilled, ArrowRightOutlined, -} from "@ant-design/icons"; +} from '@ant-design/icons'; import { PutStockPrice, bulkPriceUpdate, getStockNames, -} from "../../Features/StockPriceUpdate/StockPriceUpdateMaster"; +} from '../../Features/StockPriceUpdate/StockPriceUpdateMaster'; import { dateFormatChange, ExtractDateFormate, getSession, -} from "../../Services/Others"; -import { DefaultModal } from "../../Components/Modal/DefaultModal"; -import { Tables } from "../../Components/Tables/Table"; -import Buttons from "../../Components/Forms/Buttons"; -import { Messages } from "../../Components/Notifications/Messages"; +} from '../../Services/Others'; +import { DefaultModal } from '../../Components/Modal/DefaultModal'; +import { Tables } from '../../Components/Tables/Table'; +import Buttons from '../../Components/Forms/Buttons'; +import { Messages } from '../../Components/Notifications/Messages'; import { changeBreadCrumb, getEmpAccess, -} from "../../Features/AppPage/CenterPage.js"; -import FormHeader from "../PageComponents/FormHeader"; -import Search from "../../Components/Forms/Search"; -import { RadioGrpButton } from "../../Components/Forms/RadioGroup.jsx"; -import { useAuth } from "../../AuthContext.jsx"; -import "../../Styles/OverAllStyle/OverAllStyle.scss"; -import { getPreferenceData } from "../../Features/BookingScreen/BookingData/BookingData.js"; -import { DropDowns } from "../../Components/Forms/DropDown.jsx"; -import { FiDelete, FiUploadCloud } from "react-icons/fi"; -import { CiExport } from "react-icons/ci"; -import Excelupldimg from "../../Images/Excel.png"; +} from '../../Features/AppPage/CenterPage.js'; +import FormHeader from '../PageComponents/FormHeader'; +import Search from '../../Components/Forms/Search'; +import { RadioGrpButton } from '../../Components/Forms/RadioGroup.jsx'; +import { useAuth } from '../../AuthContext.jsx'; +import '../../Styles/OverAllStyle/OverAllStyle.scss'; +import './StockPriceUpdate.scss'; +import { getPreferenceData } from '../../Features/BookingScreen/BookingData/BookingData.js'; +import { DropDowns } from '../../Components/Forms/DropDown.jsx'; +import { FiDelete, FiUploadCloud } from 'react-icons/fi'; +import { CiExport } from 'react-icons/ci'; +import Excelupldimg from '../../Images/Excel.png'; import { emptyExcelData, fileInputRefSelector, -} from "../../Features/ExcelUploadPage/ExcelUploadPage.js"; +} from '../../Features/ExcelUploadPage/ExcelUploadPage.js'; const subDirectory = import.meta.env.BASE_URL; -import ExcelJS from "exceljs"; -import { read, utils } from "xlsx"; -import { v4 as uuidv4 } from "uuid"; -import { InputField } from "../../Components/Forms/InputField.jsx"; -import { MdOutlineAppRegistration } from "react-icons/md"; +import ExcelJS from 'exceljs'; +import { read, utils } from 'xlsx'; +import { v4 as uuidv4 } from 'uuid'; +import { InputField } from '../../Components/Forms/InputField.jsx'; +import { MdOutlineAppRegistration } from 'react-icons/md'; import { getFieldSetupData, postFieldSetup, -} from "../../Features/ProductPage/ProductPage.js"; +} from '../../Features/ProductPage/ProductPage.js'; import { ApplicationPreferences, getCommonAppPreference, -} from "../../Features/BrachLogin/BranchLogin.js"; -import { IoClose } from "react-icons/io5"; +} from '../../Features/BrachLogin/BranchLogin.js'; +import { IoClose } from 'react-icons/io5'; const StockPriceUpdate = () => { const { SadminuserAccess } = useAuth(); let SAAccessCommonMaster = SadminuserAccess?.find( - (e) => e?.MenuName === "Price Change", + (e) => e?.MenuName === 'Price Change' ); const ApplicationPreferenceData = useSelector(ApplicationPreferences); const categoryId = ApplicationPreferenceData?.find( - (p) => p?.PreferredCatName?.toLowerCase() === "price change fields", + (p) => p?.PreferredCatName?.toLowerCase() === 'price change fields' )?.PreferredCatId; const excelCategoryId = ApplicationPreferenceData?.find( - (p) => p?.PreferredCatName?.toLowerCase() === "price change sheet fields", + (p) => p?.PreferredCatName?.toLowerCase() === 'price change sheet fields' )?.PreferredCatId; const fileInputRef = useRef(fileInputRefSelector); @@ -81,8 +82,8 @@ const StockPriceUpdate = () => { const formRef = useRef(null); const allowedExcelTypes = [ - "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", // .xlsx - "application/vnd.ms-excel", // .xls + 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', // .xlsx + 'application/vnd.ms-excel', // .xls ]; const dispatch = useDispatch(); @@ -90,7 +91,7 @@ const StockPriceUpdate = () => { const [selectedExcelFields, setSelectedExcelFields] = useState([]); const [tableFieldPreferences, setTableFieldPreferences] = useState([]); const [tableExcelFieldPreferences, setTableExcelFieldPreferences] = useState( - [], + [] ); const [messageType, setMessageType] = useState(null); const [messageData, setMessageData] = useState(null); @@ -103,8 +104,8 @@ const StockPriceUpdate = () => { const [dataSource, setDataSource] = useState([]); const [sortedInfo, setSortedInfo] = useState({}); const [BulksortedInfo, setBulksortedInfo] = useState({}); - const [searchedText, setSearchedText] = useState(""); - const [BulksearchedText, setBulksearchedText] = useState(""); + const [searchedText, setSearchedText] = useState(''); + const [BulksearchedText, setBulksearchedText] = useState(''); const [filteredInfo, setFilteredInfo] = useState({}); const [page, setpage] = useState(1); const [Bulkchangepage, setBulkchangepage] = useState(1); @@ -114,35 +115,36 @@ const StockPriceUpdate = () => { const [open, setOpen] = useState(false); const [excelModalOpen, setExcelModalOpen] = useState(false); const [priceChangeModalOpen, setPriceChangeModalOpen] = useState(false); - const [stockVariantBased, setStockVariantBased] = useState("Yes"); + const [stockVariantBased, setStockVariantBased] = useState('Yes'); const [exportLoading, setExportLoading] = useState(false); const [fileLoading, setFileLoading] = useState(false); const [loading, setLoading] = useState(false); const [headers, setHeaders] = useState([]); + console.log(headers, 'headers'); const [uploadedData, setUploadedData] = useState([]); - const CompId = getSession("CompId"); - const BranchId = getSession("BranchId"); - const AppId = getSession("AppId"); - const UserId = getSession("UserId"); - const UserType = getSession("UserType"); + const CompId = getSession('CompId'); + const BranchId = getSession('BranchId'); + const AppId = getSession('AppId'); + const UserId = getSession('UserId'); + const UserType = getSession('UserType'); const [empData, setEmpData] = useState(); const [addnewAccess, setaddnewAccess] = useState(true); - const [RadioSelection, setRadioSelection] = useState("Single"); + const [RadioSelection, setRadioSelection] = useState('Single'); const [BulkProductData, setBulkProductData] = useState([]); const [allowDecimal, setAllowDecimal] = useState(false); const hasFieldExists = (label) => headers.some((h) => h.toLowerCase() === label.toLowerCase()); const hasField = (label) => - tableFieldPreferences?.some((f) => f.label === label && f.access === "Y"); + tableFieldPreferences?.some((f) => f.label === label && f.access === 'Y'); const hasExcelField = (label) => tableExcelFieldPreferences?.some( - (f) => f.label === label && f.access === "Y", + (f) => f.label === label && f.access === 'Y' ); const items = [ { - name: "Home", + name: 'Home', link: `${subDirectory}app-page/home`, }, ]; @@ -150,85 +152,88 @@ const StockPriceUpdate = () => { const handleRemoveRecord = (index) => { setUploadedData((prev) => prev.filter((_, i) => i !== index)); }; - + console.log(uploadedData, 'uploadedData'); const columns = [ { - title: "Product Name", - dataIndex: "ProductName", - key: "ProductName", + title: 'Product Name', + dataIndex: 'ProductName', + key: 'ProductName', width: 180, render: (value, record, index) => ( -

{`${value} (${record?.Size} ${record?.UOMName})`}

+

+ {value}{' '} + {record?.Size && `(${record?.Size || ''} ${record?.UOMName || ''})`} +

), }, { - title: "Variant Name", - dataIndex: "VariantName", - key: "VariantName", + title: 'Variant Name', + dataIndex: 'VariantName', + key: 'VariantName', width: 180, }, { - title: "Batch No", - dataIndex: "BatchRef", - key: "BatchRef", + title: 'Batch No', + dataIndex: 'BatchRef', + key: 'BatchRef', width: 180, }, - ...(hasFieldExists("Stock") + ...(hasFieldExists('Stock') ? [ - { - title: "Stock", - dataIndex: "Stock", - key: "Stock", - width: 80, - }, - ] + { + title: 'Stock', + dataIndex: 'Stock', + key: 'Stock', + width: 80, + }, + ] : []), - ...(hasFieldExists("Stock Date") + ...(hasFieldExists('Stock Date') ? [ - { - title: "Stock Date", - dataIndex: "StockDate", - key: "StockDate", - width: 80, - }, - ] + { + title: 'Stock Date', + dataIndex: 'StockDate', + key: 'StockDate', + width: 80, + }, + ] : []), - ...(hasFieldExists("Old MRP") + ...(hasFieldExists('Old MRP') ? [ - { - title: "Old MRP", - dataIndex: "OldMRP", - key: "OldMRP", - width: 100, - }, - ] + { + title: 'Old MRP', + dataIndex: 'OldMRP', + key: 'OldMRP', + width: 100, + }, + ] : []), - ...(hasFieldExists("Old SP") + ...(hasFieldExists('Old SP') ? [ - { - title: "Old SP", - dataIndex: "OldSP", - key: "OldSP", - width: 100, - }, - ] + { + title: 'Old SP', + dataIndex: 'OldSP', + key: 'OldSP', + width: 100, + }, + ] : []), - ...(hasFieldExists("Old Wholesale Price") + ...(hasFieldExists('Old Wholesale Price') ? [ - { - title: "Old Wholesale Price", - dataIndex: "OldWholeSalePrice", - key: "OldWholeSalePrice", - width: 140, - }, - ] + { + title: 'Old Wholesale Price', + dataIndex: 'OldWholeSalePrice', + key: 'OldWholeSalePrice', + width: 140, + }, + ] : []), // ✅ EDITABLE { - title: "New MRP", - dataIndex: "NewMRP", - key: "NewMRP", + title: 'New MRP', + dataIndex: 'NewMRP', + key: 'NewMRP', width: 120, render: (_, record, index) => ( @@ -236,17 +241,17 @@ const StockPriceUpdate = () => { placeholder="New MRP" inputMode="decimal" onChange={(e) => - handlePriceChange(index, "NewMRP", e.target.value, record.localId) + handlePriceChange(index, 'NewMRP', e.target.value, record.localId) } onInput={(e) => { - let cleanedValue = e.target.value.replace(/[^0-9.]/g, ""); - if (cleanedValue.startsWith(".")) { - cleanedValue = "0" + cleanedValue; + let cleanedValue = e.target.value.replace(/[^0-9.]/g, ''); + if (cleanedValue.startsWith('.')) { + cleanedValue = '0' + cleanedValue; } - const parts = cleanedValue.split("."); + const parts = cleanedValue.split('.'); e.target.value = parts.length > 2 - ? `${parts[0]}.${parts.slice(1).join("")}` + ? `${parts[0]}.${parts.slice(1).join('')}` : cleanedValue; }} /> @@ -254,38 +259,38 @@ const StockPriceUpdate = () => { ), }, { - title: "New SP", - dataIndex: "NewSellPrice", - key: "NewSellPrice", + title: 'New SP', + dataIndex: 'NewSellPrice', + key: 'NewSellPrice', width: 120, render: (_, record, index) => ( ({ validator(_, value) { const mrp = getFieldValue(`NewMRP${record.localId}`); - if (mrp === undefined || mrp === null || mrp === "") { + if (mrp === undefined || mrp === null || mrp === '') { return Promise.resolve(); } const numMRP = Number(mrp); const numSP = - value === undefined || value === null || value === "" + value === undefined || value === null || value === '' ? null : Number(value); if (numSP === null) { return Promise.reject( - new Error("New SP is required when New MRP is provided"), + new Error('New SP is required when New MRP is provided') ); } if (numSP > numMRP) { return Promise.reject( - new Error("New SP cannot be greater than New MRP"), + new Error('New SP cannot be greater than New MRP') ); } @@ -298,80 +303,80 @@ const StockPriceUpdate = () => { placeholder="New SP" inputMode="decimal" onInput={(e) => { - let cleanedValue = e.target.value.replace(/[^0-9.]/g, ""); - const parts = cleanedValue.split("."); - if (cleanedValue.startsWith(".")) { - cleanedValue = "0" + cleanedValue; + let cleanedValue = e.target.value.replace(/[^0-9.]/g, ''); + const parts = cleanedValue.split('.'); + if (cleanedValue.startsWith('.')) { + cleanedValue = '0' + cleanedValue; } e.target.value = parts.length > 2 - ? `${parts[0]}.${parts.slice(1).join("")}` + ? `${parts[0]}.${parts.slice(1).join('')}` : cleanedValue; }} onChange={(e) => { { handlePriceChange( index, - "NewSellPrice", + 'NewSellPrice', e.target.value, - record.localId, + record.localId ); excelDataRef.current ?.validateFields([`NewSellPrice${record.localId}`]) - .catch(() => { }); + .catch(() => {}); } }} /> ), }, - ...(hasFieldExists("New Wholesale Price") + ...(hasFieldExists('New Wholesale Price') ? [ - { - title: "New Wholesale Price", - dataIndex: "NewWholeSalePrice", - key: "NewWholeSalePrice", - width: 160, - render: (value, record, index) => ( - - - handlePriceChange( - index, - "NewWholeSalePrice", - e.target.value, - record.localId, - ) - } - placeholder="New Wholesale" - inputMode="decimal" - onInput={(e) => { - let cleanedValue = e.target.value.replace(/[^0-9.]/g, ""); - const parts = cleanedValue.split("."); - if (cleanedValue.startsWith(".")) { - cleanedValue = "0" + cleanedValue; + { + title: 'New Wholesale Price', + dataIndex: 'NewWholeSalePrice', + key: 'NewWholeSalePrice', + width: 160, + render: (value, record, index) => ( + + + handlePriceChange( + index, + 'NewWholeSalePrice', + e.target.value, + record.localId + ) } - e.target.value = - parts.length > 2 - ? `${parts[0]}.${parts.slice(1).join("")}` - : cleanedValue; - }} - /> - - ), - }, - ] + placeholder="New Wholesale" + inputMode="decimal" + onInput={(e) => { + let cleanedValue = e.target.value.replace(/[^0-9.]/g, ''); + const parts = cleanedValue.split('.'); + if (cleanedValue.startsWith('.')) { + cleanedValue = '0' + cleanedValue; + } + e.target.value = + parts.length > 2 + ? `${parts[0]}.${parts.slice(1).join('')}` + : cleanedValue; + }} + /> + + ), + }, + ] : []), { - title: "Action", - key: "action", + title: 'Action', + key: 'action', width: 80, - align: "center", + align: 'center', render: (_, record, index) => ( handleRemoveRecord(index)} /> @@ -390,7 +395,7 @@ const StockPriceUpdate = () => { dispatch(getCommonAppPreference(AppId)); }, [AppId, dispatch]); useEffect(() => { - if (UserType === "Employee") { + if (UserType === 'Employee') { fetchApi(); } }, [UserType]); @@ -406,25 +411,25 @@ const StockPriceUpdate = () => { const getFieldSetup = async () => { try { const response = await dispatch( - getFieldSetupData({ AppId, CompId, BranchId, categoryId, Type: "GB" }), + getFieldSetupData({ AppId, CompId, BranchId, categoryId, Type: 'GB' }) ).unwrap(); if (response?.data?.statusCode === 1) { - console.log(response?.data?.data?.[0]?.ConfigDtl, "Field Setup Data"); + console.log(response?.data?.data?.[0]?.ConfigDtl, 'Field Setup Data'); setSelectedFields( response?.data?.data?.[0]?.ConfigDtl?.filter( - (c) => c.ConfigId && c.Access === "Y", - )?.map((c) => c.ConfigId) || [], + (c) => c.ConfigId && c.Access === 'Y' + )?.map((c) => c.ConfigId) || [] ); setTableFieldPreferences( response?.data?.data?.[0]?.ConfigDtl?.map((c) => ({ value: c.ConfigId, label: c.ConfigName, access: c.Access, - })) || [], + })) || [] ); } } catch (error) { - console.error("Error fetching field setup:", error); + console.error('Error fetching field setup:', error); } }; @@ -436,38 +441,38 @@ const StockPriceUpdate = () => { CompId, BranchId, categoryId: excelCategoryId, - Type: "GB", - }), + Type: 'GB', + }) ).unwrap(); if (response?.data?.statusCode === 1) { - console.log(response?.data?.data?.[0]?.ConfigDtl, "Field Setup Data"); + console.log(response?.data?.data?.[0]?.ConfigDtl, 'Field Setup Data'); setSelectedExcelFields( response?.data?.data?.[0]?.ConfigDtl?.filter( - (c) => c.ConfigId && c.Access === "Y", - )?.map((c) => c.ConfigId) || [], + (c) => c.ConfigId && c.Access === 'Y' + )?.map((c) => c.ConfigId) || [] ); setTableExcelFieldPreferences( response?.data?.data?.[0]?.ConfigDtl?.map((c) => ({ value: c.ConfigId, label: c.ConfigName, access: c.Access, - })) || [], + })) || [] ); } } catch (error) { - console.error("Error fetching field setup:", error); + console.error('Error fetching field setup:', error); } }; useEffect(() => { let hasAccess = false; - if (UserType === "Admin" || UserType === "Super Admin") { + if (UserType === 'Admin' || UserType === 'Super Admin') { hasAccess = true; - } else if (UserType === "Employee") { - hasAccess = empData?.AddAccess === "Y"; - } else if (UserType === "Super Admin User") { - hasAccess = SAAccessCommonMaster?.AddAccess === "Y"; + } else if (UserType === 'Employee') { + hasAccess = empData?.AddAccess === 'Y'; + } else if (UserType === 'Super Admin User') { + hasAccess = SAAccessCommonMaster?.AddAccess === 'Y'; } setaddnewAccess(!hasAccess); @@ -490,7 +495,7 @@ const StockPriceUpdate = () => { }; let response = await dispatch(getEmpAccess(data)).unwrap(); let datas = response?.data?.data?.[0]?.EmpAccessDetails?.filter( - (item) => item.ConfigName === "Price Change", + (item) => item.ConfigName === 'Price Change' ); setEmpData(datas?.[0]); }; @@ -553,7 +558,7 @@ const StockPriceUpdate = () => { ...values, }); } catch (errInfo) { - console.log("Save failed:", errInfo); + console.log('Save failed:', errInfo); } }; @@ -569,12 +574,12 @@ const StockPriceUpdate = () => { rules={[ { pattern: /^(?!0$)(\d+)(\.\d{1,2})?$/, - message: "Invalid format (Max 2 decimals, No zero)", + message: 'Invalid format (Max 2 decimals, No zero)', }, { validator: (_, value) => value?.length > 10 - ? Promise.reject("Max 10 characters allowed") + ? Promise.reject('Max 10 characters allowed') : Promise.resolve(), }, ]} @@ -590,11 +595,11 @@ const StockPriceUpdate = () => { } inputMode="decimal" onInput={(e) => { - const cleanedValue = e.target.value.replace(/[^0-9.]/g, ""); - const parts = cleanedValue.split("."); + const cleanedValue = e.target.value.replace(/[^0-9.]/g, ''); + const parts = cleanedValue.split('.'); e.target.value = parts.length > 2 - ? `${parts[0]}.${parts.slice(1).join("")}` + ? `${parts[0]}.${parts.slice(1).join('')}` : cleanedValue; }} /> @@ -660,7 +665,7 @@ const StockPriceUpdate = () => { ...values, }); } catch (errInfo) { - console.log("Save failed:", errInfo); + console.log('Save failed:', errInfo); } }; @@ -676,12 +681,12 @@ const StockPriceUpdate = () => { rules={[ { pattern: /^(?!0$)(\d+)(\.\d{1,2})?$/, - message: "Invalid format (Max 2 decimals, No zero)", + message: 'Invalid format (Max 2 decimals, No zero)', }, { validator: (_, value) => value?.length > 10 - ? Promise.reject("Max 10 characters allowed") + ? Promise.reject('Max 10 characters allowed') : Promise.resolve(), }, ]} @@ -696,11 +701,11 @@ const StockPriceUpdate = () => { } inputMode="decimal" onInput={(e) => { - const cleanedValue = e.target.value.replace(/[^0-9.]/g, ""); - const parts = cleanedValue.split("."); + const cleanedValue = e.target.value.replace(/[^0-9.]/g, ''); + const parts = cleanedValue.split('.'); e.target.value = parts.length > 2 - ? `${parts[0]}.${parts.slice(1).join("")}` + ? `${parts[0]}.${parts.slice(1).join('')}` : cleanedValue; }} /> @@ -736,8 +741,8 @@ const StockPriceUpdate = () => { const { data: res } = await dispatch(getPreferenceData(data)).unwrap(); const decimalSetting = res?.data?.[0]?.SettingDtlDetails?.find( (setting) => - setting?.SettingIdName?.toLowerCase() === "decimal" && - setting?.SettingValue === "Y", + setting?.SettingIdName?.toLowerCase() === 'decimal' && + setting?.SettingValue === 'Y' ); if (decimalSetting) { setAllowDecimal(true); @@ -781,7 +786,7 @@ const StockPriceUpdate = () => { ProdVariantName: detail?.ProdVariantName, BatchRef: detail?.BatchRef, key: `${product.ProdId}_${detail.InwardDtlId}`, - })), + })) ); setBulkProductData(flattenedArray); }; @@ -799,7 +804,7 @@ const StockPriceUpdate = () => { const currentRow = { ...updated[rowIndex] }; // If changing New MRP, clear New SP - if (field === "NewMRP") { + if (field === 'NewMRP') { currentRow.NewSellPrice = null; excelDataRef.current?.setFieldsValue({ [`NewSellPrice${localId}`]: null, @@ -807,18 +812,19 @@ const StockPriceUpdate = () => { } currentRow[field] = numValue; + currentRow.isModified = true; updated[rowIndex] = currentRow; return updated; }); // Validate New SP against New MRP - if (field === "NewSellPrice" && numValue) { + if (field === 'NewSellPrice' && numValue) { const currentRow = uploadedData[rowIndex]; const newMRP = currentRow?.NewMRP; if (newMRP && numValue > newMRP) { - setMessageType("error"); - setMessageData("New SP cannot be greater than New MRP"); + setMessageType('error'); + setMessageData('New SP cannot be greater than New MRP'); return; } } @@ -830,7 +836,7 @@ const StockPriceUpdate = () => { const statusFormatter = async (row) => { const updatedData = StockDetails?.filter( - (item) => item?.InwardDtlId !== row?.InwardDtlId, + (item) => item?.InwardDtlId !== row?.InwardDtlId ); setStockDetails(updatedData); }; @@ -838,7 +844,7 @@ const StockPriceUpdate = () => { let tableValue = StockNames?.[0]?.stockDetails; let DataSource = StockNames?.map((name, index) => ({ value: index + 1, - label: name?.ProdName + "(" + (name?.Size + " " + name?.UOMName) + ")", + label: name?.ProdName + '(' + (name?.Size + ' ' + name?.UOMName) + ')', ProdId: name?.ProdId, stockDetails: name?.stockDetails, Quantity: name?.Size, @@ -864,8 +870,8 @@ const StockPriceUpdate = () => { }); setStockDetails(newData); } else { - setMessageType("error"); - setMessageData("MRP is must be greater than or equal to selling price"); + setMessageType('error'); + setMessageData('MRP is must be greater than or equal to selling price'); } } else { const newData = StockDetails?.map((item) => { @@ -894,9 +900,9 @@ const StockPriceUpdate = () => { }); setBulkProductData(newData); } else { - setMessageType("error"); + setMessageType('error'); setMessageData( - "MRP is must be greater than or equal to selling price", + 'MRP is must be greater than or equal to selling price' ); } } else { @@ -926,31 +932,31 @@ const StockPriceUpdate = () => { }; function safeRound(amountStr) { - if (amountStr == null) return allowDecimal ? "0.00" : "0"; + if (amountStr == null) return allowDecimal ? '0.00' : '0'; - const cleaned = String(amountStr).replace(/[^0-9.-]+/g, ""); + const cleaned = String(amountStr).replace(/[^0-9.-]+/g, ''); const num = Number(cleaned); - if (isNaN(num)) return allowDecimal ? "0.00" : "0"; + if (isNaN(num)) return allowDecimal ? '0.00' : '0'; return allowDecimal ? num.toFixed(2) : Math.round(num).toString(); } const columns2 = [ { - title: "Sl.No", - align: "center", - key: "sno", - width: "60px", + title: 'Sl.No', + align: 'center', + key: 'sno', + width: '60px', render: (text, object, index) => ( - {index + 1} + {index + 1} ), }, { - title: "Product Name", - dataIndex: "ProdName", - key: "ProdName", - width: "20%", + title: 'Product Name', + dataIndex: 'ProdName', + key: 'ProdName', + width: '20%', filteredValue: [searchedText], onFilter: (value, record) => { return String(record.ProdName) @@ -958,7 +964,7 @@ const StockPriceUpdate = () => { .includes(value?.toLowerCase()); }, sorter: (a, b) => a?.ProdName?.localeCompare(b.ProdName), - sortOrder: sortedInfo.columnKey === "ProdName" ? sortedInfo.order : null, + sortOrder: sortedInfo.columnKey === 'ProdName' ? sortedInfo.order : null, ellipsis: true, render: (_, record) => ( @@ -968,65 +974,65 @@ const StockPriceUpdate = () => { ), }, { - title: "stock Date", - dataIndex: "InwardDate", - key: "InwardDate", - align: "right", - width: "150px", + title: 'stock Date', + dataIndex: 'InwardDate', + key: 'InwardDate', + align: 'right', + width: '150px', render: (InwardDate) => - InwardDate !== null ? ExtractDateFormate(InwardDate) : "-", + InwardDate !== null ? ExtractDateFormate(InwardDate) : '-', }, { - title: "Old MRP", - dataIndex: "MRP", - key: "MRP", - align: "right", - render: (MRP) => (safeRound(MRP) !== null ? safeRound(MRP) : "-"), + title: 'Old MRP', + dataIndex: 'MRP', + key: 'MRP', + align: 'right', + render: (MRP) => (safeRound(MRP) !== null ? safeRound(MRP) : '-'), }, { - title: "Old Price", - dataIndex: "SellPrice", - key: "SellPrice", - align: "right", + title: 'Old Price', + dataIndex: 'SellPrice', + key: 'SellPrice', + align: 'right', render: (SellPrice) => - safeRound(SellPrice) !== null ? safeRound(SellPrice) : "-", + safeRound(SellPrice) !== null ? safeRound(SellPrice) : '-', }, { - title: "New MRP", - dataIndex: "CurrentMRP", - key: "CurrentMRP", - align: "right", + title: 'New MRP', + dataIndex: 'CurrentMRP', + key: 'CurrentMRP', + align: 'right', editable: true, - render: (text, record) =>

{text ? text : "Enter MRP"}

, + render: (text, record) =>

{text ? text : 'Enter MRP'}

, width: 100, }, { - title: "New SP", - dataIndex: "CurrentAmt", - key: "CurrentAmt", - align: "right", + title: 'New SP', + dataIndex: 'CurrentAmt', + key: 'CurrentAmt', + align: 'right', editable: true, - render: (text, record) =>

{text ? text : "Enter Price"}

, + render: (text, record) =>

{text ? text : 'Enter Price'}

, width: 100, }, { - title: "Action", - dataIndex: "SellPrice", - key: "SellPrice", - align: "center", - width: "100px", + title: 'Action', + dataIndex: 'SellPrice', + key: 'SellPrice', + align: 'center', + width: '100px', render: (_, record, index) => (
statusFormatter(record, index)} />
@@ -1035,21 +1041,21 @@ const StockPriceUpdate = () => { ]; const BulkPricechangeColumns = [ { - title: "Sl.No", - align: "center", - key: "sno", - width: "50px", + title: 'Sl.No', + align: 'center', + key: 'sno', + width: '50px', render: (text, object, index) => ( - + {(Bulkchangepage - 1) * 10 + index + 1} ), }, { - title: "Name", - dataIndex: "ProdName", - key: "ProdName", - width: "20%", + title: 'Name', + dataIndex: 'ProdName', + key: 'ProdName', + width: 150, filteredValue: [BulksearchedText], onFilter: (value, record) => { return String(record.ProdName) @@ -1058,7 +1064,7 @@ const StockPriceUpdate = () => { }, sorter: (a, b) => a?.ProdName?.localeCompare(b.ProdName), sortOrder: - BulksortedInfo.columnKey === "ProdName" ? BulksortedInfo.order : null, + BulksortedInfo.columnKey === 'ProdName' ? BulksortedInfo.order : null, ellipsis: true, render: (_, record) => ( @@ -1067,131 +1073,130 @@ const StockPriceUpdate = () => { ), }, { - title: "Variant Name", - dataIndex: "ProdVariantName", - key: "ProdVariantName", - align: "left", - width: "120px", + title: 'Variant Name', + dataIndex: 'ProdVariantName', + key: 'ProdVariantName', + align: 'left', + width: 120, }, { - title: "Batch No", - dataIndex: "BatchRef", - key: "BatchRef", - align: "left", - width: "120px", + title: 'Batch No', + dataIndex: 'BatchRef', + key: 'BatchRef', + align: 'left', + width: 120, }, - ...(hasField("Stock Date") + ...(hasField('Stock Date') ? [ - { - title: "stock Date", - dataIndex: "InwardDate", - key: "InwardDate", - align: "center", - width: "100px", - render: (InwardDate) => - InwardDate !== null ? ExtractDateFormate(InwardDate) : "-", - }, - ] + { + title: 'stock Date', + dataIndex: 'InwardDate', + key: 'InwardDate', + align: 'center', + width: 120, + render: (InwardDate) => + InwardDate !== null ? ExtractDateFormate(InwardDate) : '-', + }, + ] : []), - ...(hasField("Expiry Date") + ...(hasField('Expiry Date') ? [ - { - title: "Exp date", - dataIndex: "ExpDate", - key: "ExpDate", - align: "center", - width: "100px", - render: (ExpDate) => - ExpDate !== null ? ExtractDateFormate(ExpDate) : "-", - }, - ] + { + title: 'Exp date', + dataIndex: 'ExpDate', + key: 'ExpDate', + align: 'center', + width: 100, + render: (ExpDate) => + ExpDate !== null ? ExtractDateFormate(ExpDate) : '-', + }, + ] : []), - ...(hasField("Stock") + ...(hasField('Stock') ? [ - - { - title: "stock", - dataIndex: "BalanceQty", - key: "BalanceQty", - align: "right", - width: "60px", - render: (BalanceQty) => (BalanceQty !== null ? BalanceQty : "-"), - }, - ] + { + title: 'stock', + dataIndex: 'BalanceQty', + key: 'BalanceQty', + align: 'right', + width: '60px', + render: (BalanceQty) => (BalanceQty !== null ? BalanceQty : '-'), + }, + ] : []), - ...(hasField("Old MRP") + ...(hasField('Old MRP') ? [ - { - title: "Old MRP", - dataIndex: "MRP", - key: "MRP", - align: "right", - width: "70px", - render: (MRP) => (safeRound(MRP) !== null ? safeRound(MRP) : "-"), - }, - ] + { + title: 'Old MRP', + dataIndex: 'MRP', + key: 'MRP', + align: 'right', + width: '70px', + render: (MRP) => (safeRound(MRP) !== null ? safeRound(MRP) : '-'), + }, + ] : []), - ...(hasField("Old SP") + ...(hasField('Old SP') ? [ - { - title: "Old SP", - dataIndex: "SellPrice", - key: "SellPrice", - align: "right", - width: "70px", - render: (SellPrice) => - safeRound(SellPrice) !== null ? safeRound(SellPrice) : "-", - }, - ] + { + title: 'Old SP', + dataIndex: 'SellPrice', + key: 'SellPrice', + align: 'right', + width: '70px', + render: (SellPrice) => + safeRound(SellPrice) !== null ? safeRound(SellPrice) : '-', + }, + ] : []), - ...(hasField("Old Wholesale Price") + ...(hasField('Old Wholesale Price') ? [ - { - title: "Old Wholesale Price", - dataIndex: "WhSalePrice", - key: "WhSalePrice", - align: "right", - width: "120px", - render: (WhSalePrice) => - safeRound(WhSalePrice) !== null ? safeRound(WhSalePrice) : "-", - }, - ] + { + title: 'Old Wholesale Price', + dataIndex: 'WhSalePrice', + key: 'WhSalePrice', + align: 'right', + width: '120px', + render: (WhSalePrice) => + safeRound(WhSalePrice) !== null ? safeRound(WhSalePrice) : '-', + }, + ] : []), { - title: "New MRP", - dataIndex: "CurrentMRP", - key: "CurrentMRP", - align: "center", - with: "4rem", + title: 'New MRP', + dataIndex: 'CurrentMRP', + key: 'CurrentMRP', + align: 'center', + with: '4rem', editable: true, - render: (text, record) =>

{text ? text : "Enter MRP"}

, + render: (text, record) =>

{text ? text : 'Enter MRP'}

, width: 100, }, { - title: "New SP", - dataIndex: "CurrentAmt", - key: "CurrentAmt", - align: "center", - with: "4rem", + title: 'New SP', + dataIndex: 'CurrentAmt', + key: 'CurrentAmt', + align: 'center', + with: '4rem', editable: true, - render: (text, record) =>

{text ? text : "Enter Price"}

, + render: (text, record) =>

{text ? text : 'Enter Price'}

, width: 100, }, - ...(hasField("New Wholesale Price") + ...(hasField('New Wholesale Price') ? [ - { - title: "New Wholesale Price", - dataIndex: "CurrentWhAmt", - key: "CurrentWhAmt", - align: "center", - with: "4rem", - editable: true, - render: (text, record) => ( -

{text ? text : "Enter Wholesale Price"}

- ), - width: 120, - }, - ] + { + title: 'New Wholesale Price', + dataIndex: 'CurrentWhAmt', + key: 'CurrentWhAmt', + align: 'center', + with: '4rem', + editable: true, + render: (text, record) => ( +

{text ? text : 'Enter Wholesale Price'}

+ ), + width: 120, + }, + ] : []), ]; @@ -1200,7 +1205,7 @@ const StockPriceUpdate = () => { // Check if any of the new products already exist in StockDetails setStockDetails((prevStockDetails) => { const existingInwardDtlIds = new Set( - prevStockDetails?.map((item) => item.InwardDtlId), + prevStockDetails?.map((item) => item.InwardDtlId) ); const uniqueNewStockDetails = newStockDetails @@ -1255,18 +1260,18 @@ const StockPriceUpdate = () => { // }; const HandlePutData = async () => { - if (RadioSelection == "Bulk") { + if (RadioSelection == 'Bulk') { const filteredCurrentAmtData = BulkProductData?.filter( (item) => (item.CurrentAmt !== undefined && item.CurrentAmt !== null && - item.CurrentAmt !== "" && + item.CurrentAmt !== '' && item.CurrentMRP !== undefined && item.CurrentMRP !== null && - item.CurrentMRP !== "") || + item.CurrentMRP !== '') || (item.CurrentWhAmt !== undefined && item.CurrentWhAmt !== null && - item.CurrentWhAmt !== ""), + item.CurrentWhAmt !== '') ); const hasInvalidData = BulkProductData.every((item) => { const isAbsent = item.CurrentAmt == null && item.CurrentMRP == null; @@ -1280,12 +1285,12 @@ const StockPriceUpdate = () => { let Postdata = { CompId: CompId, BranchId: BranchId, - Type: "Variant", + Type: 'Variant', ProductDetails: filteredCurrentAmtData?.map((item) => ({ ProdId: item?.ProdId, NewMRP: item?.CurrentMRP, NewSellPrice: item?.CurrentAmt, - AdjComment: "string", + AdjComment: 'string', InwardDtlId: item?.InwardDtlId, NewWholeSalePrice: item.CurrentWhAmt, })), @@ -1295,32 +1300,32 @@ const StockPriceUpdate = () => { if (response?.data?.statusCode == 1) { setProductName(); - setMessageType("success"); + setMessageType('success'); setMessageData(response?.data?.response); fetchData(); - setBulksearchedText(""); + setBulksearchedText(''); setStockDetails([]); setBulkProductData([]); } else { - setMessageType("error"); + setMessageType('error'); setMessageData(response?.data?.response); } } else { - setMessageType("error"); - setMessageData("Please give all details"); + setMessageType('error'); + setMessageData('Please give all details'); } } else { const filteredStockDetails = StockDetails?.filter( (item) => item?.CurrentMRP && - item?.CurrentMRP !== "" && + item?.CurrentMRP !== '' && item?.CurrentAmt && - item?.CurrentAmt !== "", + item?.CurrentAmt !== '' ); if (filteredStockDetails?.length === 0) { - setMessageType("error"); - setMessageData("Please enter price details for at least one product"); + setMessageType('error'); + setMessageData('Please enter price details for at least one product'); return; } @@ -1331,7 +1336,7 @@ const StockPriceUpdate = () => { ProdId: item?.ProdId, MRP: item?.CurrentMRP, SellPrice: item?.CurrentAmt, - AdjComment: "string", + AdjComment: 'string', InwardDtlId: item?.InwardDtlId, })), UpdatedBy: 1, @@ -1343,11 +1348,11 @@ const StockPriceUpdate = () => { setStockNames(res?.data?.data); if (response?.data?.statusCode == 1) { setProductName(); - setMessageType("success"); + setMessageType('success'); setMessageData(response?.data?.response); fetchData(); } else { - setMessageType("error"); + setMessageType('error'); setMessageData(response?.data?.response); } setStockDetails([]); @@ -1464,94 +1469,94 @@ const StockPriceUpdate = () => { setPriceChangeModalOpen(true); }; - const handleExport = async (isStockVariantBased = "Yes") => { + const handleExport = async (isStockVariantBased = 'Yes') => { setExportLoading(true); setPriceChangeModalOpen(false); const uniqueBulkProductData = - isStockVariantBased === "Yes" + isStockVariantBased === 'Yes' ? BulkProductData || [] : (BulkProductData || [])?.filter( - (item, index, self) => - index === self.findIndex((p) => p.ProdId === item.ProdId), - ); + (item, index, self) => + index === self.findIndex((p) => p.ProdId === item.ProdId) + ); if (!uniqueBulkProductData?.length) { - setMessageType("error"); - setMessageData("No data available to export"); + setMessageType('error'); + setMessageData('No data available to export'); setExportLoading(false); return; } const workbook = new ExcelJS.Workbook(); - const worksheet = workbook.addWorksheet("Products"); + const worksheet = workbook.addWorksheet('Products'); /* ---------------- COLUMN DEFINITIONS ---------------- */ const columns = [ - { header: "Product Name", key: "ProdName", width: 20 }, - ...(isStockVariantBased === "Yes" - ? [{ header: "Variant Name", key: "ProdVariantName", width: 20 }] + { header: 'Product Name', key: 'ProdName', width: 20 }, + ...(isStockVariantBased === 'Yes' + ? [{ header: 'Variant Name', key: 'ProdVariantName', width: 20 }] : []), - ...(isStockVariantBased === "Yes" - ? [{ header: "Batch No", key: "BatchRef", width: 20 }] + ...(isStockVariantBased === 'Yes' + ? [{ header: 'Batch No', key: 'BatchRef', width: 20 }] : []), - ...(hasExcelField("Stock Date") - ? [{ header: "Stock Date", key: "StockDate", width: 15 }] + ...(hasExcelField('Stock Date') + ? [{ header: 'Stock Date', key: 'StockDate', width: 15 }] : []), - ...(hasExcelField("Expiry Date") - ? [{ header: "Exp Date", key: "ExpDate", width: 15 }] + ...(hasExcelField('Expiry Date') + ? [{ header: 'Exp Date', key: 'ExpDate', width: 15 }] : []), - ...(hasExcelField("Stock") - ? [{ header: "Stock", key: "Stock", width: 10 }] + ...(hasExcelField('Stock') + ? [{ header: 'Stock', key: 'Stock', width: 10 }] : []), - ...(hasExcelField("Old MRP") - ? [{ header: "Old MRP", key: "OldMRP", width: 10 }] + ...(hasExcelField('Old MRP') + ? [{ header: 'Old MRP', key: 'OldMRP', width: 10 }] : []), - ...(hasExcelField("Old SP") - ? [{ header: "Old SP", key: "OldSP", width: 10 }] + ...(hasExcelField('Old SP') + ? [{ header: 'Old SP', key: 'OldSP', width: 10 }] : []), - ...(hasExcelField("Old Wholesale Price") - ? [{ header: "Old Wholesale Price", key: "WhSalePrice", width: 14 }] + ...(hasExcelField('Old Wholesale Price') + ? [{ header: 'Old Wholesale Price', key: 'WhSalePrice', width: 14 }] : []), - ...(hasExcelField("Size") - ? [{ header: "Size", key: "Size", width: 10 }] + ...(hasExcelField('Size') + ? [{ header: 'Size', key: 'Size', width: 10 }] : []), - ...(hasExcelField("Stock Maintainence") - ? [{ header: "Stock Maintainence", key: "StockAvailable", width: 18 }] + ...(hasExcelField('Stock Maintainence') + ? [{ header: 'Stock Maintainence', key: 'StockAvailable', width: 18 }] : []), - ...(hasExcelField("UOM Name") - ? [{ header: "UOMName", key: "UOMName", width: 15 }] + ...(hasExcelField('UOM Name') + ? [{ header: 'UOMName', key: 'UOMName', width: 15 }] : []), // ...(hasExcelField("New MRP & New SP") // ? [ - { header: "New MRP", key: "NewMRP", width: 12 }, - { header: "New SP", key: "NewSP", width: 12 }, + { header: 'New MRP', key: 'NewMRP', width: 12 }, + { header: 'New SP', key: 'NewSP', width: 12 }, // ] // : []), - ...(hasExcelField("New Wholesale Price") - ? [{ header: "New Wholesale Price", key: "NewWhSalePrice", width: 14 }] + ...(hasExcelField('New Wholesale Price') + ? [{ header: 'New Wholesale Price', key: 'NewWhSalePrice', width: 14 }] : []), // --- Hidden system columns (always included) --- - { header: "ProdId", key: "ProdId", width: 1 }, + { header: 'ProdId', key: 'ProdId', width: 1 }, - ...(isStockVariantBased === "Yes" - ? [{ header: "InwardDtlId", key: "InwardDtlId", width: 1 }] + ...(isStockVariantBased === 'Yes' + ? [{ header: 'InwardDtlId', key: 'InwardDtlId', width: 1 }] : []), - { header: "key", key: "key", width: 1 }, - { header: "downloadType", key: "downloadType", width: 1 }, + { header: 'key', key: 'key', width: 1 }, + { header: 'downloadType', key: 'downloadType', width: 1 }, ]; worksheet.columns = columns; - worksheet.views = [{ state: "frozen", xSplit: 1, ySplit: 1 }]; + worksheet.views = [{ state: 'frozen', xSplit: 1, ySplit: 1 }]; const headerRow = worksheet.getRow(1); - const newMRPCol = headerRow.values.indexOf("New MRP"); - const newSPCol = headerRow.values.indexOf("New SP"); + const newMRPCol = headerRow.values.indexOf('New MRP'); + const newSPCol = headerRow.values.indexOf('New SP'); const hasNewMRPAndSP = newMRPCol > 0 && newSPCol > 0; /* ---------------- HEADER STYLE ---------------- */ @@ -1559,37 +1564,37 @@ const StockPriceUpdate = () => { const header = cell.value; const isHiddenCol = - header === "key" || - header === "ProdId" || - header === "InwardDtlId" || - header === "downloadType"; + header === 'key' || + header === 'ProdId' || + header === 'InwardDtlId' || + header === 'downloadType'; cell.font = { bold: true, size: isHiddenCol ? 1 : 11, - color: { argb: isHiddenCol ? "FFFFFFFF" : "FF000000" }, + color: { argb: isHiddenCol ? 'FFFFFFFF' : 'FF000000' }, }; cell.alignment = { - horizontal: "center", - vertical: "middle", + horizontal: 'center', + vertical: 'middle', wrapText: true, // ✅ prevents overflow in header }; cell.fill = { - type: "pattern", - pattern: "solid", + type: 'pattern', + pattern: 'solid', fgColor: { - argb: isHiddenCol ? "FFFFFFFF" : "FF52C41A", + argb: isHiddenCol ? 'FFFFFFFF' : 'FF52C41A', }, }; cell.border = isHiddenCol ? undefined : { - right: { style: "thin", color: { argb: "FF000000" } }, - bottom: { style: "thin", color: { argb: "FF000000" } }, - }; + right: { style: 'thin', color: { argb: 'FF000000' } }, + bottom: { style: 'thin', color: { argb: 'FF000000' } }, + }; }); /* ---------------- ADD DATA ---------------- */ @@ -1599,7 +1604,7 @@ const StockPriceUpdate = () => { ProdVariantName: product?.ProdVariantName, BatchRef: product?.BatchRef, StockDate: product?.InwardDate, - ExpDate: product?.ExpDate || "-", + ExpDate: product?.ExpDate || '-', Stock: product?.BalanceQty, OldMRP: product?.MRP, OldSP: product?.SellPrice, @@ -1608,13 +1613,13 @@ const StockPriceUpdate = () => { StockAvailable: product?.StockAvailable, UOMName: product?.UOMName, key: product?.key, - downloadType: isStockVariantBased === "Yes" ? "Variant" : "Product", - NewMRP: "", - NewSP: "", - NewWhSalePrice: "", + downloadType: isStockVariantBased === 'Yes' ? 'Variant' : 'Product', + NewMRP: '', + NewSP: '', + NewWhSalePrice: '', ProdId: product?.ProdId, InwardDtlId: - isStockVariantBased === "Yes" ? product?.InwardDtlId : undefined, + isStockVariantBased === 'Yes' ? product?.InwardDtlId : undefined, }); }); @@ -1627,15 +1632,15 @@ const StockPriceUpdate = () => { const newSPCell = row.getCell(newSPCol); newSPCell.dataValidation = { - type: "custom", + type: 'custom', allowBlank: true, formulae: [ `IFERROR(VALUE(${newSPCell.address}),0) <= IFERROR(VALUE(${newMRPCell.address}),0)`, ], showErrorMessage: true, - errorStyle: "stop", - errorTitle: "Invalid Selling Price", - error: "New SP cannot be greater than New MRP", + errorStyle: 'stop', + errorTitle: 'Invalid Selling Price', + error: 'New SP cannot be greater than New MRP', }; }); } @@ -1662,38 +1667,38 @@ const StockPriceUpdate = () => { const header = worksheet.getRow(1).getCell(colNumber).value; const isHiddenCol = - header === "key" || - header === "ProdId" || - header === "InwardDtlId" || - header === "downloadType"; + header === 'key' || + header === 'ProdId' || + header === 'InwardDtlId' || + header === 'downloadType'; const isEditable = - header === "New MRP" || - header === "New SP" || - header === "New Wholesale Price"; + header === 'New MRP' || + header === 'New SP' || + header === 'New Wholesale Price'; cell.protection = { locked: !isEditable }; cell.alignment = { - vertical: "middle", + vertical: 'middle', wrapText: true, }; if (isHiddenCol) { cell.font = { size: 1, - color: { argb: "FFFFFFFF" }, + color: { argb: 'FFFFFFFF' }, }; cell.fill = { - type: "pattern", - pattern: "solid", - fgColor: { argb: "FFFFFFFF" }, + type: 'pattern', + pattern: 'solid', + fgColor: { argb: 'FFFFFFFF' }, }; } }); }); /* ---------------- PROTECT SHEET ---------------- */ - await worksheet.protect("", { + await worksheet.protect('', { selectLockedCells: false, selectUnlockedCells: true, formatCells: false, @@ -1705,12 +1710,12 @@ const StockPriceUpdate = () => { /* ---------------- DOWNLOAD ---------------- */ const buffer = await workbook.xlsx.writeBuffer(); const blob = new Blob([buffer], { - type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", + type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', }); - const link = document.createElement("a"); + const link = document.createElement('a'); link.href = URL.createObjectURL(blob); - link.download = "PriceChange_Data.xlsx"; + link.download = 'PriceChange_Data.xlsx'; link.click(); setExportLoading(false); @@ -1733,8 +1738,8 @@ const StockPriceUpdate = () => { const isAllowed = allowedExcelTypes?.includes(file.type); if (!isAllowed) { Modal.error({ - title: "Invalid File Type", - content: "Only Excel files (.xls, .xlsx) are allowed.", + title: 'Invalid File Type', + content: 'Only Excel files (.xls, .xlsx) are allowed.', }); handleCancelData(); setFileLoading(false); @@ -1748,15 +1753,42 @@ const StockPriceUpdate = () => { const extractedData = extractPriceChangeDataFromExcel(arrayBuffer); - console.log(extractedData, "extractedData"); + console.log(extractedData, 'extractedData'); if ((extractedData || [])?.length === 0) { - setMessageData("No Data Found in Uploaded Sheet"); - setMessageType("error"); + setMessageData('No Data Found in Uploaded Sheet'); + setMessageType('error'); handleCancelData(); setFileLoading(false); return; } - setUploadedData(extractedData); + + // Compare and mark as Old/Modified + const comparedData = extractedData + .map((uploaded) => { + const current = BulkProductData.find( + (p) => + p.ProdId === uploaded.ProdId && + (!uploaded.InwardDtlId || p.InwardDtlId === uploaded.InwardDtlId) + ); + + if (current) { + const isModified = + Number(current.MRP) !== Number(uploaded.NewMRP) || + Number(current.SellPrice) !== Number(uploaded.NewSellPrice) || + Number(current.WhSalePrice || 0) !== + Number(uploaded.NewWholeSalePrice || 0); + + return { + ...uploaded, + isModified, + status: isModified ? 'Modified' : 'Old', + }; + } + + return { ...uploaded, isModified: false, status: 'Old' }; + }) + .sort((a, b) => Number(b.isModified) - Number(a.isModified)); + setUploadedData(comparedData); setFileLoading(false); // setFormValuesFromExtractedData(extractedData); }; @@ -1790,13 +1822,13 @@ const StockPriceUpdate = () => { }; const extractPriceChangeDataFromExcel = (arrayBuffer) => { - const workbook = read(arrayBuffer, { type: "array" }); + const workbook = read(arrayBuffer, { type: 'array' }); const worksheet = workbook.Sheets[workbook.SheetNames[0]]; const rows = utils.sheet_to_json(worksheet, { header: 1, raw: false, - defval: "", + defval: '', }); if (!rows.length) return []; @@ -1808,23 +1840,23 @@ const StockPriceUpdate = () => { // Helper to safely get column value const getVal = (row, colName) => { const idx = header.indexOf(colName); - return idx !== -1 ? row[idx] : ""; + return idx !== -1 ? row[idx] : ''; }; const result = dataRows .map((row) => { - const prodId = getVal(row, "ProdId")?.toString().trim(); + const prodId = getVal(row, 'ProdId')?.toString().trim(); if (!prodId) return null; const newMRP = - getVal(row, "New MRP") !== "" ? Number(getVal(row, "New MRP")) : null; + getVal(row, 'New MRP') !== '' ? Number(getVal(row, 'New MRP')) : null; const newSP = - getVal(row, "New SP") !== "" ? Number(getVal(row, "New SP")) : null; + getVal(row, 'New SP') !== '' ? Number(getVal(row, 'New SP')) : null; const newWholesale = - getVal(row, "New Wholesale Price") !== "" - ? Number(getVal(row, "New Wholesale Price")) + getVal(row, 'New Wholesale Price') !== '' + ? Number(getVal(row, 'New Wholesale Price')) : null; // ❌ Must have at least one change @@ -1836,37 +1868,37 @@ const StockPriceUpdate = () => { // 🔹 Product identity localId: uuidv4(), ProdId: prodId, - InwardDtlId: getVal(row, "InwardDtlId") - ? getVal(row, "InwardDtlId").toString() + InwardDtlId: getVal(row, 'InwardDtlId') + ? getVal(row, 'InwardDtlId').toString() : null, // 🔹 Product info - VariantName: getVal(row, "Variant Name") || null, - BatchRef: getVal(row, "Batch No") || null, - ProductName: getVal(row, "Product Name") || null, - Size: getVal(row, "Size") || null, - UOMName: getVal(row, "UOMName") || null, - StockMaintainence: getVal(row, "Stock Maintainence") || null, + VariantName: getVal(row, 'Variant Name') || null, + BatchRef: getVal(row, 'Batch No') || null, + ProductName: getVal(row, 'Product Name') || null, + Size: getVal(row, 'Size') || null, + UOMName: getVal(row, 'UOMName') || null, + StockMaintainence: getVal(row, 'Stock Maintainence') || null, // 🔹 Stock / dates - StockDate: getVal(row, "Stock Date") || null, - ExpDate: getVal(row, "Exp Date") || null, - downloadType: getVal(row, "downloadType") || null, + StockDate: getVal(row, 'Stock Date') || null, + ExpDate: getVal(row, 'Exp Date') || null, + downloadType: getVal(row, 'downloadType') || null, Stock: - getVal(row, "Stock") !== "" ? Number(getVal(row, "Stock")) : null, + getVal(row, 'Stock') !== '' ? Number(getVal(row, 'Stock')) : null, // 🔹 Old prices OldMRP: - getVal(row, "Old MRP") !== "" - ? Number(getVal(row, "Old MRP")) + getVal(row, 'Old MRP') !== '' + ? Number(getVal(row, 'Old MRP')) : null, OldSP: - getVal(row, "Old SP") !== "" ? Number(getVal(row, "Old SP")) : null, + getVal(row, 'Old SP') !== '' ? Number(getVal(row, 'Old SP')) : null, OldWholeSalePrice: - getVal(row, "Old Wholesale Price") !== "" - ? Number(getVal(row, "Old Wholesale Price")) + getVal(row, 'Old Wholesale Price') !== '' + ? Number(getVal(row, 'Old Wholesale Price')) : null, // 🔹 New prices (normalized) @@ -1883,7 +1915,7 @@ const StockPriceUpdate = () => { const handleCancelData = () => { dispatch(emptyExcelData()); if (fileInputRef.current) { - fileInputRef.current.value = ""; + fileInputRef.current.value = ''; } setUploadedData([]); }; @@ -1901,26 +1933,26 @@ const StockPriceUpdate = () => { // If MRP is present, SP must also be present if (newMRP && !newSP) { - setMessageType("error"); + setMessageType('error'); setMessageData( - "If New MRP is provided, New SP must also be provided", + 'If New MRP is provided, New SP must also be provided' ); return; } // If SP is present, MRP must also be present if (newSP && !newMRP) { - setMessageType("error"); + setMessageType('error'); setMessageData( - "If New SP is provided, New MRP must also be provided", + 'If New SP is provided, New MRP must also be provided' ); return; } // New SP cannot be greater than New MRP if (newMRP && newSP && parseFloat(newSP) > parseFloat(newMRP)) { - setMessageType("error"); - setMessageData("New SP cannot be greater than New MRP"); + setMessageType('error'); + setMessageData('New SP cannot be greater than New MRP'); return; } } @@ -1930,10 +1962,13 @@ const StockPriceUpdate = () => { const hasMRP = !!data?.NewMRP; const hasSell = !!data?.NewSellPrice; const hasWholesale = !!data?.NewWholeSalePrice; + const isModified = data?.isModified === true; // valid cases - if (hasMRP && hasSell) return true; - if (!hasMRP && !hasSell && hasWholesale) return true; + if (hasMRP && hasSell && isModified) return true; + + // ✅ Case 2: Only Wholesale changed + if (!hasMRP && !hasSell && hasWholesale && isModified) return true; return false; }) @@ -1943,7 +1978,7 @@ const StockPriceUpdate = () => { NewSellPrice: data?.NewSellPrice, NewMRP: data?.NewMRP, NewWholeSalePrice: data?.NewWholeSalePrice, - AdjComment: "string", + AdjComment: 'string', })); const putData = { @@ -1955,25 +1990,31 @@ const StockPriceUpdate = () => { CreatedBy: UserId, }; + if (!updatedData || updatedData.length === 0) { + setMessageData('Minimum 1 product needs to be changed or added'); + setMessageType('error'); + return; + } + const res = await dispatch(bulkPriceUpdate(putData))?.unwrap(); if (res?.data?.statusCode === 1) { - setMessageData(res?.data?.response || "Price Updated Successfully"); - setMessageType("success"); + setMessageData(res?.data?.response || 'Price Updated Successfully'); + setMessageType('success'); setUploadedData([]); handleCancelData(); setExcelModalOpen(false); await fetchData(); } else { setMessageData(res?.data?.response); - setMessageType("error"); + setMessageType('error'); } // If validation passes, proceed with submission - console.log("Form validation passed", updatedData); + console.log('Form validation passed', updatedData); } catch (error) { - setMessageType("error"); - setMessageData("Please check all fields and try again"); + setMessageType('error'); + setMessageData('Please check all fields and try again'); } finally { setLoading(false); } @@ -1984,14 +2025,14 @@ const StockPriceUpdate = () => { AppId: AppId, CompId: CompId, BranchId: BranchId, - Type: "GB", - FormType: fieldSetup ? "Price Change" : "Price Change Sheet", + Type: 'GB', + FormType: fieldSetup ? 'Price Change' : 'Price Change Sheet', TypeId: fieldSetup ? categoryId : excelCategoryId, ConfigDtl: (fieldSetup ? selectedFields : selectedExcelFields)?.map( (field) => ({ ConfigId: field, - Access: "Y", - }), + Access: 'Y', + }) ), CreatedBy: UserId, }; @@ -1999,7 +2040,7 @@ const StockPriceUpdate = () => { const response = await dispatch(postFieldSetup(postData))?.unwrap(); if (response?.data?.statusCode === 1) { - setMessageType("success"); + setMessageType('success'); setMessageData(response?.data?.response); if (fieldSetup) { await getFieldSetup(); @@ -2007,8 +2048,8 @@ const StockPriceUpdate = () => { await getExcelFieldSetup(); } } else { - setMessageType("error"); - setMessageData("Failed to set up fields"); + setMessageType('error'); + setMessageData('Failed to set up fields'); } }; @@ -2047,28 +2088,19 @@ const StockPriceUpdate = () => { onComplete={onComplete} /> -
+
- +
- {RadioSelection == "Bulk" && ( -
+ {RadioSelection == 'Bulk' && ( +
{ />
-
+
)}
- {RadioSelection == "Single" && ( + {RadioSelection == 'Single' && (
-
+
@@ -2119,7 +2151,7 @@ const StockPriceUpdate = () => { onChangeFunction={(value, option) => HandleStockNames(value, option) } - style={{ width: "240px" }} + style={{ width: '240px' }} options={DataSource} isOnchanges={ProductName ? true : false} /> @@ -2148,17 +2180,17 @@ const StockPriceUpdate = () => {
{
- {(RadioSelection == "Bulk" || - (RadioSelection == "Single" && StockDetails.length > 0)) && ( -
- } - disabled={addnewAccess} - > -
- )} + {(RadioSelection == 'Bulk' || + (RadioSelection == 'Single' && StockDetails.length > 0)) && ( +
+ } + disabled={addnewAccess} + > +
+ )}
- {RadioSelection == "Single" && ( + {RadioSelection == 'Single' && (
{ StockDetails?.length < 11 ? false : { - current: page, - pageSize: pageSize, - onChange: handlePageChange, - } + current: page, + pageSize: pageSize, + onChange: handlePageChange, + } } onChange={handleChange} >
)} - {RadioSelection == "Bulk" && ( -
+ {RadioSelection == 'Bulk' && ( +
{ pagination={{ current: Bulkchangepage, pageSize: pageSize, - pageSizeOptions: ["10", "20", "30"], + pageSizeOptions: ['10', '20', '30'], onChange: handlePageChangeBulk, showSizeChanger: false, }} @@ -2232,7 +2261,7 @@ const StockPriceUpdate = () => { open={excelModalOpen} title="Bulk Upload" footer={false} - className={"bulkuploadmodal padding-less-modal"} + className={'bulkuploadmodal padding-less-modal'} handleCancel={() => { setExcelModalOpen(false); handleCancelData(); @@ -2243,24 +2272,24 @@ const StockPriceUpdate = () => { {uploadedData?.length === 0 && (
@@ -2268,15 +2297,15 @@ const StockPriceUpdate = () => {
{ } : () => showPriceChangeModal() + exportLoading ? () => {} : () => showPriceChangeModal() } >
-
+
Export Excel
@@ -2287,29 +2316,29 @@ const StockPriceUpdate = () => { {!fileLoading && (
{/* */}
{ onChange={handleFileUpload} ref={fileInputRef} style={{ - position: "absolute", + position: 'absolute', top: 0, left: 0, - width: "100%", - height: "100%", + width: '100%', + height: '100%', opacity: 0, - cursor: "pointer", + cursor: 'pointer', }} /> - - {" "} - Upload Sheet{" "} + + {' '} + Upload Sheet{' '}
)} {fileLoading && ( -
+
-

+

Processing file...