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/App.jsx b/src/App.jsx
index b7fd00b..bec22f1 100644
--- a/src/App.jsx
+++ b/src/App.jsx
@@ -1,52 +1,36 @@
-// AppRoutes.jsx
-import React, { useEffect, useState, useRef, lazy, } from 'react';
+import { useEffect, lazy, Suspense } from 'react';
import { Routes, Route } from 'react-router-dom';
-import { useNavigate } from 'react-router-dom';
-import { useDispatch, useSelector } from 'react-redux';
+import { useSelector } from 'react-redux';
import ProtectedRoutes from './ProtectedRoutes';
-
-import SelfBooking from './Pages/SelfBooking/SelfBooking.jsx'
-import { isMobile, isIOS } from "react-device-detect";
-// const { routesConfig } = lazy(() => import('./routesConfig'));
+import SelfBooking from './Pages/SelfBooking/SelfBooking.jsx';
+import { isMobile, isIOS } from 'react-device-detect';
import { routesConfig } from './routesConfig';
-import {
- ChangeAppExpDateData,
- changeHeightforExpDate,
- getAppSubscriptionDate,
- GlobalItemCard,
-} from './Features/BookingScreen/BookingData/BookingData.js';
-import {
- checkSession,
- GenerateLogout,
-} from './Features/BrachLogin/BranchLogin.js';
-import {
- clearSession,
- getSession,
- TokendecryptedValuesFun,
-} from './Services/Others.js';
+import { GlobalItemCard } from './Features/BookingScreen/BookingData/BookingData.js';
+import { clearSession, getSession } from './Services/Others.js';
import devtools from 'devtools-detect';
-import KisokSelBooking from './Pages/SelfBooking/KisokSelBooking.jsx';
-import IndividualBooking from './Pages/SelfBooking/IndividualBooking.jsx';
+const KisokSelBooking = lazy(
+ () => import('./Pages/SelfBooking/KisokSelBooking')
+);
+
+const IndividualBooking = lazy(
+ () => import('./Pages/SelfBooking/IndividualBooking')
+);
const commonSubDir = import.meta.env.ENV_COMMON_BASE_URL;
const subDirectory = import.meta.env.ENV_BASE_URL;
-import "../ownLib/my-ui-lib.css"
+import '../ownLib/my-ui-lib.css';
import CustomerMenuPage from './Pages/Reports/MenuQRCode/CustomerMenuPage.jsx';
import WeightScaleApp from './Pages/BookingScreen/WeightscaleApp.jsx';
-
-import { getPurchasedAppDetails, postInvoice } from './Features/BookingScreen/Pricing/Pricing.js';
-import { sendSms } from './Features/Payment/PaymentDetails/PaymentDetails.js';
+import useSubscriptionManager from './useSubscriptionManager.js';
+import useSessionManager from './useSessionManager.js';
import ExtendSubscriptionModal from './Pages/ExtentedModal/ExtendSubscriptionModal.jsx';
+
const AppRoutes = () => {
- const navigate = useNavigate();
- const dispatch = useDispatch();
const ItemCard = useSelector(GlobalItemCard);
- const [remainingDays, setRemainingDays] = useState(null);
- const prevRemainingDays = useRef(null);
- const [sessionData, setSessionData] = useState(null);
- const [devToolsOpen, setDevToolsOpen] = useState(false);
- const [extendModel, setExtendModel] = useState(false);
+ const { sessionData, logout } = useSessionManager(ItemCard);
+ const { remainingDays, handleCancel, handlePay, freeExtend, extendModel } = useSubscriptionManager(sessionData, logout);
+
useEffect(() => {
- const handlePopState = (e) => {
+ const handlePopState = () => {
const SessionId = getSession('SessionId');
if (!SessionId) {
alert(
@@ -68,296 +52,18 @@ const AppRoutes = () => {
};
}, []);
- //cmd it start
- // useEffect(() => {
- // sessionCheckFun()
- // }, [navigate, ItemCard]);
-
- //cmd it End
-
-
useEffect(() => {
- const loadSessionData = () => {
- const CompId = getSession('CompId');
- const AppId = getSession('AppId');
- const BranchId = getSession('BranchId');
- const UserType = getSession('UserType');
- console.log('loadSessionData:', CompId, AppId, BranchId, UserType);
-
- if (CompId && AppId && BranchId) {
- setSessionData({ CompId, AppId, BranchId, UserType });
- return true; // Indicate that session data is available
+ if (isMobile || isIOS) return;
+ const timer = setInterval(() => {
+ if (devtools.isOpen) {
+ document.body.innerHTML =
+ "
Close Inspect to continue
";
}
- return false; // Indicate that session data is not yet available
- };
+ }, 1000);
- if (!loadSessionData()) {
- const interval = setInterval(() => {
- if (loadSessionData()) {
- clearInterval(interval); // Stop checking once data is available
- }
- }, 1000);
-
- return () => clearInterval(interval); // Cleanup interval on unmount
- }
+ return () => clearInterval(timer);
}, []);
- useEffect(() => {
- const fetchExpDate = async () => {
- if (!sessionData) {
- console.log('Session data not available, skipping API call...');
- return;
- }
-
- try {
- const { CompId, AppId, BranchId, UserType } = sessionData;
- const data = { CompId, BranchId, AppId };
-
- let res = await dispatch(getAppSubscriptionDate(data)).unwrap();
-
- if (res?.data?.statusCode === 1 && res?.data?.data?.length > 0) {
- const expData = res?.data?.data?.[0];
-
- if (prevRemainingDays.current !== expData.RemainingDays) {
- prevRemainingDays.current = expData.RemainingDays;
- setRemainingDays(expData.RemainingDays);
- dispatch(ChangeAppExpDateData(expData));
- dispatch(changeHeightforExpDate(expData.RemainingDays));
-
-
-
-
-
- if (
- expData.RemainingDays < 1 &&
- expData.RemainingHours < 1 &&
- expData.RemainingMinutes < 1 &&
- expData.RemainingSeconds < 1
- ) {
-
-
-
- if (
- (UserType !== 'Super Admin' ||
- UserType !== 'Super Admin User') && (expData?.PlanType?.toLowerCase() == "extend expired")
- ) {
- console.log('Subscription expired, logging out...');
- alert(
- 'Subscription expired, logging out. Redirecting to login...'
- );
- Logout();
- }
- else if (
- (UserType !== 'Super Admin' ||
- UserType !== 'Super Admin User') && (expData?.PlanType?.toLowerCase() == "plan expired")
- ) {
- setExtendModel(true)
- // "Extend Expired"
-
-
-
-
- // alert(
- // 'Subscription expired, logging out. Redirecting to login...'
- // );
- // Logout();
- }
- }
- }
-
- } else {
- console.log('No subscription data found, logging out...');
- alert(
- 'No subscription data found, logging out. Redirecting to login...'
- );
- Logout();
- }
- } catch (error) {
- console.error('Error fetching subscription data:', error);
- }
- };
-
- if (remainingDays === null) {
- fetchExpDate();
- }
-
- const interval = setInterval(fetchExpDate, 60 * 60 * 1000);
-
- return () => clearInterval(interval);
- }, [sessionData, remainingDays]);
-
- const Logout = async () => {
- const UserId = getSession('UserId');
- const status = 'N';
- try {
- const res = await dispatch(GenerateLogout({ UserId, status })).unwrap();
- if (res?.data?.statusCode === 1) {
- sessionStorage.clear();
- window.location.replace(`${commonSubDir}`);
- }
- } catch (error) {
- console.error('Logout failed:', error);
- }
- };
- // mohan
- // useEffect(() => {
- // if (isMobile || isIOS) {
- // console.log("📱 Mobile/iOS device → skipping DevTools detection");
- // return;
- // }
- // const checkDevTools = setInterval(() => {
- // if (devtools.isOpen && !devToolsOpen) {
- // setDevToolsOpen(true);
- // document.body.innerHTML =
- // "Close Inspect to continue using the application.
";
- // }
- // else if (!devtools.isOpen && devToolsOpen) {
- // setDevToolsOpen(false);
-
- // setTimeout(() => {
- // window.location.reload();
- // }, 100);
-
- // clearInterval(checkDevTools);
- // }
-
- // if (!devtools.isOpen) {
- // let before = performance.now();
-
- // let after = performance.now();
-
- // let executionDelay = after - before;
-
- // if (executionDelay > 100) {
- // setDevToolsOpen(true);
- // document.body.innerHTML =
- // "Close Inspect to continue using the application.
";
- // } else {
- // setDevToolsOpen(false);
- // }
- // }
- // }, 1000);
-
- // return () => clearInterval(checkDevTools);
- // }, [devToolsOpen]);
-
- const sessionCheckFun = async () => {
- const UserId = getSession('UserId');
- const sessionId = getSession('SessionId');
- const IsLogout = getSession('Mode');
- let encryptedLoginType = TokendecryptedValuesFun(
- sessionStorage.getItem('LoginType')
- );
- if (encryptedLoginType != 'Kiosk') {
- const res = await dispatch(checkSession({ UserId, sessionId })).unwrap();
- if (res?.data?.statusCode === 1) {
- if (res?.data?.response === 'False') {
- if (IsLogout !== 'Logout') {
- alert('Session invalid. Redirecting to login...');
- }
- clearSession();
- window.location.replace(commonSubDir);
- }
- }
- }
- };
-
- // ---------------- DATE UTILS ----------------
- function formatDate(date) {
- const year = date.getFullYear();
- const month = String(date.getMonth() + 1).padStart(2, '0');
- const day = String(date.getDate()).padStart(2, '0');
- const hours = String(date.getHours()).padStart(2, '0');
- const minutes = String(date.getMinutes()).padStart(2, '0');
- const seconds = String(date.getSeconds()).padStart(2, '0');
- const milliseconds = String(date.getMilliseconds()).padStart(3, '0');
-
- return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}.${milliseconds}`;
- }
-
- function addDays(dateString, days) {
- // Make it ISO-safe for iOS / WebView
- const isoDate = dateString.replace(' ', 'T');
- const currentDate = new Date(isoDate);
-
- currentDate.setDate(currentDate.getDate() + Number(days));
-
- return formatDate(currentDate);
- }
-
- // ---------------- MAIN FUNCTION ----------------
- const freeExtend = async () => {
- try {
- const { CompId, AppId, BranchId, UserType } = sessionData;
- const UserId = getSession('UserId');
-
- // Current date
- const now = new Date();
- const currentDate = formatDate(now);
-
- // 1️⃣ Get purchased app details
- const response1 = await dispatch(
- getPurchasedAppDetails({ AppId, UserId })
- ).unwrap();
-
- const PurchasedDetails = response1?.data?.data;
-
- if (!PurchasedDetails || !PurchasedDetails.length) {
- console.error('No purchased details found');
- return;
- }
-
- // 2️⃣ Prepare post data
- const postData = {
- UserId: UserId,
- AppId: AppId,
- PricingId: PurchasedDetails[0]?.PricingId,
- PurDate: currentDate,
- NoofDays: 30,
- PaymentMode: 27,
- PaymentStatus: 'S',
- LicenseStatus: PurchasedDetails[0]?.LicenseStatus,
- Price: PurchasedDetails[0]?.Price ?? 0,
- TaxId: PurchasedDetails[0]?.TaxId ?? 0,
- NetPrice: PurchasedDetails[0]?.ExistingPlanNetPrice ?? 0,
- ValidityStart: currentDate,
- ValidityEnd: addDays(
- currentDate,
- PurchasedDetails[0]?.NoOfDays
- ),
- CreatedBy: UserId,
- TaxAmount: PurchasedDetails[0]?.TaxAmount ?? 0,
- MobileNo: getSession('MobileNo'),
- MailId: 'ts@gmmail.com',
- Type: "FreeExtend"
- };
-
- // 3️⃣ Post invoice
- const response = await dispatch(postInvoice(postData)).unwrap();
-
- // 4️⃣ Send SMS if required
- if (response?.data?.statusCode === 1 && response?.data?.SMSbody) {
- await dispatch(
- sendSms({ body: response.data.SMSbody })
- );
- setExtendModel(false)
-
- }
-
- } catch (error) {
- console.error('freeExtend error:', error);
- }
- };
- const handleCancel = () => {
- Logout();
- setExtendModel(false)
-
- }
- const handlePay = () => {
- setExtendModel(false)
- let AppName = getSession("AppName")
- navigate(`${subDirectory}PricingPage`, { state: { AppName: AppName } });
- }
if (extendModel) {
return (
@@ -368,9 +74,8 @@ const AppRoutes = () => {
/>
);
}
-
return (
- <>
+ Loading…}>
{
path={`${subDirectory}weightscaleapp`}
element={}
/>
- } />
+ }
+ />
{
element={}
/>
- >
+
);
};
diff --git a/src/AuthContext.jsx b/src/AuthContext.jsx
index 94bcb3a..825ee8b 100644
--- a/src/AuthContext.jsx
+++ b/src/AuthContext.jsx
@@ -1,5 +1,5 @@
// AuthContext.jsx
-import React, { createContext, useContext, useState, useEffect } from 'react';
+import { createContext, useContext, useState, useEffect } from 'react';
import { useDispatch } from 'react-redux';
import { getSession } from './Services/Others';
import {
@@ -64,7 +64,8 @@ export const AuthProvider = ({ children }) => {
);
setAdvance(hasAdvance);
const hasProOrAdvance =
- hasAdvance || pricingData.some((item) => item.PricingName === 'Customized');
+ hasAdvance ||
+ pricingData.some((item) => item.PricingName === 'Customized');
setProORAdvance(hasProOrAdvance);
} catch (error) {
console.error('Error fetching pricing name:', error);
diff --git a/src/Components/Forms/main.scss b/src/Components/Forms/main.scss
index c75a1ce..55fcee9 100644
--- a/src/Components/Forms/main.scss
+++ b/src/Components/Forms/main.scss
@@ -564,7 +564,7 @@ Button[disabled] {
.ant-table-cell {
background: #fafafa7a;
//vicky
- padding: 1px 8px !important;
+ padding: 6px 6px !important;
border: 0.5px solid rgb(235, 235, 235);
}
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/Components/Menu/SideMenu.jsx b/src/Components/Menu/SideMenu.jsx
index 095fafc..5f6adf2 100644
--- a/src/Components/Menu/SideMenu.jsx
+++ b/src/Components/Menu/SideMenu.jsx
@@ -5,7 +5,6 @@ import { Menu } from 'antd';
import {
changePreviewComponents,
changeSelectedPrintdummyData,
- getTemplate,
} from '../../Features/ThemeChange/ThemeChange';
import {
changeBookingType,
@@ -69,9 +68,6 @@ const SideMenu = ({ mode, theme, items }) => {
const [clickedKeys, setClickedKeys] = useState([]);
const dispatch = useDispatch();
const navigate = useNavigate();
- const CompId = getSession('CompId');
- const BranchId = getSession('BranchId');
- const AppId = getSession('AppId');
const DineinDefault = useSelector(GlobalDineinDefault);
const handleMouseEnter = (e) => {
@@ -187,28 +183,7 @@ const SideMenu = ({ mode, theme, items }) => {
if (e == `${subDirectory}saleslayouts/print-selection`) {
dispatch(changeSelectedPrintdummyData(true));
}
- // if(e==`${subDirectory}kiosksales`){
- // const elem = document.documentElement;
- // if (elem.requestFullscreen) {
- // elem.requestFullscreen();
- // } else if (elem.mozRequestFullScreen) { // Firefox
- // elem.mozRequestFullScreen();
- // } else if (elem.webkitRequestFullscreen) { // Chrome, Safari and Opera
- // elem.webkitRequestFullscreen();
- // } else if (elem.msRequestFullscreen) { // IE/Edge
- // elem.msRequestFullscreen();
- // }
- // }else{
- // if (document.exitFullscreen) {
- // document.exitFullscreen();
- // } else if (document.mozCancelFullScreen) { // Firefox
- // document.mozCancelFullScreen();
- // } else if (document.webkitExitFullscreen) { // Chrome, Safari and Opera
- // document.webkitExitFullscreen();
- // } else if (document.msExitFullscreen) { // IE/Edge
- // document.msExitFullscreen();
- // }
- // }
+
navigate(e);
} catch (error) {
diff --git a/src/Components/Menu/SideMenuPozo.jsx b/src/Components/Menu/SideMenuPozo.jsx
index bbd38dd..1856fd9 100644
--- a/src/Components/Menu/SideMenuPozo.jsx
+++ b/src/Components/Menu/SideMenuPozo.jsx
@@ -1,45 +1,15 @@
-import React, { useState, useEffect, useRef } from 'react';
+import { useState, useEffect, useRef } from 'react';
import { useNavigate, useLocation } from 'react-router-dom';
import { useSelector } from 'react-redux';
-import {
- FaBars,
- FaThLarge,
- FaHome,
- FaCog,
- FaChartBar,
- FaFileAlt,
- FaMobileAlt,
- FaSignOutAlt,
- FaSignInAlt,
- FaArrowRight,
- FaCaretRight,
-} from 'react-icons/fa';
-import {
- MdSettings,
- MdOutlineReport,
- MdOutlineHome,
- MdOutlineKeyboardArrowDown,
- MdOutlineKeyboardArrowRight,
-} from 'react-icons/md';
-import { BiLogOut, BiLogIn } from 'react-icons/bi';
-import {
- AiOutlineAppstore,
- AiOutlineSetting,
- AiOutlineBarChart,
- AiOutlineFileText,
-} from 'react-icons/ai';
-import { GiHamburgerMenu } from 'react-icons/gi';
+
import './SideMenuPozo.scss';
-import { FaCaretDown } from 'react-icons/fa';
import { useDispatch } from 'react-redux';
import { useContext } from 'react';
import { AuthContext } from '../../AuthContext';
import PozoMenu from './PozoMenu';
-import { getSession } from '../../Services/Others';
import {
changePreviewComponents,
- changeSelectedPrintdummyData,
- getTemplate,
+ changeSelectedPrintdummyData
} from '../../Features/ThemeChange/ThemeChange';
import {
changeBookingType,
@@ -67,7 +37,7 @@ import {
import { ChangeTotalAmount } from '../../Features/ExteraCharges/ExtraCharges';
import * as Offer from '../../Features/Offer/Offer';
import { FiMenu } from 'react-icons/fi';
-import POZOMIND from '../../Images/PozomindWLogo.png';
+
import {
ChangeFullFreeProductList,
changeFullOfferAppliedProducts,
@@ -165,9 +135,7 @@ const SideMenuPozo = ({ items = [] }) => {
const [collapsed, setCollapsed] = useState(window.innerWidth < 768);
const [dropdownPosition, setDropdownPosition] = useState({});
const menuRef = useRef();
- const CompId = getSession('CompId');
- const BranchId = getSession('BranchId');
- const AppId = getSession('AppId');
+
const DineinDefault = useSelector(GlobalDineinDefault);
const [collapse, setCollapse] = useState(false);
@@ -381,57 +349,7 @@ const SideMenuPozo = ({ items = [] }) => {
(item) => !bottomKeys.includes(item.label)
);
// Recursive render for menu and submenus
- const renderMenuItems = (items, parentKeys = [], level = 0) => (
- 0 ? ' nested-list' : ''}`}>
- {(items || []).filter(Boolean).map((item) => (
-
-
0 ? 'dropdown-submenu-item' : 'menu-item'}${isSelected(item.key) || (level === 0 && hasSelectedChild(item)) ? ' selecteded' : ''}${isOpen(item.key) ? ' open' : ''}${item.children ? ' has-children' : ''}`}
- onClick={(e) => {
- e.stopPropagation();
- handleMenuClick(item, parentKeys, e, level);
- }}
- // style={{ paddingLeft: `${level * 10 + 1}px` }}
- >
- {item.icon && level === 0 && (
-
- {item.icon}
-
- )}
- {!collapse && {item.label}}
- {!collapse && (
-
- {isDropdownItemSelected(item) ? '●' : ''}
-
- )}
- {item.children && !collapse && (
-
- {level === 0 ? (
-
- ) : (
-
- )}
-
- )}
-
- {item.children && isOpen(item.key) && !collapse && (
-
0 ? ' nested' : ''}`}>
- {renderMenuItems(
- item.children,
- [...parentKeys, item.key],
- level + 1
- )}
-
- )}
-
- ))}
-
- );
+
// Custom onClick handler for PozoMenu
const handlePozoMenuClick = (e) => {
diff --git a/src/Features/PurchaseOrder/PurchaseOrder.js b/src/Features/PurchaseOrder/PurchaseOrder.js
index b1b0994..7445091 100644
--- a/src/Features/PurchaseOrder/PurchaseOrder.js
+++ b/src/Features/PurchaseOrder/PurchaseOrder.js
@@ -70,13 +70,15 @@ export const postStockAdjustment = createAsyncThunk(
export const getPurchaseSupplierAndWareHouseData = createAsyncThunk(
'PurchaseOrder/getPurchaseSupplierAndWareHouseData',
async (ProdData, { rejectWithValue }) => {
- const { AppId, CompId, BranchId } = ProdData;
+ const { AppId, CompId, BranchId, Type } = ProdData;
if (AppId && CompId && BranchId) {
try {
- const response = await axiosRetailInstanceData.get(
- `/Supplier/AllSupplierBranchDropdown?appId=${AppId}&compId=${CompId}&branchId=${BranchId}`
- );
+ let url = `/Supplier/AllSupplierBranchDropdown?appId=${AppId}&compId=${CompId}&branchId=${BranchId}`;
+ if (Type) {
+ url += `&Type=${Type}`;
+ }
+ const response = await axiosRetailInstanceData.get(url);
return response.data;
} catch (error) {
return rejectWithValue(error.response?.data || error.message);
diff --git a/src/Pages/Automated Reorder/AutomatedReorderList.jsx b/src/Pages/Automated Reorder/AutomatedReorderList.jsx
index 49351a7..d574ead 100644
--- a/src/Pages/Automated Reorder/AutomatedReorderList.jsx
+++ b/src/Pages/Automated Reorder/AutomatedReorderList.jsx
@@ -20,6 +20,7 @@ import { DefaultModal } from "../../Components/Modal/DefaultModal";
import { FaRegEye } from "react-icons/fa";
import { render } from "react-dom";
import { useAuth } from "../../AuthContext";
+import "./AutomatedReorder.scss";
const subDirectory = import.meta.env.BASE_URL;
diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingEditQuantity/BSBillingEditQuantity.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingEditQuantity/BSBillingEditQuantity.jsx
index af7eb6a..4a3942d 100644
--- a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingEditQuantity/BSBillingEditQuantity.jsx
+++ b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingEditQuantity/BSBillingEditQuantity.jsx
@@ -3393,19 +3393,19 @@ const [RadioBtnSelection, setRadioBtnSelection] = useState(() => {
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;
}
diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingEditQuantity/WeightCalculatePrice.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingEditQuantity/WeightCalculatePrice.jsx
index ce68e60..c646c5e 100644
--- a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingEditQuantity/WeightCalculatePrice.jsx
+++ b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingEditQuantity/WeightCalculatePrice.jsx
@@ -9,7 +9,7 @@ const WeightCalculatePrice = ({ itemData, CartOrderDetails, onSubmit }) => {
const [enteredPrice, setEnteredPrice] = useState('');
const [enteredQty, setEnteredQty] = useState('');
const [calculatedQty, setCalculatedQty] = useState(0);
- const [calcMode, setCalcMode] = useState('amt');
+ const [calcMode, setCalcMode] = useState('kgs');
const priceInputRef = useRef(null);
const [form] = Form.useForm();
@@ -82,8 +82,8 @@ const WeightCalculatePrice = ({ itemData, CartOrderDetails, onSubmit }) => {
form.resetFields();
}}
>
- AMT
KGS
+ AMT
diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable1/BSBillingTable1.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable1/BSBillingTable1.jsx
index 1622ded..a61f899 100644
--- a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable1/BSBillingTable1.jsx
+++ b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable1/BSBillingTable1.jsx
@@ -303,14 +303,19 @@ const BSBillingTable1 = () => {
if (!event.ctrlKey) return;
if (key === 'q') {
- event.preventDefault();
- handleShortcut('qty');
- }
-
- if (key === 'e') {
- event.preventDefault();
- handleShortcut('price');
- }
+ 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);
diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable3/BSBillingTable3.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable3/BSBillingTable3.jsx
index 298f997..5af7c1e 100644
--- a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable3/BSBillingTable3.jsx
+++ b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable3/BSBillingTable3.jsx
@@ -241,15 +241,20 @@ const BSBillingTable3 = () => {
// 👉 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');
+ } 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/BSBillingTable4/BSBillingTable4.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable4/BSBillingTable4.jsx
index c0665f2..f43aa0b 100644
--- a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable4/BSBillingTable4.jsx
+++ b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable4/BSBillingTable4.jsx
@@ -294,15 +294,20 @@ const BSBillingTable4 = () => {
// 👉 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');
+ } 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/BsBill.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable5/BsBill.jsx
index a6a4784..4e55d96 100644
--- a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable5/BsBill.jsx
+++ b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable5/BsBill.jsx
@@ -1940,15 +1940,20 @@ const BsBill = () => {
// 👉 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');
+ } 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/BSBillingTable6/BSBillingTable6.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable6/BSBillingTable6.jsx
index f6263dd..5433a60 100644
--- a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable6/BSBillingTable6.jsx
+++ b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable6/BSBillingTable6.jsx
@@ -267,16 +267,20 @@ const BSBillingTable6 = () => {
}
// 👉 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');
+ } 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/BSBillingTable7/BSBillingTable7.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable7/BSBillingTable7.jsx
index e1fd535..406cd6b 100644
--- a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable7/BSBillingTable7.jsx
+++ b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable7/BSBillingTable7.jsx
@@ -260,14 +260,20 @@ const BSBillingTable7 = () => {
return;
}
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');
+ } 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/ComboBillTableEdit/ComboEditQtyAndRate.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/ComboBillTableEdit/ComboEditQtyAndRate.jsx
new file mode 100644
index 0000000..243f7f4
--- /dev/null
+++ b/src/Pages/BookingScreen/Components/BSBillingTables/ComboBillTableEdit/ComboEditQtyAndRate.jsx
@@ -0,0 +1,3250 @@
+import { useCallback, useEffect, useRef, useState } from 'react';
+import { shallowEqual, useDispatch, useSelector } from 'react-redux';
+import { Form } from 'antd';
+import {
+ GlobalOrderCardDetails,
+ changeOrderCardDetails,
+ changeHoldOrderDtl,
+ changePreviousOrderLength,
+ GlobalOrderType,
+ GlobalReorderProductDetails,
+ PreferenceData,
+ getConfigType,
+} from '../../../../../Features/BookingScreen/BookingData/BookingData';
+import { Messages } from '../../../../../Components/Notifications/Messages';
+import '../../../../../Styles/BookingScreen/Components/BSBillingTables/BSBillingEditQuantity/BSBillingEditQuantity.scss';
+import { useApplyOfferto_CardDetail } from '../../UtillComponents/BSNavBarOffer/BSNavBarOffer_CustomHooks.jsx';
+import {
+ getTemplateData,
+ StoredSessionData,
+} from '../../../../../Features/ThemeChange/ThemeChange.js';
+import { GlobalEmpAccessDetail } from '../../../../../Features/AppPage/CenterPage.js';
+import {
+ ChangeFullFreeProductList,
+ changeFullOfferAppliedProducts,
+ ChangeOfferAppliedProducts,
+ GlobalFreeProdList,
+ GlobalOfferAppliedProducts,
+ RemoveOfferAppliedProduct,
+} from '../../../../../Features/Offer/Offernew/BookingOffernew.js';
+import { validateOffers } from '../../BSItemCards/ValidateOffer.jsx';
+import { v4 as uuidv4 } from 'uuid';
+import "./ComboBillTableEdit.scss"
+
+const ComboEditQtyAndRate = (props) => {
+ const dispatch = useDispatch();
+ const formRef = useRef(null);
+ const quantityInputRef = useRef(null);
+ const priceChangeInputRef = useRef(null);
+ const { setIndex = () => {}, setEditQtyCombo = () => {}, setEditRateCombo = () => {} } = props;
+
+ const [disableSubmitButton, setDisableSubmitButton] = useState(false);
+ const SessionData = useSelector(StoredSessionData);
+ // const AppId = SessionData?.AppId;
+ // const CompId = SessionData?.CompId;
+ // const BranchId = SessionData?.BranchId;
+ const UserType = SessionData?.UserType;
+ const applyOffer = useApplyOfferto_CardDetail();
+ const preferenceDatas = useSelector(PreferenceData);
+ const EmpAccessDetail = useSelector(GlobalEmpAccessDetail);
+ const OverAllproductBasedOfferDatas = useSelector(
+ (state) => state?.BookingOFferNew?.OverAllProductBasedProducts,
+ shallowEqual
+ );
+ const preferenceOffer =
+ preferenceDatas?.[0]?.['SettingDtlDetails']?.find(
+ (item) => item.SettingIdName === 'Offer'
+ )?.SettingValue === 'Y';
+ const preferenceshortcutkey = preferenceDatas?.[0]?.[
+ 'SettingDtlDetails'
+ ]?.some(
+ (item) =>
+ item.SettingIdName.toLowerCase() === 'shortcutkeys' &&
+ item.SettingValue === 'Y'
+ );
+ console.log(preferenceshortcutkey, 'preferenceshortcutkey');
+ const [PriceChangeaccess, setPriceChangeaccess] = useState(true);
+
+ const [ConfigDataList, setConfigDataList] = useState([]);
+ const [messageType, setMessageType] = useState(null);
+ const [messageData, setMessageData] = useState(null);
+ const [EditOpen, setEditOpen] = useState(props?.BSBillingEditQuantity || props?.BSBillingEditRate);
+ const [ItemData, setItemData] = useState(props?.Productdata);
+ const [Quantity, setQuantity] = useState('');
+ const ReorderProductData = useSelector(GlobalReorderProductDetails);
+ const templateData = useSelector(getTemplateData);
+ const OfferCheckedInSetup =
+ templateData?.BookingNavbar?.[1].some(
+ (item) => item?.OptionName == 'Offer'
+ ) ||
+ templateData?.BookingCombo1?.[1]?.some(
+ (item) => item?.OptionName == 'Offer'
+ );
+ const [ClearQuantity, setClearQuantity] = useState(false);
+ const CartOrderDetails = useSelector(GlobalOrderCardDetails);
+ const SettingDataSelector = useSelector(PreferenceData);
+ const OrderType = useSelector(GlobalOrderType);
+ const [BillOrderPre, setBillOrderPre] = useState(null);
+ const [RadioBtnSelection, setRadioBtnSelection] = useState();
+ const [editedPrice, setEditedPrice] = useState(0);
+ const allowDecimal = preferenceDatas?.[0]?.SettingDtlDetails?.find(
+ (setting) =>
+ setting?.SettingIdName?.toLowerCase() === 'decimal' &&
+ setting?.SettingValue === 'Y'
+ );
+ const [PackageDtl, setPackageDtl] = useState([]);
+ const OfferAppliedProducts = useSelector(
+ GlobalOfferAppliedProducts,
+ shallowEqual
+ );
+ const FreeProdList = useSelector(GlobalFreeProdList);
+ console.log(CartOrderDetails, 'CartOrderDetails');
+
+ const TakAwayId = ConfigDataList?.find(
+ (a) => a?.ConfigName === 'TakeAway'
+ )?.ConfigId;
+
+ const DineinId = ConfigDataList?.find(
+ (a) => a?.ConfigName === 'Dine In'
+ )?.ConfigId;
+
+ const hasOffer = preferenceOffer && OfferCheckedInSetup;
+
+ useEffect(() => {
+ if (ConfigDataList?.length === 0) {
+ getBookingTypeId();
+ }
+ }, []);
+
+ useEffect(
+ () => {
+ setEditOpen(props.BSBillingEditQuantity || props.BSBillingEditRate);
+ setItemData(props.Productdata);
+ setQuantity('');
+ setEditedPrice('');
+ },
+ [props.BSBillingEditQuantity],
+ [props.Productdata],
+ [props.BSBillingEditRate]
+ );
+
+ useEffect(() => {
+ if (props.BSBillingEditQuantity || props.BSBillingEditRate) {
+ if (RadioBtnSelection === 'Quantity') {
+ setTimeout(() => quantityInputRef.current?.focus(), 100);
+ } else if (RadioBtnSelection === 'Rate') {
+ setTimeout(() => priceChangeInputRef.current?.focus(), 100);
+ }
+ }
+ }, [RadioBtnSelection, props.BSBillingEditQuantity, props.BSBillingEditRate]);
+
+ useEffect(() => {
+ const handleKeyDown = (event) => {
+ if (preferenceshortcutkey && event.shiftKey && event.key === 'E') {
+ event.preventDefault();
+ if (PriceChangeaccess && props.Productdata?.Offer <= 0) {
+ onRadioBtnChange('Price');
+ }
+ }
+ };
+
+ if (EditOpen) {
+ document.addEventListener('keydown', handleKeyDown);
+ }
+
+ return () => {
+ document.removeEventListener('keydown', handleKeyDown);
+ };
+ }, [
+ EditOpen,
+ preferenceshortcutkey,
+ PriceChangeaccess,
+ props.Productdata?.Offer,
+ ]);
+
+ useEffect(() => {
+ const BillOrder = SettingDataSelector?.[0]?.SettingDtlDetails?.find(
+ (item) => item.SettingIdName === 'BillItemsOrder'
+ );
+ setBillOrderPre(BillOrder?.SettingValue);
+ }, []);
+
+ useEffect(() => {
+ if (UserType == 'Employee') {
+ const Pricechange = EmpAccessDetail?.filter(
+ (item) => item.ConfigName === 'Sales Discount'
+ );
+
+ setPriceChangeaccess(Pricechange?.[0]?.AddAccess != 'Y' ? false : true);
+ }
+ }, [EmpAccessDetail]);
+ useEffect(() => {
+ if (props?.BSBillingEditRate) {
+ setRadioBtnSelection('Rate');
+ setEditedPrice(props.Productdata?.OrderRate || 0);
+ } else if (props?.BSBillingEditQuantity) {
+ setRadioBtnSelection('Quantity');
+ }
+ }, [props?.BSBillingEditRate, props?.BSBillingEditQuantity, props.Productdata?.OrderRate]);
+ const getBookingTypeId = async () => {
+ let tempconfigdata = await dispatch(
+ getConfigType({ TypeName: 'Booking Type' })
+ ).unwrap();
+
+ if (tempconfigdata?.data?.statusCode == 1) {
+ setConfigDataList(tempconfigdata?.data?.data);
+ }
+ };
+
+
+ const calculateOverAllQty = (item, filterItems) => {
+ if (!item) return 0;
+
+ const totalUsedQty =
+ filterItems?.reduce((acc, card) => {
+ if (card?.StockAvailable !== 'Y') return acc;
+
+ const isSinglePcItem = item?.SinglePc === 'Y';
+ const isSinglePcCard = card?.SinglePc === 'Y';
+
+ let qty = 0;
+ if (isSinglePcItem) {
+ qty = isSinglePcCard ? card.OrderQty : card.OrderQty * card.NoOfPcs;
+ } else {
+ if (isSinglePcCard) {
+ const remainder = card?.OverAllPcs % card?.NoOfPcs;
+ qty =
+ remainder >= card?.OrderQty
+ ? 0
+ : Math.ceil(card?.OrderQty / card?.NoOfPcs);
+ } else {
+ qty = card.OrderQty;
+ }
+ }
+ return acc + qty;
+ }, 0) || 0;
+
+ const availableQty =
+ item?.SinglePc === 'Y' ? item?.OverAllPcs : item?.BalanceQty;
+ return availableQty - totalUsedQty;
+ };
+ const AddProductQuantity = async () => {
+ let newPrice = editedPrice > 0 ? editedPrice : props.Productdata.OrderRate;
+ await dispatch(changeHoldOrderDtl(false));
+ await dispatch(changePreviousOrderLength(CartOrderDetails?.length));
+
+ if (RadioBtnSelection === 'Rate') {
+ let localId = props.Index;
+ let editedProductIndex = CartOrderDetails?.findIndex(
+ (e) => e?.localId == localId
+ );
+ if (editedProductIndex === -1) {
+ setMessageType('error');
+ setMessageData('Product not found in cart');
+ return;
+ }
+
+ const editedProduct = CartOrderDetails[editedProductIndex];
+ const existingQty = editedProduct.OrderQty;
+
+ // Validate rate value
+ if (!newPrice || newPrice <= 0) {
+ setMessageType('error');
+ setMessageData('Please enter a valid rate');
+ return;
+ }
+
+ // Update ONLY the rate, use existing quantity
+ await handleNormalEditQuantity(
+ editedProduct,
+ editedProductIndex,
+ existingQty,
+ newPrice
+ );
+
+ // Reset and close
+ setClearQuantity(false);
+ setIndex(null);
+ setEditQtyCombo(false);
+ setEditRateCombo(false);
+ setMessageType('success');
+ setMessageData('Rate updated successfully');
+ return;
+ }
+
+ // When editing quantity, validate quantity input
+ if (
+ (parseInt(Quantity) === 0 || Quantity === '') &&
+ props?.Productdata?.ScaleType !== 'weight'
+ ) {
+ setMessageType('error');
+ setMessageData('Please enter valid quantity');
+ setQuantity('');
+ } else {
+ let localId = props.Index;
+ const editedQty =
+ props?.Productdata?.ScaleType !== 'weight'
+ ? parseInt(Quantity)
+ : props.Productdata.OrderQty;
+ let editedProductIndex = CartOrderDetails?.findIndex(
+ (e) => e?.localId == localId
+ );
+ const editedProduct = CartOrderDetails[editedProductIndex];
+ const productBookingType = editedProduct?.BookingTypeName;
+ const isItemInCart = CartOrderDetails?.find(
+ (cartItem) =>
+ cartItem?.ProdId === editedProduct?.ProdId &&
+ cartItem?.InwardDtlId === editedProduct?.InwardDtlId &&
+ cartItem?.OrderRate === editedProduct?.OrderRate &&
+ cartItem?.BookingTypeName === editedProduct?.BookingTypeName &&
+ !cartItem?.SalesId
+ );
+ // changing for one piece stock checking
+ const isItemInCartfilter = CartOrderDetails?.filter(
+ (cartItem) =>
+ cartItem?.ProdId === editedProduct?.ProdId &&
+ cartItem?.InwardDtlId === editedProduct?.InwardDtlId &&
+ cartItem?.OrderRate !== editedProduct?.OrderRate &&
+ !cartItem?.SalesId
+ );
+
+ const isItemInCartHold = CartOrderDetails?.find(
+ (cartItem) =>
+ cartItem?.ProdId === editedProduct?.ProdId &&
+ cartItem?.InwardDtlId === editedProduct.InwardDtlId &&
+ cartItem?.OrderRate === editedProduct?.OrderRate &&
+ cartItem?.BookingTypeName === editedProduct?.BookingTypeName
+ ); // check if the item is already in the cart
+ const isItemInCartHoldfilter = CartOrderDetails?.filter(
+ (cartItem) =>
+ cartItem?.ProdId === editedProduct?.ProdId &&
+ cartItem?.InwardDtlId === editedProduct?.InwardDtlId &&
+ !(
+ (cartItem?.OrderRate === editedProduct?.OrderRate)
+ // && cartItem?.BookingTypeName === editedProduct?.BookingTypeName
+ )
+ );
+
+ if (
+ (isItemInCart &&
+ productBookingType !== 'Dine In' &&
+ OrderType != 'Hold') ||
+ (isItemInCart &&
+ productBookingType === 'Dine In' &&
+ OrderType != 'Hold')
+ ) {
+ const overAllQuantity = calculateOverAllQty(
+ isItemInCart,
+ isItemInCartfilter
+ );
+ let totalUsedQty = 0;
+ const sameProductInOtherBookingType = CartOrderDetails?.filter(
+ (cartItem) =>
+ cartItem?.ProdId === editedProduct?.ProdId &&
+ cartItem?.InwardDtlId === editedProduct?.InwardDtlId &&
+ cartItem?.OrderRate === editedProduct?.OrderRate &&
+ cartItem?.BookingTypeName !== editedProduct?.BookingTypeName &&
+ !cartItem?.SalesId
+ );
+ if (editedProduct?.Offer > 0) {
+ // check same product available in paid product
+ const sameProductAsPaidInSameBookingType = CartOrderDetails?.filter(
+ (cartItem) =>
+ cartItem?.ProdId === editedProduct?.ProdId &&
+ cartItem?.InwardDtlId === editedProduct?.InwardDtlId &&
+ cartItem?.OrderRate === editedProduct?.OrderRate &&
+ cartItem?.BookingTypeName === editedProduct?.BookingTypeName &&
+ !cartItem?.SalesId &&
+ !cartItem?.OfferMode &&
+ cartItem?.Offer === 0
+ );
+
+ if (sameProductAsPaidInSameBookingType?.length > 0) {
+ const stockAvailable = sameProductAsPaidInSameBookingType?.some(
+ (item) => item?.StockAvailable === 'Y'
+ );
+ if (stockAvailable) {
+ totalUsedQty = sameProductAsPaidInSameBookingType?.reduce(
+ (acc, item) => {
+ if (item?.StockAvailable === 'Y') {
+ return acc + parseInt(item?.OrderQty);
+ }
+ return acc;
+ },
+ 0
+ );
+ }
+ }
+ } else if (!editedProduct?.Offer) {
+ const sameProductAsFree = CartOrderDetails?.filter(
+ (cartItem) =>
+ cartItem?.ProdId === editedProduct?.ProdId &&
+ cartItem?.InwardDtlId === editedProduct?.InwardDtlId &&
+ cartItem?.OrderRate === editedProduct?.OrderRate &&
+ cartItem?.BookingTypeName === editedProduct?.BookingTypeName &&
+ !cartItem?.SalesId &&
+ cartItem?.Offer > 0 &&
+ cartItem?.OfferMode
+ );
+
+ if (sameProductAsFree?.length > 0) {
+ const stockAvailable = sameProductAsFree?.some(
+ (item) => item?.StockAvailable === 'Y'
+ );
+ if (stockAvailable) {
+ totalUsedQty = sameProductAsFree?.reduce((acc, item) => {
+ if (item?.StockAvailable === 'Y') {
+ return acc + parseInt(item?.OrderQty);
+ }
+ return acc;
+ }, 0);
+ }
+ }
+ }
+
+ if (sameProductInOtherBookingType?.length > 0) {
+ const stockAvailable = sameProductInOtherBookingType?.some(
+ (item) => item?.StockAvailable === 'Y'
+ );
+ if (stockAvailable) {
+ totalUsedQty += sameProductInOtherBookingType?.reduce(
+ (acc, item) => {
+ if (item?.StockAvailable === 'Y') {
+ return acc + parseInt(item?.OrderQty);
+ }
+ return acc;
+ },
+ 0
+ );
+ }
+ }
+
+ if (
+ overAllQuantity < editedQty + (totalUsedQty || 0) &&
+ isItemInCart?.StockAvailable === 'Y'
+ ) {
+ setMessageType('error');
+ setMessageData('Stock Not Available');
+ return;
+ }
+ } else if (isItemInCartHold && OrderType === 'Hold') {
+ const holddataproduct = ReorderProductData?.filter(
+ (cartItem) =>
+ cartItem?.ProdId === editedProduct?.ProdId &&
+ cartItem?.InwardDtlId === editedProduct?.InwardDtlId
+ );
+
+ let totalSelectedProductQty = holddataproduct?.reduce(
+ (accumulator, card) => {
+ return (
+ accumulator +
+ parseInt(
+ card?.StockAvailable === 'Y'
+ ? editedProduct?.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 totalUsedQty = 0;
+
+ const sameProductInOtherBookingType = CartOrderDetails?.filter(
+ (cartItem) =>
+ cartItem?.ProdId === editedProduct?.ProdId &&
+ cartItem?.InwardDtlId === editedProduct?.InwardDtlId &&
+ cartItem?.OrderRate === editedProduct?.OrderRate &&
+ cartItem?.BookingTypeName !== editedProduct?.BookingTypeName
+ );
+
+ if (editedProduct?.Offer > 0) {
+ // check same product available in paid product
+ const sameProductAsPaid = CartOrderDetails?.find(
+ (cartItem) =>
+ cartItem?.ProdId === editedProduct?.ProdId &&
+ cartItem?.InwardDtlId === editedProduct?.InwardDtlId &&
+ cartItem?.OrderRate === editedProduct?.OrderRate &&
+ cartItem?.BookingTypeName === editedProduct?.BookingTypeName &&
+ !cartItem?.OfferMode &&
+ cartItem?.Offer === 0
+ );
+
+ if (sameProductAsPaid?.StockAvailable === 'Y') {
+ totalUsedQty = sameProductAsPaid?.OrderQty;
+ }
+ } else if (!editedProduct?.Offer) {
+ const sameProductAsFree = CartOrderDetails?.find(
+ (cartItem) =>
+ cartItem?.ProdId === editedProduct?.ProdId &&
+ cartItem?.InwardDtlId === editedProduct?.InwardDtlId &&
+ cartItem?.OrderRate === editedProduct?.OrderRate &&
+ cartItem?.BookingTypeName === editedProduct?.BookingTypeName &&
+ cartItem?.Offer > 0 &&
+ cartItem?.OfferMode
+ );
+ if (sameProductAsFree?.StockAvailable === 'Y') {
+ totalUsedQty = sameProductAsFree?.OrderQty;
+ }
+ }
+
+ if (sameProductInOtherBookingType?.length > 0) {
+ const stockAvailable = sameProductInOtherBookingType?.some(
+ (item) => item?.StockAvailable === 'Y'
+ );
+ if (stockAvailable) {
+ totalUsedQty += sameProductInOtherBookingType?.reduce(
+ (acc, item) => {
+ if (item?.StockAvailable === 'Y') {
+ return acc + parseInt(item?.OrderQty);
+ }
+ return acc;
+ },
+ 0
+ );
+ }
+ }
+
+ let overAllQuantityHold =
+ calculateOverAllQty(isItemInCartHold, isItemInCartHoldfilter) +
+ totalSelectedProductQty;
+ if (
+ isItemInCartHold?.StockAvailable === 'Y' &&
+ overAllQuantityHold < editedQty + (totalUsedQty || 0)
+ ) {
+ setMessageType('error');
+ setMessageData('Stock Not Available');
+ return;
+ }
+ }
+ await handleEditQuantity(editedProduct, editedProductIndex, newPrice);
+ props.handleEditQuantityCancel();
+ setClearQuantity(false);
+ }
+ setIndex(null);
+ setEditQtyCombo(false);
+ setEditRateCombo(false);
+ };
+
+ const handleEditQuantity = async (
+ editedProduct,
+ editedProductIndex,
+ newPrice
+ ) => {
+ const editedQty =
+ props?.Productdata?.ScaleType !== 'weight'
+ ? parseInt(Quantity)
+ : props.Productdata.OrderQty;
+ const addFirst = BillOrderPre === 'Y';
+ const isExistsInFreeProdList = FreeProdList?.find(
+ (product) =>
+ product?.ProdVariantDetails?.some((variant) =>
+ variant?.StockDetails?.some(
+ (stock) => stock?.FreeInwardDtlId === editedProduct?.InwardDtlId
+ )
+ ) &&
+ editedProduct?.OfferMessage?.[0]?.OfferId === product?.OfferId &&
+ editedProduct?.OfferMode === product?.OfferMode
+ );
+ console.log(FreeProdList, 'FreeProdList');
+
+ if (
+ isExistsInFreeProdList &&
+ editedProduct?.Offer > 0 &&
+ hasOffer &&
+ editedProduct?.SinglePc !== 'Y'
+ ) {
+ const freeProductInOtherBooking = CartOrderDetails?.find((cartItem) => {
+ return (
+ cartItem?.InwardDtlId === editedProduct?.InwardDtlId &&
+ cartItem?.OfferMessage?.[0]?.OfferId ===
+ editedProduct?.OfferMessage?.[0]?.OfferId &&
+ cartItem?.OfferMode === editedProduct?.OfferMode &&
+ cartItem?.BookingTypeName !== editedProduct?.BookingTypeName
+ );
+ });
+
+ const finalOrderQty =
+ (freeProductInOtherBooking?.OrderQty || 0) + editedQty;
+
+ if (isExistsInFreeProdList?.RemainingQty === 0) {
+ // need to split the free product and paid product
+
+ if (finalOrderQty > isExistsInFreeProdList?.OverAllFreeQty) {
+ const paidQty =
+ finalOrderQty - isExistsInFreeProdList?.OverAllFreeQty;
+ const isAlreadyExistsInCart = CartOrderDetails?.findIndex(
+ (cartItem) => {
+ return (
+ cartItem?.ProdId === editedProduct?.ProdId &&
+ cartItem?.InwardDtlId === editedProduct?.InwardDtlId &&
+ !cartItem?.OfferMode &&
+ cartItem?.Offer === 0 &&
+ cartItem?.BookingTypeName === editedProduct?.BookingTypeName &&
+ cartItem?.OrderRate === editedProduct?.OrderRate
+ );
+ }
+ );
+
+ let updatedCart = [...CartOrderDetails];
+
+ if (isAlreadyExistsInCart !== -1) {
+ // update the existing paid product in cart
+ const existingItem = updatedCart[isAlreadyExistsInCart];
+ const updatedItem = {
+ ...existingItem,
+ OrderQty: existingItem?.OrderQty + paidQty,
+ ...calculateTaxAmounts({
+ qty: existingItem?.OrderQty + paidQty,
+ rate: existingItem?.OrderRate,
+ taxPercentage: existingItem?.TaxPercentage,
+ }),
+ };
+ updatedCart?.splice(isAlreadyExistsInCart, 1);
+ updatedCart = addFirst
+ ? [updatedItem, ...updatedCart]
+ : [...updatedCart, updatedItem];
+ } else {
+ // add new paid product in cart
+ const paidProduct = {
+ localId: uuidv4(),
+ ...editedProduct,
+ OrderQty: paidQty,
+ Offer: 0,
+ OfferMode: null,
+ OfferMessage: null,
+ OfferType: null,
+ ...calculateTaxAmounts({
+ qty: paidQty,
+ rate: editedProduct.OrderRate,
+ taxPercentage: editedProduct.TaxPercentage,
+ }),
+ };
+ updatedCart = addFirst
+ ? [paidProduct, ...updatedCart]
+ : [...updatedCart, paidProduct];
+ }
+ dispatch(changeOrderCardDetails(updatedCart));
+ } else {
+ // Check if there is any same product but No offer applied in OrderCardDtls in same BookingType
+ // In Same BookingType Have Enough Free Qty Just only Update Qty in Same Booking Type OtherWise need to update in Other Booking Type Qty also if exists in Other Booking Type
+ const isAlreadyExistsInCart = CartOrderDetails?.find((cartItem) => {
+ return (
+ cartItem?.ProdId === editedProduct?.ProdId &&
+ cartItem?.InwardDtlId === editedProduct?.InwardDtlId &&
+ cartItem?.OrderRate === editedProduct?.OrderRate &&
+ cartItem?.BookingTypeName === editedProduct?.BookingTypeName &&
+ !cartItem?.OfferMode &&
+ cartItem?.Offer === 0
+ );
+ });
+
+ const freeQtyNeeded =
+ isExistsInFreeProdList?.OverAllFreeQty - finalOrderQty;
+ const paidQtySame = isAlreadyExistsInCart?.OrderQty || 0;
+
+ if (paidQtySame >= freeQtyNeeded) {
+ const remainingPaidQty = (paidQtySame || 0) - freeQtyNeeded;
+ if (remainingPaidQty === 0) {
+ // Just need to update the Free Qty and Remove the Paid Product from Cart
+ const updatedCart = CartOrderDetails?.filter(
+ (cartItem) => cartItem !== isAlreadyExistsInCart
+ );
+ dispatch(
+ changeOrderCardDetails(
+ updatedCart?.map((cartItem) => {
+ if (cartItem === editedProduct) {
+ return {
+ ...cartItem,
+ PackageDtl: PackageDtl,
+ };
+ }
+ return cartItem;
+ })
+ )
+ );
+ } else {
+ // need to update the Paid Qty to Remaining Qty
+ const updatedCart = CartOrderDetails?.map((cartItem) => {
+ if (cartItem === isAlreadyExistsInCart) {
+ return {
+ ...cartItem,
+ OrderQty: remainingPaidQty,
+ ...calculateTaxAmounts({
+ qty: remainingPaidQty,
+ rate: cartItem.OrderRate,
+ taxPercentage: cartItem.TaxPercentage,
+ }),
+ };
+ }
+ return cartItem;
+ });
+ dispatch(changeOrderCardDetails(updatedCart));
+ }
+ } else {
+ // check if the same product exists in other booking type as paid product
+ // need to calculate how much qty going to be updated in other booking type and same booking type
+
+ const diffBookingTypeProduct = CartOrderDetails?.find(
+ (cartItem) => {
+ return (
+ cartItem?.ProdId === editedProduct?.ProdId &&
+ cartItem?.InwardDtlId === editedProduct?.InwardDtlId &&
+ cartItem?.OrderRate === editedProduct?.OrderRate &&
+ cartItem?.BookingTypeName !==
+ editedProduct?.BookingTypeName &&
+ !cartItem?.OfferMode &&
+ cartItem?.Offer === 0
+ );
+ }
+ );
+
+ const diffBookingTypeFreeProduct = CartOrderDetails?.find(
+ (cartItem) => {
+ return (
+ cartItem?.ProdId === editedProduct?.ProdId &&
+ cartItem?.InwardDtlId === editedProduct?.InwardDtlId &&
+ cartItem?.OrderRate === editedProduct?.OrderRate &&
+ cartItem?.BookingTypeName !==
+ editedProduct?.BookingTypeName &&
+ cartItem?.OfferMode === editedProduct?.OfferMode &&
+ cartItem?.Offer > 0
+ );
+ }
+ );
+
+ const paidQtyOther = diffBookingTypeProduct?.OrderQty || 0;
+ const sameBookTypeUpdateQty = freeQtyNeeded - paidQtySame;
+ const otherBookTypePaidUpdateQty =
+ paidQtyOther - sameBookTypeUpdateQty;
+ const totalPaidQty = paidQtySame + paidQtyOther;
+
+ if (paidQtySame || paidQtyOther) {
+ let updatedCart = [...CartOrderDetails];
+
+ // Remove paid product in same booking type if needed
+ if (paidQtySame) {
+ updatedCart = updatedCart.filter(
+ (cartItem) => cartItem !== isAlreadyExistsInCart
+ );
+ updatedCart = updatedCart.map((cartItem) => {
+ if (cartItem === editedProduct) {
+ return {
+ ...cartItem,
+ OrderQty: editedQty + paidQtySame,
+ ...calculateTaxAmounts({
+ qty: editedQty + paidQtySame,
+ rate: cartItem.OrderRate,
+ taxPercentage: cartItem.TaxPercentage,
+ }),
+ ...(cartItem?.Offer > 0 && {
+ Offer: (editedQty + paidQtySame) * cartItem.OrderRate,
+ }),
+ };
+ }
+ return cartItem;
+ });
+ }
+
+ // Remove/update paid product in other booking type if needed
+ if (paidQtyOther) {
+ if (otherBookTypePaidUpdateQty <= 0) {
+ // Remove paid product from other booking type
+ updatedCart = updatedCart.filter(
+ (cartItem) => cartItem !== diffBookingTypeProduct
+ );
+ updatedCart = updatedCart.map((cartItem) => {
+ if (cartItem === diffBookingTypeFreeProduct) {
+ return {
+ ...cartItem,
+ OrderQty: paidQtyOther + cartItem?.OrderQty,
+ ...calculateTaxAmounts({
+ qty: paidQtyOther + cartItem?.OrderQty,
+ rate: cartItem?.OrderRate,
+ taxPercentage: cartItem?.TaxPercentage,
+ }),
+ Offer:
+ (paidQtyOther + cartItem?.OrderQty) *
+ cartItem?.OrderRate,
+ };
+ } else if (cartItem === editedProduct) {
+ return {
+ ...cartItem,
+ OrderQty: editedQty,
+ ...calculateTaxAmounts({
+ qty: editedQty,
+ rate: cartItem?.OrderRate,
+ taxPercentage: cartItem?.TaxPercentage,
+ }),
+ Offer: editedQty * cartItem?.OrderRate,
+ };
+ }
+ return cartItem;
+ });
+ } else if (otherBookTypePaidUpdateQty > 0) {
+ updatedCart = updatedCart.map((cartItem) => {
+ if (cartItem === diffBookingTypeFreeProduct) {
+ return {
+ ...cartItem,
+ OrderQty: cartItem?.OrderQty + sameBookTypeUpdateQty,
+ ...calculateTaxAmounts({
+ qty: cartItem?.OrderQty + sameBookTypeUpdateQty,
+ rate: cartItem?.OrderRate,
+ taxPercentage: cartItem?.TaxPercentage,
+ }),
+ Offer:
+ (cartItem?.OrderQty + sameBookTypeUpdateQty) *
+ cartItem?.OrderRate,
+ };
+ } else if (cartItem === editedProduct) {
+ return {
+ ...cartItem,
+ OrderQty: editedQty,
+ ...calculateTaxAmounts({
+ qty: editedQty,
+ rate: cartItem?.OrderRate,
+ taxPercentage: cartItem?.TaxPercentage,
+ }),
+ Offer: editedQty * cartItem?.OrderRate,
+ };
+ } else if (cartItem === diffBookingTypeProduct) {
+ return {
+ ...cartItem,
+ OrderQty: otherBookTypePaidUpdateQty,
+ ...calculateTaxAmounts({
+ qty: otherBookTypePaidUpdateQty,
+ rate: cartItem?.OrderRate,
+ taxPercentage: cartItem?.TaxPercentage,
+ }),
+ };
+ }
+ return cartItem;
+ });
+ }
+ }
+
+ // Only one dispatch after all updates
+ dispatch(changeOrderCardDetails(updatedCart));
+
+ if (totalPaidQty < freeQtyNeeded) {
+ const additionalFreeQtyNeeded = freeQtyNeeded - totalPaidQty;
+
+ const updatedFreeProdList = FreeProdList?.map((product) => {
+ if (
+ product?.FreeProdId === editedProduct?.ProdId &&
+ product?.ProdVariantDetails?.some((variant) =>
+ variant?.StockDetails?.some(
+ (stock) =>
+ stock?.FreeInwardDtlId === editedProduct?.InwardDtlId
+ )
+ ) &&
+ product?.OfferId ===
+ editedProduct?.OfferMessage?.[0]?.OfferId &&
+ product?.OfferMode === editedProduct?.OfferMode
+ ) {
+ const freeQty =
+ product?.OverAllFreeQty - additionalFreeQtyNeeded;
+ return {
+ ...product,
+ FreeQty: freeQty,
+ RemainingQty: additionalFreeQtyNeeded,
+ discount: freeQty * editedProduct?.OrderRate,
+ };
+ }
+ return product;
+ });
+
+ dispatch(ChangeFullFreeProductList(updatedFreeProdList));
+ const updatedOfferAppliedProducts = OfferAppliedProducts?.map(
+ (offerProduct) => {
+ // Check if this offer product contains the edited product in its free products list
+ const hasMatchingFreeProduct =
+ offerProduct?.FreeProductsList?.some((freeProduct) =>
+ freeProduct?.ProdVariantDetails?.some((variant) =>
+ variant?.StockDetails?.some(
+ (stock) =>
+ stock?.FreeInwardDtlId ===
+ editedProduct?.InwardDtlId
+ )
+ )
+ );
+
+ // Also check main offer conditions
+ const isMatchingOffer =
+ offerProduct?.OfferId ===
+ editedProduct?.OfferMessage?.[0]?.OfferId &&
+ offerProduct?.OfferMode === editedProduct?.OfferMode;
+
+ if (hasMatchingFreeProduct && isMatchingOffer) {
+ // Get loyalty points from the matching free product
+ const matchingFreeProduct =
+ offerProduct?.FreeProductsList?.find((freeProduct) =>
+ freeProduct?.ProdVariantDetails?.some((variant) =>
+ variant?.StockDetails?.some(
+ (stock) =>
+ stock?.FreeInwardDtlId ===
+ editedProduct?.InwardDtlId
+ )
+ )
+ );
+
+ const prodLoyaltyPoint =
+ matchingFreeProduct?.ProdVariantDetails?.[0]
+ ?.StockDetails?.[0]?.ProdLoyaltyPoint || 0;
+
+ const freeQty =
+ matchingFreeProduct?.FreeQty - additionalFreeQtyNeeded;
+ // Update the specific free product in the list
+ const updatedFreeProductsList =
+ offerProduct?.FreeProductsList?.map((freeProduct) => {
+ const isTargetFreeProduct =
+ freeProduct?.ProdVariantDetails?.some((variant) =>
+ variant?.StockDetails?.some(
+ (stock) =>
+ stock?.FreeInwardDtlId ===
+ editedProduct?.InwardDtlId
+ )
+ );
+
+ if (isTargetFreeProduct) {
+ return {
+ ...freeProduct,
+ FreeQty: freeQty,
+ };
+ }
+ return freeProduct;
+ });
+
+ return {
+ ...offerProduct,
+ ActualFreeQty: freeQty,
+ ActualOfferAmount: freeQty * editedProduct?.OrderRate,
+ OfferAmount: freeQty * editedProduct?.OrderRate,
+ OfferValue: freeQty * editedProduct?.OrderRate,
+ FreeProductsList: updatedFreeProductsList,
+ UsedCount: freeQty * prodLoyaltyPoint,
+ };
+ }
+
+ return offerProduct;
+ }
+ );
+ dispatch(
+ changeFullOfferAppliedProducts(updatedOfferAppliedProducts)
+ );
+ }
+ } else {
+ await handleNormalEditQuantity(
+ editedProduct,
+ editedProductIndex,
+ editedQty,
+ newPrice,
+ true
+ );
+ const updatedFreeProdList = FreeProdList?.map((product) => {
+ if (
+ product?.FreeProdId === editedProduct?.ProdId &&
+ product?.ProdVariantDetails?.some((variant) =>
+ variant?.StockDetails?.some(
+ (stock) =>
+ stock?.FreeInwardDtlId === editedProduct?.InwardDtlId
+ )
+ ) &&
+ product?.OfferId ===
+ editedProduct?.OfferMessage?.[0]?.OfferId &&
+ product?.OfferMode === editedProduct?.OfferMode
+ ) {
+ return {
+ ...product,
+ FreeQty: finalOrderQty,
+ RemainingQty: product?.OverAllFreeQty - finalOrderQty,
+ discount: finalOrderQty * editedProduct?.OrderRate,
+ };
+ }
+ return product;
+ });
+ dispatch(ChangeFullFreeProductList(updatedFreeProdList));
+ const updatedOfferAppliedProducts = OfferAppliedProducts?.map(
+ (offerProduct) => {
+ // Check if this offer product contains the edited product in its free products list
+ const hasMatchingFreeProduct =
+ offerProduct?.FreeProductsList?.some((freeProduct) =>
+ freeProduct?.ProdVariantDetails?.some((variant) =>
+ variant?.StockDetails?.some(
+ (stock) =>
+ stock?.FreeInwardDtlId ===
+ editedProduct?.InwardDtlId
+ )
+ )
+ );
+
+ // Also check main offer conditions
+ const isMatchingOffer =
+ offerProduct?.OfferId ===
+ editedProduct?.OfferMessage?.[0]?.OfferId &&
+ offerProduct?.OfferMode === editedProduct?.OfferMode;
+
+ if (hasMatchingFreeProduct && isMatchingOffer) {
+ // Get loyalty points from the matching free product
+ const matchingFreeProduct =
+ offerProduct?.FreeProductsList?.find((freeProduct) =>
+ freeProduct?.ProdVariantDetails?.some((variant) =>
+ variant?.StockDetails?.some(
+ (stock) =>
+ stock?.FreeInwardDtlId ===
+ editedProduct?.InwardDtlId
+ )
+ )
+ );
+
+ const prodLoyaltyPoint =
+ matchingFreeProduct?.ProdVariantDetails?.[0]
+ ?.StockDetails?.[0]?.ProdLoyaltyPoint || 0;
+
+ // Update the specific free product in the list
+ const updatedFreeProductsList =
+ offerProduct?.FreeProductsList?.map((freeProduct) => {
+ const isTargetFreeProduct =
+ freeProduct?.ProdVariantDetails?.some((variant) =>
+ variant?.StockDetails?.some(
+ (stock) =>
+ stock?.FreeInwardDtlId ===
+ editedProduct?.InwardDtlId
+ )
+ );
+
+ if (isTargetFreeProduct) {
+ return {
+ ...freeProduct,
+ FreeQty: finalOrderQty,
+ };
+ }
+ return freeProduct;
+ });
+
+ return {
+ ...offerProduct,
+ ActualFreeQty: finalOrderQty,
+ ActualOfferAmount:
+ finalOrderQty * editedProduct?.OrderRate,
+ OfferAmount: finalOrderQty * editedProduct?.OrderRate,
+ OfferValue: finalOrderQty * editedProduct?.OrderRate,
+ FreeProductsList: updatedFreeProductsList,
+ UsedCount: finalOrderQty * prodLoyaltyPoint,
+ };
+ }
+
+ return offerProduct;
+ }
+ );
+ dispatch(
+ changeFullOfferAppliedProducts(updatedOfferAppliedProducts)
+ );
+ }
+ }
+ }
+ } else if (isExistsInFreeProdList?.RemainingQty > 0) {
+ // perform normal edit qty operation
+ // console.log(editedProduct?.OrderQty, "editedProduct")
+ // await handleNormalEditQuantity(editedProduct, editedProductIndex);
+
+ if (finalOrderQty > isExistsInFreeProdList?.OverAllFreeQty) {
+ // split paid and free product
+ const paidProdQty =
+ finalOrderQty - isExistsInFreeProdList?.OverAllFreeQty;
+ const freeProdQty = editedQty - paidProdQty;
+ const isAlreadyExistsInCart = CartOrderDetails?.findIndex(
+ (cartItem) => {
+ return (
+ cartItem?.ProdId === editedProduct?.ProdId &&
+ cartItem?.InwardDtlId === editedProduct?.InwardDtlId &&
+ !cartItem?.OfferMode &&
+ cartItem?.Offer === 0 &&
+ cartItem?.BookingTypeName === editedProduct?.BookingTypeName &&
+ cartItem?.OrderRate === editedProduct?.OrderRate
+ );
+ }
+ );
+
+ let updatedCart = [...CartOrderDetails];
+
+ if (isAlreadyExistsInCart !== -1) {
+ // update the existing paid product in cart
+ updatedCart[isAlreadyExistsInCart] = {
+ ...updatedCart[isAlreadyExistsInCart],
+ OrderQty:
+ updatedCart[isAlreadyExistsInCart]?.OrderQty + paidProdQty,
+ ...calculateTaxAmounts({
+ qty: updatedCart[isAlreadyExistsInCart]?.OrderQty + paidProdQty,
+ rate: updatedCart[isAlreadyExistsInCart]?.OrderRate,
+ taxPercentage:
+ updatedCart[isAlreadyExistsInCart]?.TaxPercentage,
+ }),
+ };
+ } else {
+ // add new paid product in cart
+ const paidProduct = {
+ localId: uuidv4(),
+ ...editedProduct,
+ OrderQty: paidProdQty,
+ Offer: 0,
+ OfferMode: null,
+ OfferMessage: null,
+ OfferType: null,
+ ...calculateTaxAmounts({
+ qty: paidProdQty,
+ rate: editedProduct?.OrderRate,
+ taxPercentage: editedProduct?.TaxPercentage,
+ }),
+ };
+ updatedCart = [...updatedCart, paidProduct];
+ }
+
+ dispatch(
+ changeOrderCardDetails(
+ updatedCart?.map((prod) => {
+ if (prod === editedProduct) {
+ return {
+ ...prod,
+ OrderQty: freeProdQty,
+ ...calculateTaxAmounts({
+ qty: freeProdQty,
+ rate: prod.OrderRate,
+ taxPercentage: prod.TaxPercentage,
+ }),
+ ...(prod?.Offer > 0 && {
+ Offer: freeProdQty * prod.OrderRate,
+ }),
+ };
+ }
+ return prod;
+ })
+ )
+ );
+ } else if (finalOrderQty === isExistsInFreeProdList?.OverAllFreeQty) {
+ // Just need to update the Qty in Edited Product and FreeProductList and OfferAppliedProducts
+ await handleNormalEditQuantity(
+ editedProduct,
+ editedProductIndex,
+ editedQty,
+ newPrice,
+ true
+ );
+ const updatedFreeProdList = FreeProdList?.map((product) => {
+ if (
+ product?.FreeProdId === editedProduct?.ProdId &&
+ product?.ProdVariantDetails?.some((variant) =>
+ variant?.StockDetails?.some(
+ (stock) =>
+ stock?.FreeInwardDtlId === editedProduct?.InwardDtlId
+ )
+ ) &&
+ product?.OfferId === editedProduct?.OfferMessage?.[0]?.OfferId &&
+ product?.OfferMode === editedProduct?.OfferMode
+ ) {
+ return {
+ ...product,
+ FreeQty: finalOrderQty,
+ RemainingQty: 0,
+ discount: finalOrderQty * editedProduct?.OrderRate,
+ };
+ }
+ return product;
+ });
+ dispatch(ChangeFullFreeProductList(updatedFreeProdList));
+ const updatedOfferAppliedProducts = OfferAppliedProducts?.map(
+ (offerProduct) => {
+ // Check if this offer product contains the edited product in its free products list
+ const hasMatchingFreeProduct =
+ offerProduct?.FreeProductsList?.some((freeProduct) =>
+ freeProduct?.ProdVariantDetails?.some((variant) =>
+ variant?.StockDetails?.some(
+ (stock) =>
+ stock?.FreeInwardDtlId === editedProduct?.InwardDtlId
+ )
+ )
+ );
+
+ // Also check main offer conditions
+ const isMatchingOffer =
+ offerProduct?.OfferId ===
+ editedProduct?.OfferMessage?.[0]?.OfferId &&
+ offerProduct?.OfferMode === editedProduct?.OfferMode;
+
+ if (hasMatchingFreeProduct && isMatchingOffer) {
+ // Get loyalty points from the matching free product
+ const matchingFreeProduct =
+ offerProduct?.FreeProductsList?.find((freeProduct) =>
+ freeProduct?.ProdVariantDetails?.some((variant) =>
+ variant?.StockDetails?.some(
+ (stock) =>
+ stock?.FreeInwardDtlId === editedProduct?.InwardDtlId
+ )
+ )
+ );
+
+ const prodLoyaltyPoint =
+ matchingFreeProduct?.ProdVariantDetails?.[0]
+ ?.StockDetails?.[0]?.ProdLoyaltyPoint || 0;
+
+ // Update the specific free product in the list
+ const updatedFreeProductsList =
+ offerProduct?.FreeProductsList?.map((freeProduct) => {
+ const isTargetFreeProduct =
+ freeProduct?.ProdVariantDetails?.some((variant) =>
+ variant?.StockDetails?.some(
+ (stock) =>
+ stock?.FreeInwardDtlId ===
+ editedProduct?.InwardDtlId
+ )
+ );
+
+ if (isTargetFreeProduct) {
+ return {
+ ...freeProduct,
+ FreeQty: finalOrderQty,
+ };
+ }
+ return freeProduct;
+ });
+
+ return {
+ ...offerProduct,
+ ActualFreeQty: finalOrderQty,
+ ActualOfferAmount: finalOrderQty * editedProduct?.OrderRate,
+ OfferAmount: finalOrderQty * editedProduct?.OrderRate,
+ OfferValue: finalOrderQty * editedProduct?.OrderRate,
+ FreeProductsList: updatedFreeProductsList,
+ UsedCount: finalOrderQty * prodLoyaltyPoint,
+ };
+ }
+
+ return offerProduct;
+ }
+ );
+ dispatch(changeFullOfferAppliedProducts(updatedOfferAppliedProducts));
+ } else if (finalOrderQty < isExistsInFreeProdList?.OverAllFreeQty) {
+ // Just need to update the Qty in Edited Product and FreeProductList and OfferAppliedProducts
+ await handleNormalEditQuantity(
+ editedProduct,
+ editedProductIndex,
+ editedQty,
+ newPrice,
+ true
+ );
+ const updatedFreeProdList = FreeProdList?.map((product) => {
+ if (
+ product?.FreeProdId === editedProduct?.ProdId &&
+ product?.ProdVariantDetails?.some((variant) =>
+ variant?.StockDetails?.some(
+ (stock) =>
+ stock?.FreeInwardDtlId === editedProduct?.InwardDtlId
+ )
+ ) &&
+ product?.OfferId === editedProduct?.OfferMessage?.[0]?.OfferId &&
+ product?.OfferMode === editedProduct?.OfferMode
+ ) {
+ return {
+ ...product,
+ FreeQty: finalOrderQty,
+ RemainingQty: product?.OverAllFreeQty - finalOrderQty,
+ discount: finalOrderQty * editedProduct?.OrderRate,
+ };
+ }
+ return product;
+ });
+ dispatch(ChangeFullFreeProductList(updatedFreeProdList));
+ const updatedOfferAppliedProducts = OfferAppliedProducts?.map(
+ (offerProduct) => {
+ // Check if this offer product contains the edited product in its free products list
+ const hasMatchingFreeProduct =
+ offerProduct?.FreeProductsList?.some((freeProduct) =>
+ freeProduct?.ProdVariantDetails?.some((variant) =>
+ variant?.StockDetails?.some(
+ (stock) =>
+ stock?.FreeInwardDtlId === editedProduct?.InwardDtlId
+ )
+ )
+ );
+
+ // Also check main offer conditions
+ const isMatchingOffer =
+ offerProduct?.OfferId ===
+ editedProduct?.OfferMessage?.[0]?.OfferId &&
+ offerProduct?.OfferMode === editedProduct?.OfferMode;
+
+ if (hasMatchingFreeProduct && isMatchingOffer) {
+ // Get loyalty points from the matching free product
+ const matchingFreeProduct =
+ offerProduct?.FreeProductsList?.find((freeProduct) =>
+ freeProduct?.ProdVariantDetails?.some((variant) =>
+ variant?.StockDetails?.some(
+ (stock) =>
+ stock?.FreeInwardDtlId === editedProduct?.InwardDtlId
+ )
+ )
+ );
+
+ const prodLoyaltyPoint =
+ matchingFreeProduct?.ProdVariantDetails?.[0]
+ ?.StockDetails?.[0]?.ProdLoyaltyPoint || 0;
+
+ // Update the specific free product in the list
+ const updatedFreeProductsList =
+ offerProduct?.FreeProductsList?.map((freeProduct) => {
+ const isTargetFreeProduct =
+ freeProduct?.ProdVariantDetails?.some((variant) =>
+ variant?.StockDetails?.some(
+ (stock) =>
+ stock?.FreeInwardDtlId ===
+ editedProduct?.InwardDtlId
+ )
+ );
+
+ if (isTargetFreeProduct) {
+ return {
+ ...freeProduct,
+ FreeQty: finalOrderQty,
+ };
+ }
+ return freeProduct;
+ });
+
+ return {
+ ...offerProduct,
+ ActualFreeQty: finalOrderQty,
+ ActualOfferAmount: finalOrderQty * editedProduct?.OrderRate,
+ OfferAmount: finalOrderQty * editedProduct?.OrderRate,
+ OfferValue: finalOrderQty * editedProduct?.OrderRate,
+ FreeProductsList: updatedFreeProductsList,
+ UsedCount: finalOrderQty * prodLoyaltyPoint,
+ };
+ }
+
+ return offerProduct;
+ }
+ );
+ dispatch(changeFullOfferAppliedProducts(updatedOfferAppliedProducts));
+ }
+ }
+ } else {
+ // check is there any free product applicable for the edited product
+ const isFreeProductApplicable = FreeProdList?.find((product) => {
+ return (
+ product?.ProdId === editedProduct?.ProdId &&
+ product?.InwardDtlId === editedProduct?.InwardDtlId
+ );
+ });
+
+ const sameProductInOtherBooking = CartOrderDetails?.find((cartItem) => {
+ return (
+ cartItem?.ProdId === editedProduct?.ProdId &&
+ cartItem?.InwardDtlId === editedProduct?.InwardDtlId &&
+ cartItem?.BookingTypeName !== editedProduct?.BookingTypeName
+ );
+ });
+
+ const finalOrderQty =
+ (sameProductInOtherBooking?.OrderQty || 0) + editedQty;
+
+ if (isFreeProductApplicable && hasOffer) {
+ const applicableFreeProducts =
+ isFreeProductApplicable?.ProdVariantDetails;
+
+ const freeProductVariants = applicableFreeProducts?.map((variant) => {
+ return {
+ ...variant,
+ FreeProdId: isFreeProductApplicable?.FreeProdId,
+ OfferId: isFreeProductApplicable?.OfferId,
+ OfferMode: isFreeProductApplicable?.OfferMode,
+ };
+ });
+
+ if (isFreeProductApplicable?.OverAllFreeQty > finalOrderQty) {
+ if (isFreeProductApplicable?.FreeQty === 0) {
+ await handleNormalEditQuantity(
+ editedProduct,
+ editedProductIndex,
+ editedQty,
+ newPrice
+ );
+ // update free product list (Set OverAllFreeQty = OrderQty and Remaining = OrderQty)
+ const updatedFreeProdList = FreeProdList?.map((product) => {
+ if (
+ product?.ProdId === editedProduct?.ProdId &&
+ product?.InwardDtlId === editedProduct?.InwardDtlId
+ ) {
+ return {
+ ...product,
+ FreeQty: 0,
+ OverAllFreeQty: finalOrderQty,
+ RemainingQty: finalOrderQty,
+ discount: finalOrderQty * editedProduct?.OrderRate,
+ };
+ }
+ return product;
+ });
+ dispatch(ChangeFullFreeProductList(updatedFreeProdList));
+ } else if (isFreeProductApplicable?.FreeQty <= finalOrderQty) {
+ // check if there is any applicable free product in cart
+ await handleNormalEditQuantity(
+ editedProduct,
+ editedProductIndex,
+ editedQty,
+ newPrice
+ );
+ const updatedFreeProdList = FreeProdList?.map((product) => {
+ if (
+ product?.ProdId === editedProduct?.ProdId &&
+ product?.InwardDtlId === editedProduct?.InwardDtlId
+ ) {
+ return {
+ ...product,
+ OverAllFreeQty: finalOrderQty,
+ RemainingQty: finalOrderQty - product?.FreeQty,
+ };
+ }
+ return product;
+ });
+ dispatch(ChangeFullFreeProductList(updatedFreeProdList));
+ } else if (isFreeProductApplicable?.FreeQty > finalOrderQty) {
+ // need to split free product and paid product
+ let remainingPaidQty =
+ isFreeProductApplicable?.FreeQty - finalOrderQty;
+ const applicableFreeInCart = CartOrderDetails?.filter(
+ (cartItem) => {
+ return (
+ freeProductVariants?.some(
+ (variant) =>
+ variant.FreeProdId === cartItem.ProdId &&
+ variant?.StockDetails?.some(
+ (stock) =>
+ stock.FreeInwardDtlId === cartItem.InwardDtlId
+ )
+ ) &&
+ cartItem?.Offer &&
+ isFreeProductApplicable?.OfferId ===
+ cartItem?.OfferMessage?.[0]?.OfferId
+ );
+ }
+ );
+ const applicableFreeInCartAsPaid = CartOrderDetails?.filter(
+ (cartItem) => {
+ return (
+ freeProductVariants?.some(
+ (variant) =>
+ variant.FreeProdId === cartItem.ProdId &&
+ variant?.StockDetails?.some(
+ (stock) =>
+ stock.FreeInwardDtlId === cartItem.InwardDtlId
+ )
+ ) && !cartItem?.Offer
+ );
+ }
+ );
+ const sameBookingTypeProduct = applicableFreeInCart?.find(
+ (cartItem) => {
+ return (
+ cartItem?.BookingTypeName === editedProduct?.BookingTypeName
+ );
+ }
+ );
+ const otherBookingTypeProduct = applicableFreeInCart?.find(
+ (cartItem) => {
+ return (
+ cartItem?.BookingTypeName !== editedProduct?.BookingTypeName
+ );
+ }
+ );
+ const sameBookingTypeProductAsPaid =
+ applicableFreeInCartAsPaid?.find((cartItem) => {
+ return (
+ cartItem?.BookingTypeName === editedProduct?.BookingTypeName
+ );
+ });
+ const otherBookingTypeProductAsPaid =
+ applicableFreeInCartAsPaid?.find((cartItem) => {
+ return (
+ cartItem?.BookingTypeName !== editedProduct?.BookingTypeName
+ );
+ });
+ let updatedCart = [...CartOrderDetails];
+ if (sameBookingTypeProduct) {
+ if (sameBookingTypeProductAsPaid) {
+ if (sameBookingTypeProduct?.OrderQty <= remainingPaidQty) {
+ updatedCart = updatedCart?.filter(
+ (cartItem) => cartItem !== sameBookingTypeProduct
+ );
+ updatedCart = updatedCart?.map((cartItem) => {
+ if (cartItem === sameBookingTypeProductAsPaid) {
+ const newItem = {
+ ...cartItem,
+ OrderQty:
+ cartItem.OrderQty + sameBookingTypeProduct?.OrderQty,
+ ...calculateTaxAmounts({
+ qty:
+ cartItem.OrderQty +
+ sameBookingTypeProduct?.OrderQty,
+ rate: cartItem.OrderRate,
+ taxPercentage: cartItem.TaxPercentage,
+ }),
+ Offer: 0,
+ };
+
+ delete newItem.OfferMode;
+ delete newItem.OfferMessage;
+ delete newItem.OfferType;
+
+ return newItem;
+ }
+ return cartItem;
+ });
+ } else if (
+ sameBookingTypeProduct?.OrderQty > remainingPaidQty
+ ) {
+ updatedCart = updatedCart?.map((cartItem) => {
+ if (cartItem === sameBookingTypeProduct) {
+ return {
+ ...cartItem,
+ OrderQty: cartItem.OrderQty - remainingPaidQty,
+ ...calculateTaxAmounts({
+ qty: cartItem.OrderQty - remainingPaidQty,
+ rate: cartItem.OrderRate,
+ taxPercentage: cartItem.TaxPercentage,
+ }),
+ Offer:
+ (cartItem?.OrderQty - remainingPaidQty) *
+ cartItem?.OrderRate,
+ };
+ } else if (cartItem === sameBookingTypeProductAsPaid) {
+ return {
+ ...cartItem,
+ OrderQty: cartItem?.OrderQty + remainingPaidQty,
+ ...calculateTaxAmounts({
+ qty: cartItem?.OrderQty + remainingPaidQty,
+ rate: cartItem?.OrderRate,
+ taxPercentage: cartItem?.TaxPercentage,
+ }),
+ };
+ }
+ return cartItem;
+ });
+ }
+ } else {
+ if (sameBookingTypeProduct?.OrderQty <= remainingPaidQty) {
+ updatedCart = updatedCart?.map((cartItem) => {
+ if (cartItem === sameBookingTypeProduct) {
+ const newPaidProd = {
+ ...cartItem,
+ Offer: 0,
+ };
+
+ delete newPaidProd.OfferMode;
+ delete newPaidProd.OfferMessage;
+ delete newPaidProd.OfferType;
+ return newPaidProd;
+ }
+ return cartItem;
+ });
+ } else if (
+ sameBookingTypeProduct?.OrderQty > remainingPaidQty
+ ) {
+ const newPaidProduct = {
+ ...sameBookingTypeProduct,
+ OrderQty: remainingPaidQty,
+ Offer: 0,
+ };
+ delete newPaidProduct.OfferMode;
+ delete newPaidProduct.OfferMessage;
+ delete newPaidProduct.OfferType;
+ updatedCart = updatedCart?.map((cartItem) => {
+ if (cartItem === sameBookingTypeProduct) {
+ return {
+ ...cartItem,
+ OrderQty: cartItem.OrderQty - remainingPaidQty,
+ ...calculateTaxAmounts({
+ qty: cartItem?.OrderQty,
+ rate: cartItem?.OrderRate,
+ taxPercentage: cartItem?.TaxPercentage,
+ }),
+ Offer:
+ (cartItem?.OrderQty - remainingPaidQty) *
+ cartItem?.OrderRate,
+ };
+ }
+ return cartItem;
+ });
+ updatedCart = [...updatedCart, newPaidProduct];
+ }
+ }
+ remainingPaidQty =
+ remainingPaidQty - sameBookingTypeProduct?.OrderQty;
+ }
+
+ if (otherBookingTypeProduct && remainingPaidQty > 0) {
+ if (otherBookingTypeProductAsPaid) {
+ if (otherBookingTypeProduct?.OrderQty <= remainingPaidQty) {
+ updatedCart = updatedCart?.filter(
+ (cartItem) => cartItem !== otherBookingTypeProduct
+ );
+ updatedCart = updatedCart?.map((cartItem) => {
+ if (cartItem === otherBookingTypeProductAsPaid) {
+ const newItem = {
+ ...cartItem,
+ OrderQty:
+ cartItem.OrderQty + otherBookingTypeProduct?.OrderQty,
+ ...calculateTaxAmounts({
+ qty:
+ cartItem.OrderQty +
+ otherBookingTypeProduct?.OrderQty,
+ rate: cartItem.OrderRate,
+ taxPercentage: cartItem.TaxPercentage,
+ }),
+ Offer: 0,
+ };
+
+ delete newItem.OfferMode;
+ delete newItem.OfferMessage;
+ delete newItem.OfferType;
+
+ return newItem;
+ }
+ return cartItem;
+ });
+ } else if (
+ otherBookingTypeProduct?.OrderQty > remainingPaidQty
+ ) {
+ updatedCart = updatedCart?.map((cartItem) => {
+ if (cartItem === otherBookingTypeProduct) {
+ return {
+ ...cartItem,
+ OrderQty: cartItem.OrderQty - remainingPaidQty,
+ ...calculateTaxAmounts({
+ qty: cartItem.OrderQty - remainingPaidQty,
+ rate: cartItem.OrderRate,
+ taxPercentage: cartItem.TaxPercentage,
+ }),
+ Offer:
+ (cartItem?.OrderQty - remainingPaidQty) *
+ cartItem?.OrderRate,
+ };
+ } else if (cartItem === otherBookingTypeProductAsPaid) {
+ return {
+ ...cartItem,
+ OrderQty: cartItem?.OrderQty + remainingPaidQty,
+ ...calculateTaxAmounts({
+ qty: cartItem?.OrderQty + remainingPaidQty,
+ rate: cartItem?.OrderRate,
+ taxPercentage: cartItem?.TaxPercentage,
+ }),
+ };
+ }
+ return cartItem;
+ });
+ }
+ } else {
+ if (otherBookingTypeProduct?.OrderQty <= remainingPaidQty) {
+ updatedCart = updatedCart?.map((cartItem) => {
+ if (cartItem === otherBookingTypeProduct) {
+ const newPaidProd = {
+ ...cartItem,
+ Offer: 0,
+ };
+ delete newPaidProd.OfferMode;
+ delete newPaidProd.OfferMessage;
+ delete newPaidProd.OfferType;
+ return newPaidProd;
+ }
+ return cartItem;
+ });
+ } else if (
+ otherBookingTypeProduct?.OrderQty > remainingPaidQty
+ ) {
+ const newPaidProduct = {
+ ...otherBookingTypeProduct,
+ OrderQty:
+ otherBookingTypeProduct?.OrderQty - remainingPaidQty,
+ Offer: 0,
+ };
+ delete newPaidProduct.OfferMode;
+ delete newPaidProduct.OfferMessage;
+ delete newPaidProduct.OfferType;
+ updatedCart = updatedCart?.map((cartItem) => {
+ if (cartItem === otherBookingTypeProduct) {
+ return {
+ ...cartItem,
+ OrderQty: cartItem.OrderQty - remainingPaidQty,
+ ...calculateTaxAmounts({
+ qty: cartItem?.OrderQty,
+ rate: cartItem?.OrderRate,
+ taxPercentage: cartItem?.TaxPercentage,
+ }),
+ Offer:
+ (cartItem?.OrderQty - remainingPaidQty) *
+ cartItem?.OrderRate,
+ };
+ }
+ return cartItem;
+ });
+ updatedCart = [...updatedCart, newPaidProduct];
+ }
+ }
+ }
+
+ updatedCart = updatedCart?.map((cartItem) => {
+ if (cartItem === editedProduct) {
+ return {
+ ...cartItem,
+ OrderQty: editedQty,
+ ...calculateTaxAmounts({
+ qty: editedQty,
+ rate: cartItem.OrderRate,
+ taxPercentage: cartItem.TaxPercentage,
+ }),
+ };
+ }
+ return cartItem;
+ });
+
+ dispatch(changeOrderCardDetails(updatedCart));
+
+ const updatedFreeProdList = FreeProdList?.map((product) => {
+ if (
+ product?.ProdId === editedProduct?.ProdId &&
+ product?.InwardDtlId === editedProduct?.InwardDtlId &&
+ product?.OfferId ===
+ (sameBookingTypeProduct?.OfferMessage?.[0]?.OfferId ||
+ otherBookingTypeProduct?.OfferMessage?.[0]?.OfferId) &&
+ product?.OfferMode ===
+ (sameBookingTypeProduct?.OfferMode ||
+ otherBookingTypeProduct?.OfferMode)
+ ) {
+ return {
+ ...product,
+ FreeQty: finalOrderQty,
+ OverAllFreeQty: finalOrderQty,
+ RemainingQty: 0,
+ discount:
+ finalOrderQty *
+ (sameBookingTypeProduct?.OrderRate ||
+ otherBookingTypeProduct?.OrderRate),
+ };
+ }
+ return product;
+ });
+ dispatch(ChangeFullFreeProductList(updatedFreeProdList));
+ const updatedOfferAppliedProducts = OfferAppliedProducts?.map(
+ (offerProduct) => {
+ // Check if this offer product contains the edited product in its free products list
+ const hasMatchingFreeProduct =
+ offerProduct?.FreeProductsList?.some((freeProduct) =>
+ freeProduct?.ProdVariantDetails?.some((variant) =>
+ variant?.StockDetails?.some(
+ (stock) =>
+ stock?.FreeInwardDtlId ===
+ (sameBookingTypeProduct?.InwardDtlId ||
+ otherBookingTypeProduct?.InwardDtlId)
+ )
+ )
+ );
+
+ // Also check main offer conditions
+ const isMatchingOffer =
+ offerProduct?.OfferId ===
+ (sameBookingTypeProduct?.OfferMessage?.[0]?.OfferId ||
+ otherBookingTypeProduct?.OfferMessage?.[0]?.OfferId) &&
+ offerProduct?.OfferMode ===
+ (sameBookingTypeProduct?.OfferMode ||
+ otherBookingTypeProduct?.OfferMode);
+
+ if (hasMatchingFreeProduct && isMatchingOffer) {
+ // Get loyalty points from the matching free product
+ const matchingFreeProduct =
+ offerProduct?.FreeProductsList?.find((freeProduct) =>
+ freeProduct?.ProdVariantDetails?.some((variant) =>
+ variant?.StockDetails?.some(
+ (stock) =>
+ stock?.FreeInwardDtlId ===
+ (sameBookingTypeProduct?.InwardDtlId ||
+ otherBookingTypeProduct?.InwardDtlId)
+ )
+ )
+ );
+
+ const prodLoyaltyPoint =
+ matchingFreeProduct?.ProdVariantDetails?.[0]
+ ?.StockDetails?.[0]?.ProdLoyaltyPoint || 0;
+
+ // Update the specific free product in the list
+ const updatedFreeProductsList =
+ offerProduct?.FreeProductsList?.map((freeProduct) => {
+ const isTargetFreeProduct =
+ freeProduct?.ProdVariantDetails?.some((variant) =>
+ variant?.StockDetails?.some(
+ (stock) =>
+ stock?.FreeInwardDtlId ===
+ (sameBookingTypeProduct?.InwardDtlId ||
+ otherBookingTypeProduct?.InwardDtlId)
+ )
+ );
+
+ if (isTargetFreeProduct) {
+ return {
+ ...freeProduct,
+ FreeQty: finalOrderQty,
+ };
+ }
+ return freeProduct;
+ });
+
+ return {
+ ...offerProduct,
+ ActualFreeQty: finalOrderQty,
+ ActualOfferAmount:
+ finalOrderQty *
+ (sameBookingTypeProduct?.OrderRate ||
+ otherBookingTypeProduct?.OrderRate),
+ OfferAmount:
+ finalOrderQty *
+ (sameBookingTypeProduct?.OrderRate ||
+ otherBookingTypeProduct?.OrderRate),
+ OfferValue:
+ finalOrderQty *
+ (sameBookingTypeProduct?.OrderRate ||
+ otherBookingTypeProduct?.OrderRate),
+ FreeProductsList: updatedFreeProductsList,
+ UsedCount: finalOrderQty * prodLoyaltyPoint,
+ };
+ }
+
+ return offerProduct;
+ }
+ );
+ dispatch(
+ changeFullOfferAppliedProducts(updatedOfferAppliedProducts)
+ );
+ }
+ } else {
+ if (isFreeProductApplicable?.FreeQty === 0) {
+ await handleNormalEditQuantity(
+ editedProduct,
+ editedProductIndex,
+ editedQty,
+ newPrice
+ );
+ // update free product list (Set OverAllFreeQty = OrderQty and Remaining = OrderQty)
+ const updatedFreeProdList = FreeProdList?.map((product) => {
+ if (
+ product?.ProdId === editedProduct?.ProdId &&
+ product?.InwardDtlId === editedProduct?.InwardDtlId
+ ) {
+ return {
+ ...product,
+ FreeQty: 0,
+ OverAllFreeQty: finalOrderQty,
+ RemainingQty: finalOrderQty,
+ discount: finalOrderQty * editedProduct?.OrderRate,
+ };
+ }
+ return product;
+ });
+ dispatch(ChangeFullFreeProductList(updatedFreeProdList));
+ } else if (isFreeProductApplicable?.FreeQty === finalOrderQty) {
+ dispatch(
+ changeOrderCardDetails(
+ updatedCart?.map((cartItem) => {
+ if (cartItem === editedProduct) {
+ return {
+ ...cartItem,
+ PackageDtl: PackageDtl,
+ };
+ }
+ return cartItem;
+ })
+ )
+ );
+ return;
+ } else if (isFreeProductApplicable?.FreeQty < finalOrderQty) {
+ // check if there is any applicable free product in cart
+ console.log(freeProductVariants, 'freeProductVariants');
+ const applicableFreeInCart = CartOrderDetails?.filter(
+ (cartItem) => {
+ return (
+ freeProductVariants?.some(
+ (variant) =>
+ variant.FreeProdId === cartItem.ProdId &&
+ variant?.StockDetails?.some(
+ (stock) =>
+ stock.FreeInwardDtlId === cartItem.InwardDtlId
+ )
+ ) && !cartItem?.Offer
+ );
+ }
+ );
+
+ const applicableOfferAppliedFreeInCart = CartOrderDetails?.filter(
+ (cartItem) => {
+ return (
+ freeProductVariants?.some(
+ (variant) =>
+ variant.FreeProdId === cartItem.ProdId &&
+ variant?.StockDetails?.some(
+ (stock) =>
+ stock.FreeInwardDtlId === cartItem.InwardDtlId
+ )
+ ) &&
+ cartItem?.Offer > 0 &&
+ isFreeProductApplicable?.OfferMode === cartItem?.OfferMode &&
+ isFreeProductApplicable?.OfferId ===
+ cartItem?.OfferMessage?.[0]?.OfferId
+ );
+ }
+ );
+
+ if (applicableFreeInCart?.length > 0) {
+ console.log(applicableFreeInCart, 'applicableFreeInCart');
+ const sameBookingTypeProduct = applicableFreeInCart?.find(
+ (cartItem) => {
+ return (
+ cartItem?.BookingTypeName === editedProduct?.BookingTypeName
+ );
+ }
+ );
+ const otherBookingTypeProduct = applicableFreeInCart?.find(
+ (cartItem) => {
+ return (
+ cartItem?.BookingTypeName !== editedProduct?.BookingTypeName
+ );
+ }
+ );
+ const sameBookingTypeFreeProduct =
+ applicableOfferAppliedFreeInCart?.find((cartItem) => {
+ return (
+ cartItem?.BookingTypeName === editedProduct?.BookingTypeName
+ );
+ });
+ const otherBookingTypeFreeProduct =
+ applicableOfferAppliedFreeInCart?.find((cartItem) => {
+ return (
+ cartItem?.BookingTypeName !== editedProduct?.BookingTypeName
+ );
+ });
+ // find how many qty need to be updated as free product
+ const totalFreeQtyInCart = applicableFreeInCart?.reduce(
+ (acc, item) => acc + item.OrderQty,
+ 0
+ );
+ const freeQtyNeeded =
+ finalOrderQty - isFreeProductApplicable?.OverAllFreeQty;
+ if (totalFreeQtyInCart === freeQtyNeeded) {
+ let updatedCart = [...CartOrderDetails];
+ if (sameBookingTypeProduct) {
+ if (sameBookingTypeFreeProduct) {
+ updatedCart = updatedCart?.filter(
+ (cartItem) => cartItem !== sameBookingTypeProduct
+ );
+ updatedCart = updatedCart?.map((cartItem) => {
+ if (cartItem === sameBookingTypeFreeProduct) {
+ return {
+ ...cartItem,
+ OrderQty:
+ cartItem.OrderQty +
+ sameBookingTypeProduct?.OrderQty,
+ ...calculateTaxAmounts({
+ qty:
+ cartItem.OrderQty +
+ sameBookingTypeProduct?.OrderQty,
+ rate: cartItem.OrderRate,
+ taxPercentage: cartItem.TaxPercentage,
+ }),
+ Offer:
+ (cartItem.OrderQty +
+ sameBookingTypeProduct?.OrderQty) *
+ cartItem.OrderRate,
+ };
+ }
+ return cartItem;
+ });
+ } else {
+ updatedCart = updatedCart?.map((cartItem) => {
+ if (cartItem === sameBookingTypeProduct) {
+ return {
+ ...cartItem,
+ Offer:
+ sameBookingTypeProduct?.OrderQty *
+ cartItem.OrderRate,
+ OfferMode: isFreeProductApplicable?.OfferMode,
+ OfferType: isFreeProductApplicable?.OfferType,
+ OfferMessage: [
+ {
+ OfferId: isFreeProductApplicable?.OfferId,
+ OfferName: isFreeProductApplicable?.OfferName,
+ OfferDescription:
+ isFreeProductApplicable?.OfferDescription,
+ },
+ ],
+ };
+ }
+ return cartItem;
+ });
+ }
+ }
+
+ if (otherBookingTypeProduct) {
+ if (otherBookingTypeFreeProduct) {
+ updatedCart = updatedCart?.filter(
+ (cartItem) => cartItem !== otherBookingTypeProduct
+ );
+ updatedCart = updatedCart?.map((cartItem) => {
+ if (
+ cartItem.ProdId === otherBookingTypeProduct.ProdId &&
+ cartItem.InwardDtlId ===
+ otherBookingTypeProduct.InwardDtlId &&
+ cartItem.BookingTypeName ===
+ otherBookingTypeProduct.BookingTypeName &&
+ cartItem.OrderRate ===
+ otherBookingTypeProduct.OrderRate &&
+ cartItem.OfferMode &&
+ cartItem.Offer > 0
+ ) {
+ return {
+ ...cartItem,
+ OrderQty:
+ cartItem.OrderQty +
+ otherBookingTypeProduct?.OrderQty,
+ ...calculateTaxAmounts({
+ qty:
+ cartItem.OrderQty +
+ otherBookingTypeProduct?.OrderQty,
+ rate: cartItem.OrderRate,
+ taxPercentage: cartItem.TaxPercentage,
+ }),
+ Offer:
+ (cartItem.OrderQty +
+ otherBookingTypeProduct?.OrderQty) *
+ cartItem.OrderRate,
+ };
+ }
+ return cartItem;
+ });
+ } else {
+ updatedCart = updatedCart?.map((cartItem) => {
+ if (cartItem === otherBookingTypeProduct) {
+ return {
+ ...cartItem,
+ Offer:
+ otherBookingTypeProduct?.OrderQty *
+ cartItem.OrderRate,
+ OfferMode: isFreeProductApplicable?.OfferMode,
+ OfferType: isFreeProductApplicable?.OfferType,
+ OfferMessage: [
+ {
+ OfferId: isFreeProductApplicable?.OfferId,
+ OfferName: isFreeProductApplicable?.OfferName,
+ OfferDescription:
+ isFreeProductApplicable?.OfferDescription,
+ },
+ ],
+ };
+ }
+ return cartItem;
+ });
+ }
+ }
+ updatedCart = updatedCart?.map((cartItem) => {
+ if (cartItem === editedProduct) {
+ return {
+ ...cartItem,
+ OrderQty: editedQty,
+ ...calculateTaxAmounts({
+ qty: editedQty,
+ rate: cartItem.OrderRate,
+ taxPercentage: cartItem.TaxPercentage,
+ }),
+ ...(cartItem?.Offer > 0 && {
+ Offer: editedQty * cartItem.OrderRate,
+ }),
+ };
+ }
+ return cartItem;
+ });
+ dispatch(changeOrderCardDetails(updatedCart));
+ const updatedFreeProdList = FreeProdList?.map((product) => {
+ if (
+ product?.ProdId === editedProduct?.ProdId &&
+ product?.InwardDtlId === editedProduct?.InwardDtlId &&
+ product?.OfferId ===
+ (sameBookingTypeFreeProduct?.OfferMessage?.[0]?.OfferId ||
+ otherBookingTypeFreeProduct?.OfferMessage?.[0]
+ ?.OfferId) &&
+ product?.OfferMode ===
+ (sameBookingTypeFreeProduct?.OfferMode ||
+ otherBookingTypeFreeProduct?.OfferMode)
+ ) {
+ return {
+ ...product,
+ FreeQty: finalOrderQty,
+ OverAllFreeQty: finalOrderQty,
+ RemainingQty: 0,
+ discount:
+ finalOrderQty *
+ (sameBookingTypeProduct?.OrderRate ||
+ otherBookingTypeProduct?.OrderRate),
+ };
+ }
+ return product;
+ });
+ dispatch(ChangeFullFreeProductList(updatedFreeProdList));
+ const updatedOfferAppliedProducts = OfferAppliedProducts?.map(
+ (offerProduct) => {
+ // Check if this offer product contains the edited product in its free products list
+ const hasMatchingFreeProduct =
+ offerProduct?.FreeProductsList?.some((freeProduct) =>
+ freeProduct?.ProdVariantDetails?.some((variant) =>
+ variant?.StockDetails?.some(
+ (stock) =>
+ stock?.FreeInwardDtlId ===
+ (sameBookingTypeFreeProduct?.InwardDtlId ||
+ otherBookingTypeProduct?.InwardDtlId)
+ )
+ )
+ );
+
+ // Also check main offer conditions
+ const isMatchingOffer =
+ offerProduct?.OfferId ===
+ (sameBookingTypeFreeProduct?.OfferMessage?.[0]
+ ?.OfferId ||
+ otherBookingTypeFreeProduct?.OfferMessage?.[0]
+ ?.OfferId) &&
+ offerProduct?.OfferMode ===
+ (sameBookingTypeFreeProduct?.OfferMode ||
+ otherBookingTypeFreeProduct?.OfferMode);
+
+ if (hasMatchingFreeProduct && isMatchingOffer) {
+ // Get loyalty points from the matching free product
+ const matchingFreeProduct =
+ offerProduct?.FreeProductsList?.find((freeProduct) =>
+ freeProduct?.ProdVariantDetails?.some((variant) =>
+ variant?.StockDetails?.some(
+ (stock) =>
+ stock?.FreeInwardDtlId ===
+ (sameBookingTypeProduct?.InwardDtlId ||
+ otherBookingTypeProduct?.InwardDtlId)
+ )
+ )
+ );
+
+ const prodLoyaltyPoint =
+ matchingFreeProduct?.ProdVariantDetails?.[0]
+ ?.StockDetails?.[0]?.ProdLoyaltyPoint || 0;
+
+ // Update the specific free product in the list
+ const updatedFreeProductsList =
+ offerProduct?.FreeProductsList?.map((freeProduct) => {
+ const isTargetFreeProduct =
+ freeProduct?.ProdVariantDetails?.some((variant) =>
+ variant?.StockDetails?.some(
+ (stock) =>
+ stock?.FreeInwardDtlId ===
+ (sameBookingTypeProduct?.InwardDtlId ||
+ otherBookingTypeProduct?.InwardDtlId)
+ )
+ );
+
+ if (isTargetFreeProduct) {
+ return {
+ ...freeProduct,
+ FreeQty: finalOrderQty,
+ };
+ }
+ return freeProduct;
+ });
+
+ return {
+ ...offerProduct,
+ ActualFreeQty: finalOrderQty,
+ ActualOfferAmount:
+ finalOrderQty *
+ (sameBookingTypeProduct?.OrderRate ||
+ otherBookingTypeProduct?.OrderRate),
+ OfferAmount:
+ finalOrderQty *
+ (sameBookingTypeProduct?.OrderRate ||
+ otherBookingTypeProduct?.OrderRate),
+ OfferValue:
+ finalOrderQty *
+ (sameBookingTypeProduct?.OrderRate ||
+ otherBookingTypeProduct?.OrderRate),
+ FreeProductsList: updatedFreeProductsList,
+ UsedCount: finalOrderQty * prodLoyaltyPoint,
+ };
+ }
+
+ return offerProduct;
+ }
+ );
+ dispatch(
+ changeFullOfferAppliedProducts(updatedOfferAppliedProducts)
+ );
+ } else if (totalFreeQtyInCart > freeQtyNeeded) {
+ let updatedCart = [...CartOrderDetails];
+ if (sameBookingTypeProduct) {
+ // if available same booking type product qty is more than or equal to freeQtyNeeded.
+ // if more than then we need to update both free and paid product=
+ if (sameBookingTypeProduct?.OrderQty === freeQtyNeeded) {
+ if (sameBookingTypeFreeProduct) {
+ updatedCart = updatedCart?.filter(
+ (cartItem) => cartItem !== sameBookingTypeProduct
+ );
+ updatedCart = updatedCart?.map((cartItem) => {
+ if (
+ cartItem.ProdId === sameBookingTypeProduct.ProdId &&
+ cartItem.InwardDtlId ===
+ sameBookingTypeProduct.InwardDtlId &&
+ cartItem.BookingTypeName ===
+ sameBookingTypeProduct.BookingTypeName &&
+ cartItem.OrderRate ===
+ sameBookingTypeProduct.OrderRate &&
+ cartItem.OfferMode &&
+ cartItem.Offer > 0
+ ) {
+ return {
+ ...cartItem,
+ OrderQty:
+ cartItem.OrderQty +
+ sameBookingTypeProduct?.OrderQty,
+ ...calculateTaxAmounts({
+ qty:
+ cartItem.OrderQty +
+ sameBookingTypeProduct?.OrderQty,
+ rate: cartItem.OrderRate,
+ taxPercentage: cartItem.TaxPercentage,
+ }),
+ Offer:
+ (cartItem.OrderQty +
+ sameBookingTypeProduct?.OrderQty) *
+ cartItem.OrderRate,
+ };
+ }
+ return cartItem;
+ });
+ } else {
+ updatedCart = updatedCart?.map((cartItem) => {
+ if (cartItem === sameBookingTypeProduct) {
+ return {
+ ...cartItem,
+ Offer:
+ sameBookingTypeProduct?.OrderQty *
+ cartItem.OrderRate,
+ OfferMode: isFreeProductApplicable?.OfferMode,
+ OfferType: isFreeProductApplicable?.OfferType,
+ OfferMessage: [
+ {
+ OfferId: isFreeProductApplicable?.OfferId,
+ OfferName: isFreeProductApplicable?.OfferName,
+ OfferDescription:
+ isFreeProductApplicable?.OfferDescription,
+ },
+ ],
+ };
+ }
+ return cartItem;
+ });
+ }
+ } else if (sameBookingTypeProduct?.OrderQty > freeQtyNeeded) {
+ if (sameBookingTypeFreeProduct) {
+ updatedCart = updatedCart?.map((cartItem) => {
+ if (
+ cartItem.ProdId === sameBookingTypeProduct.ProdId &&
+ cartItem.InwardDtlId ===
+ sameBookingTypeProduct.InwardDtlId &&
+ cartItem.BookingTypeName ===
+ sameBookingTypeProduct.BookingTypeName &&
+ cartItem.OrderRate ===
+ sameBookingTypeProduct.OrderRate &&
+ cartItem.OfferMode &&
+ cartItem.Offer > 0
+ ) {
+ return {
+ ...cartItem,
+ OrderQty: cartItem.OrderQty + freeQtyNeeded,
+ ...calculateTaxAmounts({
+ qty: cartItem.OrderQty + freeQtyNeeded,
+ rate: cartItem.OrderRate,
+ taxPercentage: cartItem.TaxPercentage,
+ }),
+ Offer:
+ (cartItem.OrderQty + freeQtyNeeded) *
+ cartItem.OrderRate,
+ };
+ } else if (cartItem === sameBookingTypeProduct) {
+ return {
+ ...cartItem,
+ OrderQty: cartItem.OrderQty - freeQtyNeeded,
+ ...calculateTaxAmounts({
+ qty: cartItem.OrderQty - freeQtyNeeded,
+ rate: cartItem.OrderRate,
+ taxPercentage: cartItem.TaxPercentage,
+ }),
+ };
+ }
+ return cartItem;
+ });
+ } else {
+ const remainingPaidQty =
+ sameBookingTypeProduct?.OrderQty - freeQtyNeeded;
+ updatedCart = updatedCart?.map((cartItem) => {
+ if (cartItem === sameBookingTypeProduct) {
+ return {
+ ...cartItem,
+ OrderQty: remainingPaidQty,
+ ...calculateTaxAmounts({
+ qty: remainingPaidQty,
+ rate: cartItem.OrderRate,
+ taxPercentage: cartItem.TaxPercentage,
+ }),
+ };
+ }
+ return cartItem;
+ });
+ const freeProduct = {
+ ...sameBookingTypeProduct,
+ OrderQty: freeQtyNeeded,
+ ...calculateTaxAmounts({
+ qty: freeQtyNeeded,
+ rate: sameBookingTypeProduct.OrderRate,
+ taxPercentage: sameBookingTypeProduct.TaxPercentage,
+ }),
+ Offer: freeQtyNeeded * sameBookingTypeProduct.OrderRate,
+ OfferMode: isFreeProductApplicable?.OfferMode,
+ OfferType: isFreeProductApplicable?.OfferType,
+ OfferMessage: [
+ {
+ OfferId: isFreeProductApplicable?.OfferId,
+ OfferName: isFreeProductApplicable?.OfferName,
+ OfferDescription:
+ isFreeProductApplicable?.OfferDescription,
+ },
+ ],
+ localId: uuidv4(),
+ };
+ updatedCart = [...updatedCart, freeProduct];
+ }
+ }
+ }
+
+ if (
+ otherBookingTypeProduct &&
+ freeQtyNeeded > (sameBookingTypeProduct?.OrderQty || 0)
+ ) {
+ const remainingFreeQtyNeeded =
+ freeQtyNeeded - (sameBookingTypeProduct?.OrderQty || 0);
+ if (
+ remainingFreeQtyNeeded === otherBookingTypeProduct?.OrderQty
+ ) {
+ if (otherBookingTypeFreeProduct) {
+ updatedCart = updatedCart?.filter(
+ (cartItem) => cartItem !== otherBookingTypeProduct
+ );
+ updatedCart = updatedCart?.map((cartItem) => {
+ if (
+ cartItem.ProdId === otherBookingTypeProduct.ProdId &&
+ cartItem?.InwardDtlId ===
+ otherBookingTypeProduct.InwardDtlId &&
+ cartItem?.BookingTypeName ===
+ otherBookingTypeProduct.BookingTypeName &&
+ cartItem?.OrderRate ===
+ otherBookingTypeProduct.OrderRate &&
+ cartItem?.OfferMode &&
+ cartItem?.Offer > 0
+ ) {
+ return {
+ ...cartItem,
+ OrderQty:
+ cartItem.OrderQty +
+ otherBookingTypeProduct?.OrderQty,
+ ...calculateTaxAmounts({
+ qty:
+ cartItem.OrderQty +
+ otherBookingTypeProduct?.OrderQty,
+ rate: cartItem.OrderRate,
+ taxPercentage: cartItem.TaxPercentage,
+ }),
+ Offer:
+ (cartItem.OrderQty +
+ otherBookingTypeProduct?.OrderQty) *
+ cartItem.OrderRate,
+ };
+ }
+ return cartItem;
+ });
+ } else {
+ updatedCart = updatedCart?.map((cartItem) => {
+ if (
+ cartItem.ProdId === otherBookingTypeProduct.ProdId &&
+ cartItem.InwardDtlId ===
+ otherBookingTypeProduct.InwardDtlId &&
+ cartItem.BookingTypeName ===
+ otherBookingTypeProduct.BookingTypeName &&
+ cartItem.OrderRate ===
+ otherBookingTypeProduct.OrderRate &&
+ cartItem.OfferMode &&
+ cartItem.Offer > 0
+ ) {
+ return {
+ ...cartItem,
+ Offer: cartItem.OrderQty * cartItem.OrderRate,
+ OfferMode: isFreeProductApplicable?.OfferMode,
+ OfferType: isFreeProductApplicable?.OfferType,
+ OfferMessage: [
+ {
+ OfferId: isFreeProductApplicable?.OfferId,
+ OfferName: isFreeProductApplicable?.OfferName,
+ OfferDescription:
+ isFreeProductApplicable?.OfferDescription,
+ },
+ ],
+ };
+ }
+ return cartItem;
+ });
+ }
+ } else if (
+ otherBookingTypeProduct?.OrderQty > remainingFreeQtyNeeded
+ ) {
+ if (otherBookingTypeFreeProduct) {
+ updatedCart = updatedCart?.map((cartItem) => {
+ if (
+ cartItem.ProdId === otherBookingTypeProduct.ProdId &&
+ cartItem.InwardDtlId ===
+ otherBookingTypeProduct.InwardDtlId &&
+ cartItem.BookingTypeName ===
+ otherBookingTypeProduct.BookingTypeName &&
+ cartItem.OrderRate ===
+ otherBookingTypeProduct.OrderRate &&
+ cartItem.OfferMode &&
+ cartItem.Offer > 0
+ ) {
+ return {
+ ...cartItem,
+ OrderQty:
+ cartItem.OrderQty + remainingFreeQtyNeeded,
+ ...calculateTaxAmounts({
+ qty: cartItem.OrderQty + remainingFreeQtyNeeded,
+ rate: cartItem.OrderRate,
+ taxPercentage: cartItem.TaxPercentage,
+ }),
+ Offer:
+ (cartItem.OrderQty + remainingFreeQtyNeeded) *
+ cartItem.OrderRate,
+ };
+ } else if (cartItem === otherBookingTypeProduct) {
+ return {
+ ...cartItem,
+ OrderQty:
+ cartItem.OrderQty - remainingFreeQtyNeeded,
+ ...calculateTaxAmounts({
+ qty: cartItem.OrderQty - remainingFreeQtyNeeded,
+ rate: cartItem.OrderRate,
+ taxPercentage: cartItem.TaxPercentage,
+ }),
+ };
+ }
+ return cartItem;
+ });
+ } else {
+ const remainingPaidQty =
+ otherBookingTypeProduct?.OrderQty -
+ remainingFreeQtyNeeded;
+ const newFreeProduct = {
+ ...otherBookingTypeProduct,
+ OrderQty: remainingFreeQtyNeeded,
+ ...calculateTaxAmounts({
+ qty: remainingFreeQtyNeeded,
+ rate: otherBookingTypeProduct.OrderRate,
+ taxPercentage: otherBookingTypeProduct.TaxPercentage,
+ }),
+ Offer:
+ remainingFreeQtyNeeded *
+ otherBookingTypeProduct.OrderRate,
+ OfferMode: isFreeProductApplicable?.OfferMode,
+ OfferType: isFreeProductApplicable?.OfferType,
+ OfferMessage: [
+ {
+ OfferId: isFreeProductApplicable?.OfferId,
+ OfferName: isFreeProductApplicable?.OfferName,
+ OfferDescription:
+ isFreeProductApplicable?.OfferDescription,
+ },
+ ],
+ localId: uuidv4(),
+ };
+ updatedCart = updatedCart?.map((cartItem) => {
+ if (cartItem === otherBookingTypeProduct) {
+ return {
+ ...cartItem,
+ OrderQty: remainingPaidQty,
+ ...calculateTaxAmounts({
+ qty: remainingPaidQty,
+ rate: cartItem.OrderRate,
+ taxPercentage: cartItem.TaxPercentage,
+ }),
+ };
+ }
+ return cartItem;
+ });
+ updatedCart = [...updatedCart, newFreeProduct];
+ }
+ }
+ }
+ updatedCart = updatedCart?.map((cartItem) => {
+ if (cartItem === editedProduct) {
+ return {
+ ...cartItem,
+ OrderQty: editedQty,
+ ...calculateTaxAmounts({
+ qty: editedQty,
+ rate: cartItem.OrderRate,
+ taxPercentage: cartItem.TaxPercentage,
+ }),
+ ...(cartItem?.Offer > 0 && {
+ Offer: editedQty * cartItem.OrderRate,
+ }),
+ };
+ }
+ return cartItem;
+ });
+ dispatch(changeOrderCardDetails(updatedCart));
+ const updatedFreeProdList = FreeProdList?.map((product) => {
+ if (
+ product?.ProdId === editedProduct?.ProdId &&
+ product?.InwardDtlId === editedProduct?.InwardDtlId &&
+ product?.OfferId ===
+ (sameBookingTypeFreeProduct?.OfferMessage?.[0]?.OfferId ||
+ otherBookingTypeFreeProduct?.OfferMessage?.[0]
+ ?.OfferId) &&
+ product?.OfferMode ===
+ (sameBookingTypeFreeProduct?.OfferMode ||
+ otherBookingTypeFreeProduct?.OfferMode)
+ ) {
+ return {
+ ...product,
+ FreeQty: finalOrderQty,
+ OverAllFreeQty: finalOrderQty,
+ RemainingQty: 0,
+ discount:
+ finalOrderQty *
+ (sameBookingTypeProduct?.OrderRate ||
+ otherBookingTypeProduct?.OrderRate),
+ };
+ }
+ return product;
+ });
+ dispatch(ChangeFullFreeProductList(updatedFreeProdList));
+ const updatedOfferAppliedProducts = OfferAppliedProducts?.map(
+ (offerProduct) => {
+ // Check if this offer product contains the edited product in its free products list
+ const hasMatchingFreeProduct =
+ offerProduct?.FreeProductsList?.some((freeProduct) =>
+ freeProduct?.ProdVariantDetails?.some((variant) =>
+ variant?.StockDetails?.some(
+ (stock) =>
+ stock?.FreeInwardDtlId ===
+ (sameBookingTypeProduct?.InwardDtlId ||
+ otherBookingTypeProduct?.InwardDtlId)
+ )
+ )
+ );
+
+ // Also check main offer conditions
+ const isMatchingOffer =
+ offerProduct?.OfferId ===
+ (sameBookingTypeProduct?.OfferMessage?.[0]?.OfferId ||
+ otherBookingTypeProduct?.OfferMessage?.[0]
+ ?.OfferId) &&
+ offerProduct?.OfferMode ===
+ (sameBookingTypeProduct?.OfferMode ||
+ otherBookingTypeProduct?.OfferMode);
+
+ if (hasMatchingFreeProduct && isMatchingOffer) {
+ // Get loyalty points from the matching free product
+ const matchingFreeProduct =
+ offerProduct?.FreeProductsList?.find((freeProduct) =>
+ freeProduct?.ProdVariantDetails?.some((variant) =>
+ variant?.StockDetails?.some(
+ (stock) =>
+ stock?.FreeInwardDtlId ===
+ (sameBookingTypeProduct?.InwardDtlId ||
+ otherBookingTypeProduct?.InwardDtlId)
+ )
+ )
+ );
+
+ const prodLoyaltyPoint =
+ matchingFreeProduct?.ProdVariantDetails?.[0]
+ ?.StockDetails?.[0]?.ProdLoyaltyPoint || 0;
+
+ // Update the specific free product in the list
+ const updatedFreeProductsList =
+ offerProduct?.FreeProductsList?.map((freeProduct) => {
+ const isTargetFreeProduct =
+ freeProduct?.ProdVariantDetails?.some((variant) =>
+ variant?.StockDetails?.some(
+ (stock) =>
+ stock?.FreeInwardDtlId ===
+ (sameBookingTypeProduct?.InwardDtlId ||
+ otherBookingTypeProduct?.InwardDtlId)
+ )
+ );
+
+ if (isTargetFreeProduct) {
+ return {
+ ...freeProduct,
+ FreeQty: finalOrderQty,
+ };
+ }
+ return freeProduct;
+ });
+
+ return {
+ ...offerProduct,
+ ActualFreeQty: finalOrderQty,
+ ActualOfferAmount:
+ finalOrderQty *
+ (sameBookingTypeProduct?.OrderRate ||
+ otherBookingTypeProduct?.OrderRate),
+ OfferAmount:
+ finalOrderQty *
+ (sameBookingTypeProduct?.OrderRate ||
+ otherBookingTypeProduct?.OrderRate),
+ OfferValue:
+ finalOrderQty *
+ (sameBookingTypeProduct?.OrderRate ||
+ otherBookingTypeProduct?.OrderRate),
+ FreeProductsList: updatedFreeProductsList,
+ UsedCount: finalOrderQty * prodLoyaltyPoint,
+ };
+ }
+
+ return offerProduct;
+ }
+ );
+ dispatch(
+ changeFullOfferAppliedProducts(updatedOfferAppliedProducts)
+ );
+ } else if (totalFreeQtyInCart < freeQtyNeeded) {
+ let updatedCart = [...CartOrderDetails];
+ if (sameBookingTypeProduct) {
+ if (sameBookingTypeFreeProduct) {
+ updatedCart = updatedCart?.filter(
+ (cartItem) => cartItem !== sameBookingTypeProduct
+ );
+ updatedCart = updatedCart?.map((cartItem) => {
+ if (
+ cartItem.ProdId === sameBookingTypeProduct.ProdId &&
+ cartItem.InwardDtlId ===
+ sameBookingTypeProduct.InwardDtlId &&
+ cartItem.BookingTypeName ===
+ sameBookingTypeProduct.BookingTypeName &&
+ cartItem.OrderRate ===
+ sameBookingTypeProduct.OrderRate &&
+ cartItem.OfferMode &&
+ cartItem.Offer > 0
+ ) {
+ return {
+ ...cartItem,
+ OrderQty:
+ cartItem.OrderQty +
+ sameBookingTypeProduct?.OrderQty,
+ ...calculateTaxAmounts({
+ qty:
+ cartItem.OrderQty +
+ sameBookingTypeProduct?.OrderQty,
+ rate: cartItem.OrderRate,
+ taxPercentage: cartItem.TaxPercentage,
+ }),
+ Offer:
+ (cartItem.OrderQty +
+ sameBookingTypeProduct?.OrderQty) *
+ cartItem.OrderRate,
+ };
+ }
+ return cartItem;
+ });
+ } else {
+ updatedCart = updatedCart?.map((cartItem) => {
+ if (cartItem === sameBookingTypeProduct) {
+ return {
+ ...cartItem,
+ Offer:
+ (cartItem.OrderQty +
+ sameBookingTypeProduct?.OrderQty) *
+ cartItem.OrderRate,
+ OfferMode: isFreeProductApplicable?.OfferMode,
+ OfferType: isFreeProductApplicable?.OfferType,
+ OfferMessage: [
+ {
+ OfferId: isFreeProductApplicable?.OfferId,
+ OfferName: isFreeProductApplicable?.OfferName,
+ OfferDescription:
+ isFreeProductApplicable?.OfferDescription,
+ },
+ ],
+ };
+ }
+ return cartItem;
+ });
+ }
+ }
+
+ if (otherBookingTypeProduct) {
+ if (otherBookingTypeFreeProduct) {
+ updatedCart = updatedCart?.filter(
+ (cartItem) => cartItem !== otherBookingTypeProduct
+ );
+ updatedCart = updatedCart?.map((cartItem) => {
+ if (
+ cartItem.ProdId === otherBookingTypeProduct.ProdId &&
+ cartItem.InwardDtlId ===
+ otherBookingTypeProduct.InwardDtlId &&
+ cartItem.BookingTypeName ===
+ otherBookingTypeProduct.BookingTypeName &&
+ cartItem.OrderRate ===
+ otherBookingTypeProduct.OrderRate &&
+ cartItem.OfferMode &&
+ cartItem.Offer > 0
+ ) {
+ return {
+ ...cartItem,
+ OrderQty:
+ cartItem.OrderQty +
+ otherBookingTypeProduct?.OrderQty,
+ ...calculateTaxAmounts({
+ qty:
+ cartItem.OrderQty +
+ otherBookingTypeProduct?.OrderQty,
+ rate: cartItem.OrderRate,
+ taxPercentage: cartItem.TaxPercentage,
+ }),
+ Offer:
+ (cartItem.OrderQty +
+ otherBookingTypeProduct?.OrderQty) *
+ cartItem.OrderRate,
+ };
+ }
+ return cartItem;
+ });
+ } else {
+ updatedCart = updatedCart?.map((cartItem) => {
+ if (cartItem === otherBookingTypeProduct) {
+ return {
+ ...cartItem,
+ Offer:
+ otherBookingTypeProduct?.OrderQty *
+ cartItem.OrderRate,
+ OfferMode: isFreeProductApplicable?.OfferMode,
+ OfferType: isFreeProductApplicable?.OfferType,
+ OfferMessage: [
+ {
+ OfferId: isFreeProductApplicable?.OfferId,
+ OfferName: isFreeProductApplicable?.OfferName,
+ OfferDescription:
+ isFreeProductApplicable?.OfferDescription,
+ },
+ ],
+ };
+ }
+ return cartItem;
+ });
+ }
+ }
+ updatedCart = updatedCart?.map((cartItem) => {
+ if (cartItem === editedProduct) {
+ return {
+ ...cartItem,
+ OrderQty: editedQty,
+ ...calculateTaxAmounts({
+ qty: editedQty,
+ rate: cartItem.OrderRate,
+ taxPercentage: cartItem.TaxPercentage,
+ }),
+ ...(cartItem?.Offer > 0 && {
+ Offer: editedQty * cartItem.OrderRate,
+ }),
+ };
+ }
+ return cartItem;
+ });
+ dispatch(changeOrderCardDetails(updatedCart));
+ const remainingQty = freeQtyNeeded - totalFreeQtyInCart;
+ const updatedFreeProdList = FreeProdList?.map((product) => {
+ if (
+ product?.ProdId === editedProduct?.ProdId &&
+ product?.InwardDtlId === editedProduct?.InwardDtlId &&
+ product?.OfferId ===
+ (sameBookingTypeFreeProduct?.OfferMessage?.[0]?.OfferId ||
+ otherBookingTypeFreeProduct?.OfferMessage?.[0]
+ ?.OfferId) &&
+ product?.OfferMode ===
+ (sameBookingTypeFreeProduct?.OfferMode ||
+ otherBookingTypeFreeProduct?.OfferMode)
+ ) {
+ return {
+ ...product,
+ FreeQty: finalOrderQty - remainingQty,
+ OverAllFreeQty: finalOrderQty,
+ RemainingQty: remainingQty,
+ discount:
+ (finalOrderQty - remainingQty) *
+ (sameBookingTypeProduct?.OrderRate ||
+ otherBookingTypeProduct?.OrderRate),
+ };
+ }
+ return product;
+ });
+ dispatch(ChangeFullFreeProductList(updatedFreeProdList));
+ const updatedOfferAppliedProducts = OfferAppliedProducts?.map(
+ (offerProduct) => {
+ // Check if this offer product contains the edited product in its free products list
+ const hasMatchingFreeProduct =
+ offerProduct?.FreeProductsList?.some((freeProduct) =>
+ freeProduct?.ProdVariantDetails?.some((variant) =>
+ variant?.StockDetails?.some(
+ (stock) =>
+ stock?.FreeInwardDtlId ===
+ (sameBookingTypeProduct?.InwardDtlId ||
+ otherBookingTypeProduct?.InwardDtlId)
+ )
+ )
+ );
+
+ // Also check main offer conditions
+ const isMatchingOffer =
+ offerProduct?.OfferId ===
+ (sameBookingTypeProduct?.OfferMessage?.[0]?.OfferId ||
+ otherBookingTypeProduct?.OfferMessage?.[0]
+ ?.OfferId) &&
+ offerProduct?.OfferMode ===
+ (sameBookingTypeProduct?.OfferMode ||
+ otherBookingTypeProduct?.OfferMode);
+
+ if (hasMatchingFreeProduct && isMatchingOffer) {
+ // Get loyalty points from the matching free product
+ const matchingFreeProduct =
+ offerProduct?.FreeProductsList?.find((freeProduct) =>
+ freeProduct?.ProdVariantDetails?.some((variant) =>
+ variant?.StockDetails?.some(
+ (stock) =>
+ stock?.FreeInwardDtlId ===
+ (sameBookingTypeProduct?.InwardDtlId ||
+ otherBookingTypeProduct?.InwardDtlId)
+ )
+ )
+ );
+
+ const prodLoyaltyPoint =
+ matchingFreeProduct?.ProdVariantDetails?.[0]
+ ?.StockDetails?.[0]?.ProdLoyaltyPoint || 0;
+
+ // Update the specific free product in the list
+ const updatedFreeProductsList =
+ offerProduct?.FreeProductsList?.map((freeProduct) => {
+ const isTargetFreeProduct =
+ freeProduct?.ProdVariantDetails?.some((variant) =>
+ variant?.StockDetails?.some(
+ (stock) =>
+ stock?.FreeInwardDtlId ===
+ (sameBookingTypeProduct?.InwardDtlId ||
+ otherBookingTypeProduct?.InwardDtlId)
+ )
+ );
+
+ if (isTargetFreeProduct) {
+ return {
+ ...freeProduct,
+ FreeQty: finalOrderQty - remainingQty,
+ };
+ }
+ return freeProduct;
+ });
+
+ return {
+ ...offerProduct,
+ ActualFreeQty: finalOrderQty - remainingQty,
+ ActualOfferAmount:
+ (finalOrderQty - remainingQty) *
+ (sameBookingTypeProduct?.OrderRate ||
+ otherBookingTypeProduct?.OrderRate),
+ OfferAmount:
+ (finalOrderQty - remainingQty) *
+ (sameBookingTypeProduct?.OrderRate ||
+ otherBookingTypeProduct?.OrderRate),
+ OfferValue:
+ (finalOrderQty - remainingQty) *
+ (sameBookingTypeProduct?.OrderRate ||
+ otherBookingTypeProduct?.OrderRate),
+ FreeProductsList: updatedFreeProductsList,
+ UsedCount:
+ (finalOrderQty - remainingQty) * prodLoyaltyPoint,
+ };
+ }
+
+ return offerProduct;
+ }
+ );
+ dispatch(
+ changeFullOfferAppliedProducts(updatedOfferAppliedProducts)
+ );
+ }
+ } else {
+ // just update the free product list
+ await handleNormalEditQuantity(
+ editedProduct,
+ editedProductIndex,
+ editedQty,
+ newPrice
+ );
+ const updatedFreeProdList = FreeProdList?.map((product) => {
+ if (
+ product?.ProdId === editedProduct?.ProdId &&
+ product?.InwardDtlId === editedProduct?.InwardDtlId
+ ) {
+ return {
+ ...product,
+ OverAllFreeQty: finalOrderQty,
+ RemainingQty: finalOrderQty - product?.FreeQty,
+ discount: finalOrderQty * editedProduct?.OrderRate,
+ };
+ }
+ return product;
+ });
+ dispatch(ChangeFullFreeProductList(updatedFreeProdList));
+ }
+ }
+ }
+ } else {
+ await handleNormalEditQuantity(
+ editedProduct,
+ editedProductIndex,
+ editedQty,
+ newPrice
+ );
+ }
+ }
+ };
+
+ const handleNormalEditQuantity = async (
+ editedProduct,
+ index,
+ qty,
+ newPrice = 0,
+ offerApply = false
+ ) => {
+ const updatedProduct = {
+ ...editedProduct,
+ OrderQty: qty,
+ OrderRate: newPrice > 0 ? newPrice : editedProduct?.OrderRate,
+ ...calculateTaxAmounts({
+ qty: qty,
+ rate: newPrice > 0 ? newPrice : editedProduct?.OrderRate,
+ taxPercentage: editedProduct?.TaxPercentage,
+ type: editedProduct?.Type,
+ product: editedProduct,
+ }),
+ PackageDtl: PackageDtl,
+ // ✅ FIXED: Proper conditional property assignment
+ ...(offerApply && {
+ Offer: qty * (newPrice > 0 ? newPrice : editedProduct?.OrderRate),
+ }),
+ };
+
+ if (hasOffer) {
+ const offers = validateOffers(
+ updatedProduct,
+ OverAllproductBasedOfferDatas,
+ CartOrderDetails,
+ TakAwayId,
+ DineinId
+ );
+ if (!offers?.length) {
+ if (updatedProduct?.OfferType && updatedProduct?.Offer > 0) {
+ dispatch(
+ RemoveOfferAppliedProduct({
+ ProdId: updatedProduct?.ProdId,
+ InwardDtlId: updatedProduct?.InwardDtlId,
+ OfferType: updatedProduct?.OfferType,
+ })
+ );
+ }
+ dispatch(
+ changeOrderCardDetails(
+ CartOrderDetails?.map((i) =>
+ i?.InwardDtlId == updatedProduct?.InwardDtlId &&
+ i?.BookingTypeName == updatedProduct?.BookingTypeName &&
+ i?.localId === updatedProduct?.localId
+ ? {
+ ...updatedProduct,
+ Offer: 0,
+ OfferType:
+ updatedProduct?.Type === 'C'
+ ? updatedProduct?.OfferType
+ : null,
+ OfferMessage: null,
+ }
+ : i
+ )
+ )
+ );
+ return;
+ }
+
+ let bestOffer = null;
+ for (const offer of offers) {
+ if (!bestOffer || offer.OfferAmount > bestOffer.OfferAmount) {
+ bestOffer = offer;
+ }
+ }
+
+ const UpdatedCartItemWithOffer = {
+ ...updatedProduct,
+ Offer:
+ bestOffer?.OfferMode === 'I' || bestOffer?.OfferMode === 'Q'
+ ? bestOffer?.OfferAmount || updatedProduct.Offer
+ : updatedProduct.Offer || bestOffer?.OfferAmount,
+ OfferType: updatedProduct?.OfferType || bestOffer?.OfferType,
+ OfferMessage: updatedProduct?.OfferMessage || bestOffer?.OfferMessage,
+ };
+
+ console.log(updatedProduct, 'updatedProduct');
+
+ const shouldRemove = (c) =>
+ c.ProdId === updatedProduct.ProdId &&
+ c.InwardDtlId === updatedProduct.InwardDtlId &&
+ c.OrderRate === updatedProduct.OrderRate &&
+ c.BookingTypeName === updatedProduct.BookingTypeName &&
+ !c.SalesId &&
+ ((c?.OfferModeType && c?.OfferMode === 'B'
+ ? true
+ : c?.OfferMode !== 'B') &&
+ c?.OfferMode !== 'P' &&
+ c?.OfferMode !== 'C' &&
+ c?.OfferMode !== 'O' &&
+ c?.OfferMode !== 'L'
+ ? true
+ : c?.Offer === 0);
+
+ const filteredCart = CartOrderDetails?.filter((c) => !shouldRemove(c));
+ const updatedCartData = [UpdatedCartItemWithOffer, ...filteredCart];
+
+ if (bestOffer) {
+ dispatch(ChangeOfferAppliedProducts(bestOffer));
+ }
+
+ dispatch(changeOrderCardDetails(updatedCartData));
+ } else {
+ const updatedData = [...CartOrderDetails];
+ updatedData[index] = updatedProduct;
+ dispatch(changeOrderCardDetails(updatedData));
+ }
+ };
+
+ const calculateTaxAmounts = ({
+ qty,
+ rate,
+ taxPercentage,
+ type = null,
+ product = {},
+ isOfferApply = false,
+ }) => {
+ const { OfferType = null, OfferPrice = 0 } = product;
+ const totalAmount = qty * rate;
+ const taxAmount = (
+ (totalAmount * taxPercentage) /
+ (100 + taxPercentage)
+ ).toFixed(2);
+ const withoutTaxRate = (totalAmount - taxAmount).toFixed(2);
+ const offerValue =
+ type === 'C'
+ ? OfferType === 'F'
+ ? qty * OfferPrice
+ : (qty * rate * OfferPrice) / 100
+ : null;
+
+ return {
+ TotalAmt:
+ type === 'C' && OfferPrice > 0
+ ? totalAmount - (offerValue || 0)
+ : totalAmount,
+ TaxAmt: parseFloat(taxAmount),
+ WithoutTaxRate: parseFloat(withoutTaxRate),
+ OfferValue: offerValue,
+ };
+ };
+
+ const onComplete = useCallback(() => {
+ setMessageData(null);
+ setMessageType(null);
+ }, []);
+
+ const SellingPriceChange = (data) => {
+ if (props.Productdata?.Offer > 0) {
+ setMessageData(
+ 'You cant Change Price Because You Applied Offer This Product'
+ );
+ setMessageType('error');
+ setDisableSubmitButton(true);
+ return;
+ }
+ if (data?.target.value) {
+ const sellingPrice = parseFloat(props.Productdata?.SellingPrice || 0);
+ const limit = parseFloat(props.Productdata?.DiscountLimit || 0);
+ const limitType = props.Productdata?.DiscountLimitType;
+ const enteredDiscount = parseFloat(data?.target.value);
+
+ if (limit === null || limit === undefined || limit === 0) {
+ 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();
+ }
+ return;
+ }
+
+ let maxDiscount = 0;
+ if (limitType === 'F') {
+ maxDiscount = limit;
+ } else if (limitType === 'P') {
+ const afterdiscountfullamount = (sellingPrice * limit) / 100;
+ maxDiscount = afterdiscountfullamount;
+ }
+
+ if (enteredDiscount === maxDiscount) {
+ setEditedPrice(data?.target.value);
+ setDisableSubmitButton(true);
+ return;
+ }
+
+ if (enteredDiscount < maxDiscount) {
+ setMessageType('error');
+ setMessageData(`You cannot sell below ₹${maxDiscount.toFixed(2)}`);
+ setEditedPrice(0);
+ setDisableSubmitButton(false);
+ return;
+ }
+ setDisableSubmitButton(true);
+ setEditedPrice(data?.target.value);
+ } else {
+ setDisableSubmitButton(false);
+ setEditedPrice(0);
+ }
+ };
+
+ const onRadioBtnChange = (data) => {
+ setRadioBtnSelection(data);
+ };
+
+ useEffect(() => {
+ const handleOutsideClick = (e) => {
+ if (
+ quantityInputRef.current &&
+ !quantityInputRef.current.contains(e.target) &&
+ priceChangeInputRef.current &&
+ !priceChangeInputRef.current.contains(e.target)
+ ) {
+ setIndex(null);
+ setEditQtyCombo(false);
+ setEditRateCombo(false);
+ }
+ };
+
+ document.addEventListener('mousedown', handleOutsideClick);
+ return () => {
+ document.removeEventListener('mousedown', handleOutsideClick);
+ };
+ }, []);
+
+ return (
+
+ );
+};
+export default ComboEditQtyAndRate;
diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/ComboSalesBillTable/ComboSalesBillTable.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/ComboSalesBillTable/ComboSalesBillTable.jsx
index e7530b9..f25d3f5 100644
--- a/src/Pages/BookingScreen/Components/BSBillingTables/ComboSalesBillTable/ComboSalesBillTable.jsx
+++ b/src/Pages/BookingScreen/Components/BSBillingTables/ComboSalesBillTable/ComboSalesBillTable.jsx
@@ -73,9 +73,9 @@ import {
} from '../../../../../Features/Offer/Offernew/BookingOffernew.js';
import { useRemoveProducts } from '../BSBillingTable3/RemoveCartWithOffer.jsx';
import { useUtilsComponent } from '../../../../../Services/utils.js';
-import ComboEditQty from '../ComboBillTableEdit/ComboEditQty.jsx';
import ComboEditRate from '../ComboBillTableEdit/ComboEditRate.jsx';
import CustomerPriceHistory from '../../UtillComponents/CustomerPriceHistory.jsx';
+import ComboEditQtyAndRate from '../ComboBillTableEdit/ComboEditQtyAndRate.jsx';
const ComboSalesBillTable = () => {
const { removeExtraCharge } = useUtilsComponent();
@@ -177,6 +177,10 @@ const ComboSalesBillTable = () => {
const [qtyEdit, setQtyEdit] = useState(false);
const qtyTdRef = useRef(null);
const qtyInputRef = useRef(null);
+ const [shortKeyMethod, setshortKeyMethod] = useState(null);
+ const [activeRowIndex, setActiveRowIndex] = useState(null);
+ const [activeColIndex, setActiveColIndex] = useState(null);
+ const tableRef = useRef(null);
const handleEditQTYcombo = () => {
if (!qtyEdit) {
@@ -268,7 +272,7 @@ const ComboSalesBillTable = () => {
const item = getSelectedItem();
if (!item) return;
- handleEditQuantity(item);
+ handleEditQuantityCombo(item);
setshortKeyMethod(method);
};
@@ -288,12 +292,17 @@ const ComboSalesBillTable = () => {
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);
@@ -2074,6 +2083,95 @@ const ComboSalesBillTable = () => {
...(tableDataDinein || []),
];
+ // Set last row as active when data changes
+ useEffect(() => {
+ if (combinedTableData?.length > 0 && activeRowIndex === null) {
+ setActiveRowIndex(combinedTableData.length - 1);
+ }
+ }, [combinedTableData?.length]);
+
+ // Table navigation
+ useEffect(() => {
+ const handleTableNav = (e) => {
+ if (EditQtyCombo || EditRateCombo) return;
+ if (!combinedTableData?.length || activeRowIndex === null) return;
+
+ const visibleCols =
+ tableOptions?.filter((opt) =>
+ ['Item', 'Quantity', 'Rate', 'Total'].includes(opt.OptionName)
+ ) || [];
+
+ // Arrow Up/Down - Row navigation
+ if (e.key === 'ArrowUp') {
+ e.preventDefault();
+ setActiveRowIndex((prev) => Math.max(0, prev - 1));
+ setActiveColIndex(null);
+ } else if (e.key === 'ArrowDown') {
+ e.preventDefault();
+ setActiveRowIndex((prev) =>
+ Math.min(combinedTableData.length - 1, prev + 1)
+ );
+ setActiveColIndex(null);
+ }
+ // Arrow Left/Right - Column navigation
+ else if (e.key === 'ArrowLeft') {
+ e.preventDefault();
+ if (activeColIndex === null) {
+ setActiveColIndex(visibleCols.length - 1);
+ } else {
+ setActiveColIndex((prev) => Math.max(0, prev - 1));
+ }
+ } else if (e.key === 'ArrowRight') {
+ e.preventDefault();
+ if (activeColIndex === null) {
+ setActiveColIndex(0);
+ } else {
+ setActiveColIndex((prev) =>
+ Math.min(visibleCols.length - 1, prev + 1)
+ );
+ }
+ }
+ // Tab - Move to next column
+ else if (e.key === 'Tab') {
+ e.preventDefault();
+ if (activeColIndex === null) {
+ setActiveColIndex(0);
+ } else {
+ const nextCol = activeColIndex + 1;
+ if (nextCol >= visibleCols.length) {
+ setActiveColIndex(0);
+ if (activeRowIndex < combinedTableData.length - 1) {
+ setActiveRowIndex((prev) => prev + 1);
+ }
+ } else {
+ setActiveColIndex(nextCol);
+ }
+ }
+ }
+ // Enter - Trigger cell action
+ else if (e.key === 'Enter' && activeColIndex !== null) {
+ e.preventDefault();
+ const row = combinedTableData[activeRowIndex];
+ const col = visibleCols[activeColIndex];
+ if (row && col && editField) {
+ if (col.OptionName === 'Quantity') handleEditQuantityCombo(row);
+ else if (col.OptionName === 'Rate') handleEditRateCombo(row);
+ }
+ }
+ };
+
+ window.addEventListener('keydown', handleTableNav);
+ return () => window.removeEventListener('keydown', handleTableNav);
+ }, [
+ activeRowIndex,
+ activeColIndex,
+ combinedTableData,
+ EditQtyCombo,
+ EditRateCombo,
+ editField,
+ tableOptions,
+ ]);
+
console.log(combinedTableData, 'combinedTableData', tableData);
const displayTableData =
BillOrderPre === 'N' ? [...combinedTableData].reverse() : combinedTableData;
@@ -2261,7 +2359,7 @@ const ComboSalesBillTable = () => {
return (
{
: 'none',
}}
>
- {tableOptions?.map((item) => (
- <>
- {/* HSN Code */}
- {item.OptionName === 'HSNCode' && (
- | editField && handleEditQuantity(row)}
- >
- {row.HSNCode || '-'}
- |
- )}
+ {tableOptions?.map((item, colIdx) => {
+ const isActiveCell =
+ activeRowIndex === index &&
+ activeColIndex !== null &&
+ ['Item', 'Quantity', 'Rate', 'Total'].indexOf(
+ item.OptionName
+ ) === activeColIndex;
- {/* Product Name / Item */}
- {(item.OptionName === 'Item' ||
- item.OptionName === 'Product Name') && (
+ return (
+ <>
+ {/* HSN Code */}
+ {item.OptionName === 'HSNCode' && (
- row.FullProductIdentifierDtls?.length > 0 ||
- row.ProductIdentifierDtls?.length > 0
- ? handleImeiDetails(row)
- : editField && handleEditQuantity(row)
- }
+ key={`hsn-${index}`}
+ className="hsnCodeTd"
+ onClick={() => 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.HSNCode || '-'}
|
)}
- {/* Barcode */}
- {item.OptionName === 'Barcode' && (
- editField && handleEditQuantity(row)}
- >
- {row.QRCode || '-'}
- |
- )}
+ {/* 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}
+
+ ))}
+ |
+ )}
- {/* Quantity */}
- {item.OptionName === 'Quantity' && (
- editField && handleEditQuantity(row)}
+ >
+ {row.QRCode || '-'}
+ |
+ )}
+
+ {/* Quantity */}
+ {item.OptionName === 'Quantity' && (
+ {
+ if (
+ shortKeyMethod === 'qty' &&
+ row?.localId === Index
+ ) {
+ el?.focus();
+ el?.click();
+ }
+ }}
+ key={`qty-${index}`}
+ tabIndex={0}
+ className={`${EditQtyCombo && row?.localId === Index
? 'EditQTYcomboTD'
: 'qtyTd'
- }
+ } ${isActiveCell ? 'active-cell' : ''}`}
onClick={() =>
editField && handleEditQuantityCombo(row)
}
- // onClick={() => handleEditQTYcombo()}
- >
- {(!EditQtyCombo || row?.localId !== Index) && (
- <>{row.OrderQty}>
- )}
- {EditQtyCombo && row?.localId === Index && (
-
+ {(!EditQtyCombo || row?.localId !== Index) && (
+ <>{row.OrderQty}>
+ )}
+ {EditQtyCombo && row?.localId === Index && (
+ {
Index={Index}
setIndex={setIndex}
setEditQtyCombo={setEditQtyCombo}
- // id={`qty-${index}`}
- />
- )}
- |
- )}
+ />
+ )}
+
+ )}
- {/* Rate */}
- {item.OptionName === 'Rate' && (
- editField && handleEditQuantity(row)}
- onClick={() => editField && handleEditRateCombo(row)}
- >
+ {/* Rate */}
+ {item.OptionName === 'Rate' && (
+ | editField && handleEditRateCombo(row)}
+ >
{!EditRateCombo || row?.localId !== Index ? (
- <>
- {allowDecimal
- ? Number(row?.OrderRate).toFixed(2)
- : Number(row?.OrderRate)}
- >
+ <>
+ {allowDecimal
+ ? Number(row?.OrderRate).toFixed(2)
+ : Number(row?.OrderRate)}
+ >
) : null}
- {EditRateCombo && row?.localId === Index && (
- {
Index={Index}
setIndex={setIndex}
setEditRateCombo={setEditRateCombo}
- />
- )}
- |
- )}
+ />
+ )}
+
+ )}
- {/* Disc % */}
- {item.OptionName === 'Discount' && (
- editField && handleEditQuantity(row)}
- >
- {row?.Offer > 0
- ? `${(
- (row.Offer / (row?.OrderQty * row?.OrderRate)) *
- 100
- ).toFixed(2)}%`
- : '-'}
- |
- )}
+ {/* Disc % */}
+ {item.OptionName === 'Discount' && (
+ editField && handleEditQuantity(row)}
+ >
+ {row?.Offer > 0
+ ? `${(
+ (row.Offer / (row?.OrderQty * row?.OrderRate)) *
+ 100
+ ).toFixed(2)}%`
+ : '-'}
+ |
+ )}
- {/* Disc Amt */}
- {item.OptionName === 'Amount' && (
- editField && handleEditQuantity(row)}
- >
- {row.Offer || '-'}
- |
- )}
+ {/* Disc Amt */}
+ {item.OptionName === 'Amount' && (
+ editField && handleEditQuantity(row)}
+ >
+ {row.Offer || '-'}
+ |
+ )}
- {/* Total */}
- {item.OptionName === 'Total' && (
- {
- // if (editField) {
- // handleEditQuantity(row)
- // }
- if (GetCustId) {
- handleCustomerProductPriceHistory(row);
- }
- }}
- >
- {allowDecimal
- ? Number(row.TotalAmt - (row?.Offer || 0)).toFixed(2)
- : Number(row.TotalAmt - (row?.Offer || 0))}
- |
- )}
-
- {/* Optional columns */}
- {item.OptionName === 'SalesMan' && (
-
- {row.salesMan || '-'}
- |
- )}
- {item.OptionName === '%' && (
-
- {row.percentage || '-'}
- |
- )}
- {item.OptionName === 'Commission' && (
-
- {row.commission || '-'}
- |
- )}
- {item.OptionName === 'StockId' && (
-
- {row.stockId || '-'}
- |
- )}
- {item.OptionName === 'Points' && (
-
- {row.points || '-'}
- |
- )}
-
- {/* Delete */}
- {item.OptionName === 'Delete' && (
-
- removeFromCart(row)}
- style={{
- color: '#FF4D4F',
- cursor: 'pointer',
- textAlign: 'center',
- width: '100%',
+ {/* Total */}
+ {item.OptionName === 'Total' && (
+ | {
+ // if (editField) {
+ // handleEditQuantity(row)
+ // }
+ if (GetCustId) {
+ handleCustomerProductPriceHistory(row);
+ }
}}
- />
- |
- )}
- >
- ))}
+ >
+ {allowDecimal
+ ? Number(row.TotalAmt - (row?.Offer || 0)).toFixed(
+ 2
+ )
+ : Number(row.TotalAmt - (row?.Offer || 0))}
+ |
+ )}
+
+ {/* Optional columns */}
+ {item.OptionName === 'SalesMan' && (
+
+ {row.salesMan || '-'}
+ |
+ )}
+ {item.OptionName === '%' && (
+
+ {row.percentage || '-'}
+ |
+ )}
+ {item.OptionName === 'Commission' && (
+
+ {row.commission || '-'}
+ |
+ )}
+ {item.OptionName === 'StockId' && (
+
+ {row.stockId || '-'}
+ |
+ )}
+ {item.OptionName === 'Points' && (
+
+ {row.points || '-'}
+ |
+ )}
+
+ {/* Delete */}
+ {item.OptionName === 'Delete' && (
+
+ removeFromCart(row)}
+ style={{
+ color: '#FF4D4F',
+ cursor: 'pointer',
+ textAlign: 'center',
+ width: '100%',
+ }}
+ />
+ |
+ )}
+ >
+ );
+ })}
);
})}
diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/ComboSalesBillTable/ComboSalesBillTable.scss b/src/Pages/BookingScreen/Components/BSBillingTables/ComboSalesBillTable/ComboSalesBillTable.scss
index ece0711..2840d01 100644
--- a/src/Pages/BookingScreen/Components/BSBillingTables/ComboSalesBillTable/ComboSalesBillTable.scss
+++ b/src/Pages/BookingScreen/Components/BSBillingTables/ComboSalesBillTable/ComboSalesBillTable.scss
@@ -28,7 +28,7 @@
}
tbody {
- > tr:last-child {
+ >tr:last-child {
background-color: #e5d434 !important;
position: sticky;
bottom: 0;
@@ -40,6 +40,16 @@
background-color: #e5d434;
}
+ &.active-row {
+ outline: 2px solid #1292ee;
+ outline-offset: -2px;
+ }
+
+ td.active-cell {
+ background-color: #1292ee !important;
+ color: #ffffff;
+ }
+
td {
padding: 4px 8px;
border: 1px solid #9c9c9c;
@@ -189,3 +199,14 @@
padding: 1px !important;
text-align: center;
}
+
+.focused-cell {
+ background-color: #fff3cd !important;
+ border: 2px solid #ffc107 !important;
+ box-shadow: 0 0 5px rgba(255, 193, 7, 0.5);
+}
+
+
+:where(.css-dev-only-do-not-override-mncuj7).ant-select-dropdown .ant-select-item-option-active:not(.ant-select-item-option-disabled) {
+ background-color: rgba(116, 107, 107, 0.356);
+}
\ No newline at end of file
diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/StandardTable/StandardTable.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/StandardTable/StandardTable.jsx
index 4708782..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,30 +262,40 @@ const StandardTable = () => {
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 (OrderCardDetail?.length > 0) {
- OpenEditTotalAmount();
+ const handleKeyDown = (event) => {
+ const key = event.key.toLowerCase();
+ // 👉 ALT + P → Open Edit Total Amount
+ if (event.altKey && key === 'p') {
+ event.preventDefault();
+ if (OrderCardDetail?.length > 0) {
+ OpenEditTotalAmount();
+ }
+ return;
}
- return;
- }
- // 👉 CTRL shortcuts
- if (!event.ctrlKey) return;
-
- if (key === 'q') {
- event.preventDefault();
- handleShortcut('qty');
- }
-
- if (key === 'e') {
- event.preventDefault();
- handleShortcut('price');
- }
- };
-
+ // 👉 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');
+ } 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/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}
+ >
+
+
+
+ {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)}
+ >
+
+

+
+
+
+
+ {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}
+ >
+
+
+
@@ -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)}
- >
-
-

-
-
-
-
- {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={
-
-
-
-
-
-
- {qtydata?.ProdName}
-
-
+
+
-
-
-
-
- {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={
-
-
-
-
-
-
- {qtydata?.ProdName}
-
-
+ handleCancel={CloseVarientModal}
+ >
+
+
+
+
-
-
-
-
- {qtydata?.ProductDetail?.[QtyIndex]?.Size}{' '}
- {onePeiceFlow
- ? 'PCS'
- : qtydata?.ProductDetail?.[QtyIndex]?.UomName}
-
-
+
-
-
+
+
+
+
+ {qtydata?.ProductDetail?.[QtyIndex]?.Size}{' '}
+ {onePeiceFlow
+ ? 'PCS'
+ : qtydata?.ProductDetail?.[QtyIndex]?.UomName}
+
+
- }
- handleCancel={CloseVarientModal}
- />
+
+
+
{isMobile && screenWidth <= 768 && (
{
const AllCategoryDatas = useSelector(GlobalCategorieData, shallowEqual);
const AllsubcatgoryDatas = useSelector(GlobalSubcategorieData, shallowEqual);
const RetailWSSalesType = useSelector(GlobalRetailWSSalesType, shallowEqual);
- // const CustDetails = SelectedCust ? SelectedCust : AddCustomerDetails?.[0];
- const BookingTypeBoth = useSelector(GlobalBookingTypeBoth);
+
const GPreOrderList = useSelector(GlobalPreOrderList, shallowEqual);
const [modelQty, setModelQty] = useState(false);
const [modelstock, setModelstock] = useState(false);
const [ModalVarient, setModalVarient] = useState(false);
const [QtyIndex, setQtyIndex] = useState(0);
const [VarientIndex, setVarientIndex] = useState(0);
- const [expModel, setexpModel] = useState(false);
const [prodexpir, setProdexpir] = useState(false);
- const [expVarModel, setexpVarModel] = useState(false);
- const [expStockModel, setexpStockModel] = useState(false);
const [initialRun, setInitialRun] = useState(false);
const [Item, setItem] = useState();
const [VarItem, setVarItem] = useState(0);
@@ -246,7 +238,10 @@ const BSItemCard = (props) => {
SelectedGlobalCardColorDetail,
shallowEqual
);
- const GetmultipleSearchDatas = useSelector(GlobalGetmultipleSearchDatas, shallowEqual)
+ const GetmultipleSearchDatas = useSelector(
+ GlobalGetmultipleSearchDatas,
+ shallowEqual
+ );
const SelectedCardFont = useSelector(SelectedGlobalCardFont, shallowEqual);
const CartOrderDetails = useSelector(GlobalOrderCardDetails, shallowEqual);
const SelectedDatas = useSelector(GlobalSelectedDatas, shallowEqual);
@@ -254,7 +249,7 @@ const BSItemCard = (props) => {
const WSProductdata = useSelector(GlobalWSProduct, shallowEqual);
const NewQrProductData = useSelector(GlobalNewQrProduct, shallowEqual);
const ReportholdData = useSelector(GlobalReorderHoldDetails, shallowEqual);
- console.log(GetmultipleSearchDatas, "GetmultipleSearchDatas")
+ console.log(GetmultipleSearchDatas, 'GetmultipleSearchDatas');
const ReorderProductData = useSelector(
GlobalReorderProductDetails,
shallowEqual
@@ -285,12 +280,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);
@@ -318,6 +312,13 @@ 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;
@@ -326,7 +327,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' &&
@@ -617,7 +618,7 @@ const BSItemCard = (props) => {
WithoutTaxRate:
availableFreeQty * item.OrderRate -
(availableFreeQty * item.OrderRate * item.TaxPercentage) /
- 100,
+ 100,
Offer: availableFreeQty * item.OrderRate,
};
@@ -666,7 +667,7 @@ const BSItemCard = (props) => {
((existingPaidItem.OrderQty + excessQty) *
item.OrderRate *
item.TaxPercentage) /
- 100,
+ 100,
};
ModifiedData.push(mergedPaidItem);
@@ -701,7 +702,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) {
@@ -721,11 +722,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,
@@ -751,10 +752,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]
@@ -934,6 +935,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);
@@ -941,13 +955,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(() => {
@@ -968,7 +978,7 @@ const BSItemCard = (props) => {
if (TableName === 'BuyXGetXOffers') return true;
}
);
- setfreeProductsOffers(filteredOffers);
+ // setfreeProductsOffers(filteredOffers);
getOffers();
}, [OrderOfferDetail]);
@@ -982,12 +992,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
@@ -996,7 +1001,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
: '';
@@ -1029,7 +1034,7 @@ const BSItemCard = (props) => {
useEffect(() => {
if (AppId && CompId && BranchId) {
fetchedit();
- GetmultipleSearchData()
+ GetmultipleSearchData();
}
// dispatch(changepreOrder(false)); Commented to Add Normal Produts After Adding the Combo Pack !!!!!! Dont Touch Without Shifayath Permission
@@ -1043,10 +1048,9 @@ const BSItemCard = (props) => {
};
try {
- const response = await dispatch(getmultipleSearch(data))
-
+ const response = await dispatch(getmultipleSearch(data));
} catch (error) {
- console.error("Get Search Terms Error:", error);
+ console.error('Get Search Terms Error:', error);
}
};
@@ -1065,9 +1069,10 @@ const BSItemCard = (props) => {
setNoSubcatCardData();
}
- if (ProductSearch?.length > 5 && GetmultipleSearchDatas.some(
- e => e.toLowerCase() === "qrcode"
- )) {
+ if (
+ ProductSearch?.length > 5 &&
+ GetmultipleSearchDatas.some((e) => e.toLowerCase() === 'qrcode')
+ ) {
setQuickAdd(true);
}
}, [ProductSearch, GetmultipleSearchDatas]);
@@ -1101,14 +1106,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
@@ -1155,14 +1160,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,
+ }
: {}),
};
@@ -1180,13 +1185,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);
}
};
@@ -1220,7 +1218,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]);
@@ -1228,7 +1229,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 {
@@ -1320,14 +1324,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);
@@ -1376,13 +1372,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
);
@@ -1391,9 +1387,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
);
@@ -1435,11 +1431,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
);
@@ -1448,9 +1444,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
);
@@ -1489,55 +1485,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 =
@@ -1562,7 +1509,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 (
@@ -1573,13 +1527,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
);
@@ -1587,11 +1541,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
);
@@ -1638,7 +1592,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;
}
}
@@ -1652,13 +1613,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
);
@@ -1667,9 +1628,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
);
@@ -1695,16 +1656,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,
@@ -1770,7 +1721,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);
@@ -1782,7 +1740,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(
@@ -1833,15 +1798,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
);
@@ -1849,11 +1814,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
);
@@ -1932,15 +1897,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
);
@@ -1948,11 +1913,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
);
@@ -2048,7 +2013,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);
}
}
@@ -2057,178 +2029,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');
@@ -2248,7 +2051,10 @@ const BSItemCard = (props) => {
Parameter === 'OnePeiceProduct' ? transformedItem : item;
setQtydata(modiffiedData);
if (modiffiedData.OverAllExpStatus === 'Y' && ExpiredProduct) {
- setexpModel(true);
+ openExpireModal({
+ title: 'Product Expires',
+ onOk: () => expFun(modiffiedData),
+ });
setItem(modiffiedData);
} else if (modiffiedData) {
setQtydata(modiffiedData);
@@ -2359,28 +2165,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) => {
@@ -2447,9 +2240,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)
);
@@ -2460,9 +2254,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)
);
@@ -2476,9 +2271,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)
)
@@ -2491,9 +2287,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)
)
@@ -2514,8 +2311,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
@@ -2541,8 +2338,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
@@ -2769,14 +2566,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
);
}
@@ -2825,9 +2622,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,
@@ -2842,9 +2642,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);
@@ -3159,7 +2960,6 @@ const BSItemCard = (props) => {
};
});
- console.log(Postdata, 'Postdata');
const response = await dispatch(
bulkpostdata({ ProdDetails: Postdata })
).unwrap();
@@ -3232,10 +3032,10 @@ const BSItemCard = (props) => {
return FreeProdList.map((f, i) =>
i === index
? {
- ...existing,
- ...newFreeProd,
- ProdVariantDetails: existing.ProdVariantDetails,
- }
+ ...existing,
+ ...newFreeProd,
+ ProdVariantDetails: existing.ProdVariantDetails,
+ }
: f
);
} else {
@@ -3305,7 +3105,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;
@@ -3863,7 +3663,7 @@ const BSItemCard = (props) => {
parseInt(totalSelectedProductQty || 0) +
parseInt(reorderComboConsumed || 0);
}
- } catch (_) { }
+ } catch (_) {}
let getCurrentProdDtl = orderDetails?.filter(
(a) => a?.ProdName === ProdName
);
@@ -4064,7 +3864,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 (
@@ -4100,7 +3900,7 @@ const BSItemCard = (props) => {
}, 0);
totalOrderQty =
parseInt(totalOrderQty || 0) + parseInt(comboConsumed || 0);
- } catch (_) { }
+ } catch (_) {}
let OverallProdQty = totalOrderQty - totalSelectedProductQty;
if (
parseInt(ItemQuantity) >
@@ -4186,7 +3986,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 (
@@ -4225,7 +4025,7 @@ const BSItemCard = (props) => {
}, 0);
totalOrderQty =
parseInt(totalOrderQty || 0) + parseInt(comboConsumed || 0);
- } catch (_) { }
+ } catch (_) {}
let OverallProdQty = totalOrderQty - totalSelectedProductQty;
if (
parseInt(ItemQuantity) >
@@ -4317,7 +4117,7 @@ const BSItemCard = (props) => {
parseInt(totalSelectedProductQty || 0) +
parseInt(reorderComboConsumed || 0);
}
- } catch (_) { }
+ } catch (_) {}
let getCurrentProdDtl = orderDetails?.filter(
(a) => a?.ProdId === ProdId && a?.InwardDtlId === InwardDtlId
);
@@ -4360,7 +4160,7 @@ const BSItemCard = (props) => {
}, 0);
totalOrderQty =
parseInt(totalOrderQty || 0) + parseInt(comboConsumed || 0);
- } catch (_) { }
+ } catch (_) {}
let OverallProdQty = totalOrderQty - totalSelectedProductQty;
if (
@@ -4444,7 +4244,7 @@ const BSItemCard = (props) => {
parseInt(totalSelectedProductQty || 0) +
parseInt(reorderComboConsumed || 0);
}
- } catch (_) { }
+ } catch (_) {}
let getCurrentProdDtl = orderDetails?.filter(
(a) => a?.ProdId === ProdId && a?.InwardDtlId === InwardDtlId
);
@@ -4491,7 +4291,7 @@ const BSItemCard = (props) => {
}, 0);
totalOrderQty =
parseInt(totalOrderQty || 0) + parseInt(comboConsumed || 0);
- } catch (_) { }
+ } catch (_) {}
let OverallProdQty = totalOrderQty - totalSelectedProductQty;
if (
@@ -4669,7 +4469,7 @@ const BSItemCard = (props) => {
0 ||
- record.StockCount === 'Stock Not Maintained'
+ record.StockCount === 'Stock Not Maintained'
? { color: '#000', cursor: 'pointer' }
: { color: '#f49898', cursor: 'not-allowed' }
}
@@ -4699,7 +4499,7 @@ const BSItemCard = (props) => {
0 ||
- record.StockCount === 'Stock Not Maintained'
+ record.StockCount === 'Stock Not Maintained'
? { color: '#000', cursor: 'pointer' }
: { color: '#f49898', cursor: 'not-allowed' }
}
@@ -4729,7 +4529,7 @@ const BSItemCard = (props) => {
0 ||
- record.StockCount === 'Stock Not Maintained'
+ record.StockCount === 'Stock Not Maintained'
? { color: '#000', cursor: 'pointer' }
: { color: '#f49898', cursor: 'not-allowed' }
}
@@ -4904,17 +4704,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,
@@ -4936,20 +4736,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:
@@ -5321,6 +5121,7 @@ const BSItemCard = (props) => {
}, []);
const expFun = (item) => {
+ console.log(item, 'itemitemitemitemitemitemitemitem');
let count = item?.ProductDetail?.length;
if (count > 1) {
Quantity();
@@ -5328,7 +5129,8 @@ const BSItemCard = (props) => {
setVarItem(0);
SingleQuantity(item, onePeiceFlow);
}
- setexpModel(false);
+
+ closeExpireModal();
setProdexpir(true);
setQtydata(item);
};
@@ -5434,7 +5236,7 @@ const BSItemCard = (props) => {
setQtyIndex(selectedProIndex);
setRepeatedModel(true);
- setExpQtyModel(false);
+ closeExpireModal();
};
const expVerFun = (item) => {
@@ -5451,12 +5253,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 = () => {
@@ -5488,18 +5290,6 @@ 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();
const ExpDate = useSelector(GlobalExpDateforHeight);
@@ -6109,9 +5899,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';
@@ -6145,13 +5935,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);
@@ -6171,8 +5961,8 @@ const BSItemCard = (props) => {
CardOnclick(
result?.[0],
result?.[0]?.OnePcsAvailable === 'Y' &&
- preferenceSingleSales &&
- 'OnePeiceProduct'
+ preferenceSingleSales &&
+ 'OnePeiceProduct'
);
// AddOrderDetails2(result?.[0])
} else if (item?.OverAllQty < prodQty) {
@@ -6231,8 +6021,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'
: '',
}}
@@ -6311,21 +6101,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'
}
@@ -6363,39 +6153,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:
@@ -6428,19 +6218,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'
@@ -6452,8 +6242,8 @@ const BSItemCard = (props) => {
CardOnclick(
item,
item?.OnePcsAvailable === 'Y' &&
- preferenceSingleSales &&
- 'OnePeiceProduct'
+ preferenceSingleSales &&
+ 'OnePeiceProduct'
);
}
}}
@@ -6462,39 +6252,39 @@ const BSItemCard = (props) => {
>
{(cardFunction?.BigImage ||
cardFunction?.SmallImage) && (
-
- )}
+ ? item?.ProductDetail?.[0]
+ ?.ProdLogo
+ : defaultimage
+ }
+ alt=""
+ />
+ )}
{
cardFunction?.Background &&
(SelectedCardColor
? SelectedCardColor?.[
- 'BackgroundColor'
- ]
+ 'BackgroundColor'
+ ]
: ''),
position: !cardFunction?.BigImage
@@ -6528,7 +6318,7 @@ const BSItemCard = (props) => {
height: cardFunction?.SmallImage
? '5.5rem'
: !cardFunction?.BigImage &&
- '5.5rem',
+ '5.5rem',
alignItems:
!cardFunction?.BigImage &&
!cardFunction?.SmallImage &&
@@ -6551,11 +6341,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 &&
@@ -6577,24 +6367,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',
@@ -6633,8 +6423,8 @@ const BSItemCard = (props) => {
: '',
color: SelectedCardColor
? SelectedCardColor?.[
- 'FontColor'
- ]
+ 'FontColor'
+ ]
: '',
}}
>
@@ -6682,19 +6472,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}
>
@@ -6746,14 +6536,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',
}}
@@ -6795,39 +6585,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:
@@ -6845,19 +6635,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'
@@ -6869,48 +6659,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
@@ -6944,7 +6734,7 @@ const BSItemCard = (props) => {
height: cardFunction?.SmallImage
? '5.5rem'
: !cardFunction?.BigImage &&
- '4.5rem',
+ '4.5rem',
alignItems:
!cardFunction?.BigImage &&
!cardFunction?.SmallImage &&
@@ -6964,11 +6754,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 &&
@@ -6990,24 +6780,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',
@@ -7046,8 +6836,8 @@ const BSItemCard = (props) => {
: '',
color: SelectedCardColor
? SelectedCardColor?.[
- 'FontColor'
- ]
+ 'FontColor'
+ ]
: '',
}}
>
@@ -7092,19 +6882,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}
>
@@ -7155,14 +6945,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',
}}
@@ -7177,21 +6967,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'
}
@@ -7214,17 +7004,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'
)
@@ -7239,8 +7029,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
}
@@ -7282,7 +7072,7 @@ const BSItemCard = (props) => {
height={60}
src={
item?.ProductDetail?.[0]?.ProdLogo ===
- ''
+ ''
? defaultimage
: item?.ProductDetail?.[0]?.ProdLogo
? item?.ProductDetail?.[0]?.ProdLogo
@@ -7297,21 +7087,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 */}
@@ -7377,17 +7167,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}
>
@@ -7436,13 +7226,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',
}}
@@ -7458,64 +7248,62 @@ const BSItemCard = (props) => {
>
- )
-
-
- : ProductSearch?.length > 5 && GetmultipleSearchDatas.some(
- e => e.toLowerCase() === "qrcode"
+ ) : ProductSearch?.length > 5 &&
+ GetmultipleSearchDatas.some(
+ (e) => e.toLowerCase() === 'qrcode'
) &&
- (cardData?.length == 0 || cardData == undefined) ? (
-
- {/* cardData mohan 18-04-2025 */}
-
-
- ) : (
- <>
-
-
-
-
-
-
-
+ (cardData?.length == 0 || cardData == undefined) ? (
+
+ {/* cardData mohan 18-04-2025 */}
+
+
+ ) : (
+ <>
+
+ >
+ )}
{paymentloader === true && (
-
-
-
-
+
+
+
-
-
+
-
-
+
-
-
+
{' '}
@@ -7532,107 +7320,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 && (
@@ -7923,16 +7623,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/BsBookingitemCard.jsx b/src/Pages/BookingScreen/Components/BSItemCards/BsBookingitemCard.jsx
index cd14777..2755054 100644
--- a/src/Pages/BookingScreen/Components/BSItemCards/BsBookingitemCard.jsx
+++ b/src/Pages/BookingScreen/Components/BSItemCards/BsBookingitemCard.jsx
@@ -1,19 +1,15 @@
import React, { useCallback, useEffect, useRef, useState } from 'react';
import { shallowEqual, useDispatch, useSelector } from 'react-redux';
-import moment from 'moment';
-import { App, Badge, DatePicker, Modal, Tooltip, Form, message } from 'antd';
-import { GoTriangleRight } from 'react-icons/go';
+import { Badge, DatePicker, Modal, Tooltip, message } from 'antd';
import { ExclamationCircleOutlined, PlusOutlined } from '@ant-design/icons';
import defaultimage from '../../../../Images/defaultItemImg.png';
import FormHeader from '../../../PageComponents/FormHeader';
import {
- GlobalPricingAppPricingName,
SelectedGlobalCardColorDetail,
SelectedGlobalCardFont,
StoredSessionData,
getTemplateData,
} from '../../../../Features/ThemeChange/ThemeChange';
-import { Tables } from '../../../../Components/Tables/Table';
import {
GlobalProductSubCategorie,
GlobalItemCard,
@@ -107,26 +103,13 @@ import { v4 as uuidv4 } from 'uuid';
// Dummy SortableCard component
import { useSortable } from '@dnd-kit/sortable';
import { CSS } from '@dnd-kit/utilities';
-import HuggingFaceVoiceForm from '../../../VoiceToText/VoiceToText.jsx';
import VoiceToTextItemCard from '../../../VoiceToText/VoiceToTextItemCard.jsx';
import { ExtractDateFormate } from '../../../../Services/Others.js';
import {
- changeFreeProductForLoyalty,
- ChangeFreeProductList,
- ChangeFullFreeProductList,
changeFullOfferAppliedProducts,
- ChangeOfferAppliedProducts,
- changeOfferAppliedProductsForLoyalty,
changeOfferAppliedProductsForMembership,
- changeTriggerOfferFree,
- getOfferinBooking,
- GlobalFreeProdList,
- GlobalOfferAppliedProducts,
- GlobalOverAllOfferAmt,
- GlobalTriggerOfferFree,
- RemoveOfferAppliedProduct,
+ GlobalOfferAppliedProducts
} from '../../../../Features/Offer/Offernew/BookingOffernew.js';
-import { validateOffers } from './ValidateOffer.jsx';
import { useSaleswiseOfferWatcher } from './SalesWiseOffer.jsx';
import { ApplicationPreferences } from '../../../../Features/BrachLogin/BranchLogin.js';
import { useDateStore } from '../../../../Features/BookingScreen/BookingData/DateStore.js';
@@ -137,10 +120,7 @@ import dayjs from 'dayjs';
import BSCustomerSelect from '../UtillComponents/BSSelectCustomer.jsx';
import BSNavBarAddUser from '../UtillComponents/BSNavBarAddUser.jsx';
import { FaAngleLeft, FaAngleRight } from 'react-icons/fa';
-
import useRemoveFromCart from './RemoveFromCartFunction.jsx';
-
-import { IoIosAdd } from 'react-icons/io';
import { LuMinus } from 'react-icons/lu';
import BranchName from '../../Template/BranchName.jsx';
import { FiPlus } from 'react-icons/fi';
@@ -179,7 +159,7 @@ export function SortableCard({ id, children, item }) {
);
}
-const { RangePicker } = DatePicker;
+
const BsBookingitemCard = (props) => {
const voiceTriggerRef = useRef(null);
const unsubscribeRef = useRef(null);
@@ -191,14 +171,10 @@ const BsBookingitemCard = (props) => {
const handleDecline = async (item) => {
await decline(item, setPreviousdataLength);
};
- const handleClearAll = async () => {
- await clearAllItems();
- };
- const Clearall = async () => {
- await handleClearAll();
- };
- const [form] = Form.useForm();
+
+
+
const cardFunction = props?.cardFunctionality;
// const applyOffer = useApplyOfferto_CardDetail();
const preferenceDatas = useSelector(PreferenceData, shallowEqual);
diff --git a/src/Pages/BookingScreen/Components/BookingFunctionality/ExpireConfirmModal.jsx b/src/Pages/BookingScreen/Components/BookingFunctionality/ExpireConfirmModal.jsx
new file mode 100644
index 0000000..7bd2f3d
--- /dev/null
+++ b/src/Pages/BookingScreen/Components/BookingFunctionality/ExpireConfirmModal.jsx
@@ -0,0 +1,30 @@
+import { Modal } from 'antd';
+import { ExclamationCircleOutlined } from '@ant-design/icons';
+
+const ExpireConfirmModal = ({
+ open,
+ title,
+ onOk,
+ onCancel,
+ okText = 'Submit',
+ cancelText = "Don't Submit",
+}) => {
+ return (
+
+
+
+
{title}
+
+
+ );
+};
+
+export default ExpireConfirmModal;
diff --git a/src/Pages/BookingScreen/Components/PrintMainPage/SalesPrintSize.jsx b/src/Pages/BookingScreen/Components/PrintMainPage/SalesPrintSize.jsx
index d60d19e..5e4a320 100644
--- a/src/Pages/BookingScreen/Components/PrintMainPage/SalesPrintSize.jsx
+++ b/src/Pages/BookingScreen/Components/PrintMainPage/SalesPrintSize.jsx
@@ -1,436 +1,488 @@
-import { Switch, Tooltip } from "antd"
-import { useDispatch } from "react-redux";
-import { changeBillName, changeNotes, changeSelectedAmount, changeSelectedDiscount, changeSelectedHsnCode, changeSelectedItem, changeSelectedMRP, changeSelectedprintStyle, changeSelectedQrcode, changeSelectedQuantity, changeSelectedRate, changeSelectedSignature, changeSelectedSlNo, changeSelectedtermsAndConditions, changeSignatureImage, changethemeFormat, getPrintSelectionComponentData, putPrintSelectionComponentData, changeSelectedPrintdummyData } from "../../../../Features/ThemeChange/ThemeChange";
-import { useEffect, useState, useMemo, useCallback } from "react";
-import { InfoCircleOutlined, UploadOutlined, PlusOutlined, MinusCircleOutlined, ArrowRightOutlined, EditFilled, DeleteFilled } from '@ant-design/icons';
-import { getSession } from "../../../../Services/Others";
-import Buttons from "../../../../Components/Forms/Buttons";
-import { Messages } from "../../../../Components/Notifications/Messages";
-
+import { Switch, Tooltip } from 'antd';
+import { useDispatch } from 'react-redux';
+import {
+ changeBillName,
+ changeNotes,
+ changeSelectedAmount,
+ changeSelectedDiscount,
+ changeSelectedHsnCode,
+ changeSelectedItem,
+ changeSelectedMRP,
+ changeSelectedprintStyle,
+ changeSelectedQrcode,
+ changeSelectedQuantity,
+ changeSelectedRate,
+ changeSelectedSignature,
+ changeSelectedSlNo,
+ changeSelectedtermsAndConditions,
+ changeSignatureImage,
+ changethemeFormat,
+ getPrintSelectionComponentData,
+ putPrintSelectionComponentData,
+ changeSelectedPrintdummyData,
+} from '../../../../Features/ThemeChange/ThemeChange';
+import { useEffect, useState, useMemo, useCallback } from 'react';
+import {
+ InfoCircleOutlined,
+ UploadOutlined,
+ PlusOutlined,
+ MinusCircleOutlined,
+ ArrowRightOutlined,
+ EditFilled,
+ DeleteFilled,
+} from '@ant-design/icons';
+import { getSession } from '../../../../Services/Others';
+import Buttons from '../../../../Components/Forms/Buttons';
+import { Messages } from '../../../../Components/Notifications/Messages';
const SalesPrintSize = ({ onSettingsChange, closeModel }) => {
- const CompId = getSession("CompId")
- const BranchId = getSession("BranchId")
- const AppId = getSession("AppId")
- const UserId = getSession('UserId');
- const dispatch = useDispatch()
+ const CompId = getSession('CompId');
+ const BranchId = getSession('BranchId');
+ const AppId = getSession('AppId');
+ const UserId = getSession('UserId');
+ const dispatch = useDispatch();
- const [PrintType, setPrintType] = useState(false);
- const [PageSize, setPageSize] = useState(false);
- // const [PrintTemplates, setPrintTemplates] = useState([])
- const [SizeOptionData, setSizeOptionData] = useState([])
- const [selectedTemplate, setSelectedTemplate] = useState(null)
- const [messageType, setMessageType] = useState('')
- const [messageData, setMessageData] = useState('')
- console.log(selectedTemplate, 'selectedTemplate');
+ const [PrintType, setPrintType] = useState(false);
+ const [PageSize, setPageSize] = useState(false);
+ // const [PrintTemplates, setPrintTemplates] = useState([])
+ const [SizeOptionData, setSizeOptionData] = useState([]);
+ const [selectedTemplate, setSelectedTemplate] = useState(null);
+ const [messageType, setMessageType] = useState('');
+ const [messageData, setMessageData] = useState('');
+ console.log(selectedTemplate, 'selectedTemplate');
+ // Memoized values for better performance
+ const currentPrintType = useMemo(() => {
+ if (selectedTemplate) {
+ return selectedTemplate.PrintType === 'S' ? true : false;
+ }
+ return PrintType;
+ }, [selectedTemplate, PrintType]);
- // Memoized values for better performance
- const currentPrintType = useMemo(() => {
- if (selectedTemplate) {
- return selectedTemplate.PrintType === 'S' ? true : false;
- }
- return PrintType;
- }, [selectedTemplate, PrintType]);
+ const currentPageSize = useMemo(() => {
+ if (selectedTemplate) {
+ return selectedTemplate.PageSize === 'A5' ? true : false;
+ }
+ return PageSize;
+ }, [selectedTemplate, PageSize]);
- const currentPageSize = useMemo(() => {
- if (selectedTemplate) {
- return selectedTemplate.PageSize === 'A5' ? true : false;
- }
- return PageSize;
- }, [selectedTemplate, PageSize]);
+ // Get the actual values to pass to parent component
+ const getPrintTypeValue = () => {
+ if (selectedTemplate) {
+ return selectedTemplate.PrintType;
+ }
+ return PrintType ? 'S' : 'C';
+ };
- // Get the actual values to pass to parent component
- const getPrintTypeValue = () => {
- if (selectedTemplate) {
- return selectedTemplate.PrintType;
- }
- return PrintType ? 'S' : 'C';
- };
+ const getPageSizeValue = () => {
+ if (selectedTemplate) {
+ return selectedTemplate.PageSize;
+ }
+ return PageSize ? 'A5' : 'A4';
+ };
- const getPageSizeValue = () => {
- if (selectedTemplate) {
- return selectedTemplate.PageSize;
- }
- return PageSize ? 'A5' : 'A4';
- };
+ useEffect(() => {
+ printsyleget();
+ }, []);
- useEffect(() => {
- printsyleget()
- }, [])
+ // Auto-select default template when data loads
+ useEffect(() => {
+ if (SizeOptionData.length > 0) {
+ const defaultTemplate = SizeOptionData.find(
+ (template) => template.SetasDefault === 'Y'
+ );
+ if (defaultTemplate) {
+ handleTemplateSelect(defaultTemplate);
+ }
+ }
+ }, [SizeOptionData]);
- // Auto-select default template when data loads
- useEffect(() => {
- if (SizeOptionData.length > 0) {
- const defaultTemplate = SizeOptionData.find(template => template.SetasDefault === "Y");
- if (defaultTemplate) {
- handleTemplateSelect(defaultTemplate);
- }
- }
- }, [SizeOptionData]);
+ const handleTemplateSelect = (template) => {
+ setSelectedTemplate(template);
+ setPrintType(template.PrintType === 'S');
+ setPageSize(template.PageSize === 'A5');
+ stylePreview(template);
- const handleTemplateSelect = (template) => {
- setSelectedTemplate(template);
- setPrintType(template.PrintType === 'S');
- setPageSize(template.PageSize === 'A5');
- stylePreview(template);
+ // Immediately pass the template settings
+ if (onSettingsChange && typeof onSettingsChange === 'function') {
+ const currentSettings = {
+ PrintType: template.PrintType,
+ PageSize: template.PageSize,
+ selectedTemplate: template,
+ };
+ console.log('Template Selected - Settings:', currentSettings);
+ onSettingsChange(currentSettings);
+ }
+ };
- // Immediately pass the template settings
- if (onSettingsChange && typeof onSettingsChange === 'function') {
- const currentSettings = {
- PrintType: template.PrintType,
- PageSize: template.PageSize,
- selectedTemplate: template
- };
- console.log('Template Selected - Settings:', currentSettings);
- onSettingsChange(currentSettings);
- }
- };
+ const onChangeToggle = async (e) => {
+ setPrintType(e);
+ await dispatch(changethemeFormat(e));
- const onChangeToggle = async (e) => {
- setPrintType(e);
- await dispatch(changethemeFormat(e));
+ // If a template is selected, update it
+ if (selectedTemplate) {
+ const updatedTemplate = {
+ ...selectedTemplate,
+ PrintType: e ? 'S' : 'C',
+ };
+ setSelectedTemplate(updatedTemplate);
- // If a template is selected, update it
- if (selectedTemplate) {
- const updatedTemplate = {
- ...selectedTemplate,
- PrintType: e ? 'S' : 'C'
- };
- setSelectedTemplate(updatedTemplate);
-
- // Immediately pass updated settings
- if (onSettingsChange && typeof onSettingsChange === 'function') {
- const currentSettings = {
- PrintType: updatedTemplate.PrintType,
- PageSize: updatedTemplate.PageSize,
- selectedTemplate: updatedTemplate
- };
- onSettingsChange(currentSettings);
- }
- }
- };
-
- const onChangepageSize = async (e) => {
- setPageSize(e);
-
- // If a template is selected, update it
- if (selectedTemplate) {
- const updatedTemplate = {
- ...selectedTemplate,
- PageSize: e ? 'A5' : 'A4'
- };
- setSelectedTemplate(updatedTemplate);
- if (onSettingsChange && typeof onSettingsChange === 'function') {
- const currentSettings = {
- PrintType: updatedTemplate.PrintType,
- PageSize: updatedTemplate.PageSize,
- selectedTemplate: updatedTemplate
- };
- onSettingsChange(currentSettings);
- }
- }
- };
-
- const stylePreview = async (template) => {
- if (!template) return;
-
- const { StyleId, StyleName, PrintType: printType, PageSize, Notes, PrintHdrName, Signature, TermsandConditions, OptionDetails } = template;
-
- const helperFunction = (param) => {
- return OptionDetails.some(
- (item) => item.ConfigName === param
- )
- }
-
- dispatch(changeSelectedSlNo(helperFunction('Sl.No')));
- dispatch(changeSelectedItem(helperFunction('Item')));
- dispatch(changeSelectedMRP(helperFunction('MRP')));
- dispatch(changeSelectedDiscount(helperFunction('Discount')));
- dispatch(changeSelectedQuantity(helperFunction('Quantity')));
- dispatch(changeSelectedRate(helperFunction('Rate')));
- dispatch(changeSelectedAmount(helperFunction('Amount')));
- dispatch(changeSelectedHsnCode(helperFunction('HsnCode')));
- dispatch(changeSelectedQrcode(helperFunction('Qrcode')));
- dispatch(changeSelectedSignature(helperFunction('signature')));
- dispatch(changeSelectedtermsAndConditions(helperFunction('terms&conditions')));
- dispatch(changeNotes(helperFunction('Notes')));
- dispatch(changeSignatureImage(Signature));
- dispatch(changeBillName(PrintHdrName));
- dispatch(changeSelectedprintStyle({
- ConfigId: StyleId,
- ConfigName: StyleName,
- }));
- };
-
- const printsyleget = async () => {
- try {
- const Data = { AppId, CompId, BranchId };
- let response = await dispatch(getPrintSelectionComponentData(Data)).unwrap();
-
- if (response?.data?.statusCode === 1) {
- // const salesTemplates = response.data.data?.flatMap(template =>
- // (template.ComponentDetails || []).filter(comp => comp.PrintTypeName === "Sales" && comp.SetasDefault === "Y")
- // );
- // setPrintTemplates(salesTemplates);
-
- let TableData = response?.data?.data?.[0]?.ComponentDetails.map(
- (item) => ({
- ActiveStatus: 'A',
- OptionDetails: item.FieldDetails,
- StyleId: item.StyleId,
- SetasDefault: item.SetasDefault,
- SetasDefaultInvoice: item.SetasDefaultInvoice,
- StyleName: item.StyleName,
- Signature: item.Signature,
- PrintType: item.PrintType,
- PrintHdrName: item.PrintHdrName,
- Notes: item?.Notes,
- PageSize: item?.PageSize,
- PrintTypeId: item?.PrintTypeId,
- TermsandConditions: (item?.TermsandConditions
- ? item?.TermsandConditions
- : []
- )?.map((tc) => tc?.TermsandConditions),
- })
- )?.sort((a, b) => {
- if ((a.StyleName || '') === 'A4Standard') return 1;
- if ((b.StyleName || '') === 'A4Standard') return -1;
- const isA4orA5 = (name) => /A4|A5/i.test(name);
- const nameA = a.StyleName || '';
- const nameB = b.StyleName || '';
- if (isA4orA5(nameA) && !isA4orA5(nameB)) return 1;
- if (!isA4orA5(nameA) && isA4orA5(nameB)) return -1;
- const numA = parseInt(nameA.match(/\d+/)?.[0]) || 0;
- const numB = parseInt(nameB.match(/\d+/)?.[0]) || 0;
- return numA - numB;
- });
- setSizeOptionData(TableData);
- }
- } catch (error) {
- console.error('Error fetching print styles:', error);
- }
- };
-
- // Log current values for debugging
- console.log('Current PrintType:', getPrintTypeValue());
- console.log('Current PageSize:', getPageSizeValue());
- console.log('Selected Template:', selectedTemplate);
-
- useEffect(() => {
+ // Immediately pass updated settings
+ if (onSettingsChange && typeof onSettingsChange === 'function') {
const currentSettings = {
- PrintType: getPrintTypeValue(),
- PageSize: getPageSizeValue(),
- selectedTemplate
+ PrintType: updatedTemplate.PrintType,
+ PageSize: updatedTemplate.PageSize,
+ selectedTemplate: updatedTemplate,
};
- console.log('Current Print Settings:', currentSettings);
+ onSettingsChange(currentSettings);
+ }
+ }
+ };
- // Call the callback if provided
- if (onSettingsChange && typeof onSettingsChange === 'function') {
- onSettingsChange(currentSettings);
- }
- }, [selectedTemplate, PrintType, PageSize]); // Removed onSettingsChange from dependencies
+ const onChangepageSize = async (e) => {
+ setPageSize(e);
- // Also pass data when component mounts and when selectedTemplate changes
- useEffect(() => {
- if (selectedTemplate && onSettingsChange && typeof onSettingsChange === 'function') {
- const currentSettings = {
- PrintType: selectedTemplate.PrintType,
- PageSize: selectedTemplate.PageSize,
- selectedTemplate
- };
- console.log('Template-based Print Settings:', currentSettings);
- onSettingsChange(currentSettings);
- }
- }, [selectedTemplate]);
+ // If a template is selected, update it
+ if (selectedTemplate) {
+ const updatedTemplate = {
+ ...selectedTemplate,
+ PageSize: e ? 'A5' : 'A4',
+ };
+ setSelectedTemplate(updatedTemplate);
+ if (onSettingsChange && typeof onSettingsChange === 'function') {
+ const currentSettings = {
+ PrintType: updatedTemplate.PrintType,
+ PageSize: updatedTemplate.PageSize,
+ selectedTemplate: updatedTemplate,
+ };
+ onSettingsChange(currentSettings);
+ }
+ }
+ };
- const onfinish = async (values) => {
- try {
- if (!SizeOptionData || SizeOptionData.length === 0) {
- setMessageType('error');
- setMessageData('Please Setup the Screen');
- return;
- }
+ const stylePreview = async (template) => {
+ if (!template) return;
- if (!selectedTemplate) {
- setMessageType('error');
- setMessageData('Please select a template first');
- return;
- }
+ const {
+ StyleId,
+ StyleName,
+ PrintType: printType,
+ PageSize,
+ Notes,
+ PrintHdrName,
+ Signature,
+ TermsandConditions,
+ OptionDetails,
+ } = template;
-
- const currentPrintType = getPrintTypeValue(); // 'S' or 'C'
- const currentPageSize = getPageSizeValue(); // 'A4' or 'A5'
-
- // Only one "Sales" style should have SetasDefault: "Y"
- const updatedTemplates = SizeOptionData.map((item) => {
- if (
- (item.PrintType === "Sales" || item.PrintType === "S")
- ) {
- return {
- ...item,
- SetasDefault:
- item.StyleId === selectedTemplate.StyleId ? "Y" : "N",
- };
- }
- return item;
- });
-
- let TemplateDetails = updatedTemplates.map((item) => {
- const isSelectedTemplate = item.StyleId === selectedTemplate.StyleId;
-
- return {
- SizeId: null,
- StyleId: item.StyleId,
- SetasDefault: item.SetasDefault,
- SetasDefaultInvoice: item.SetasDefaultInvoice,
- PrintTypeId: item?.PrintTypeId,
- SizeDetails: item.OptionDetails.map((opt) => ({
- OptionId: opt.ConfigId,
- })),
- ...(item?.TermsandConditions?.length > 0
- ? {
- PrintTermsandConditions: (item?.TermsandConditions
- ? item?.TermsandConditions
- : []
- )?.map((tc) => ({
- TermsandConditions: tc,
- })),
- }
- : {}),
- ...(item?.Notes ? { Notes: item.Notes } : {}),
- PageSize: isSelectedTemplate ? currentPageSize : item?.PageSize,
- ...(item?.PrintHdrName ? { PrintHdrName: item.PrintHdrName } : {}),
- ...(item?.Signature ? { Signature: item?.Signature } : {}),
- PrintType: isSelectedTemplate ? currentPrintType : item?.PrintType,
- };
- });
-
- const Data = {
- CompId: CompId,
- BranchId: BranchId,
- AppId: AppId,
- TemplateDetails: TemplateDetails,
- CreatedBy: UserId,
- };
-
- // console.log('API Request Data:', Data);
-
- const response = await dispatch(
- putPrintSelectionComponentData(Data)
- ).unwrap();
-
- if (response?.data?.statusCode === 1) {
- dispatch(changeSelectedPrintdummyData(false));
- await printsyleget();
- setMessageType('success');
- setMessageData(response?.data?.response);
- if (closeModel) {
- closeModel();
- }
- }
- } catch (error) {
- console.error('Error setting default template:', error);
- setMessageType('error');
- setMessageData('Failed to set default template');
- }
+ const helperFunction = (param) => {
+ return OptionDetails.some((item) => item.ConfigName === param);
};
- const onComplete = useCallback(() => {
- setMessageData(null);
- setMessageType(null);
- }, []);
+ dispatch(changeSelectedSlNo(helperFunction('Sl.No')));
+ dispatch(changeSelectedItem(helperFunction('Item')));
+ dispatch(changeSelectedMRP(helperFunction('MRP')));
+ dispatch(changeSelectedDiscount(helperFunction('Discount')));
+ dispatch(changeSelectedQuantity(helperFunction('Quantity')));
+ dispatch(changeSelectedRate(helperFunction('Rate')));
+ dispatch(changeSelectedAmount(helperFunction('Amount')));
+ dispatch(changeSelectedHsnCode(helperFunction('HsnCode')));
+ dispatch(changeSelectedQrcode(helperFunction('Qrcode')));
+ dispatch(changeSelectedSignature(helperFunction('signature')));
+ dispatch(
+ changeSelectedtermsAndConditions(helperFunction('terms&conditions'))
+ );
+ dispatch(changeNotes(helperFunction('Notes')));
+ dispatch(changeSignatureImage(Signature));
+ dispatch(changeBillName(PrintHdrName));
+ dispatch(
+ changeSelectedprintStyle({
+ ConfigId: StyleId,
+ ConfigName: StyleName,
+ })
+ );
+ };
- return (
-
-
-
-
Print : {selectedTemplate?.StyleName}
-
-
-
- {(
-
-
- Customized
-
-
-
-
-
-
-
- Standard
-
-
-
-
-
- )}
-
-
-
- {currentPrintType && (
-
- A4
-
- A5
-
- )}
-
-
-
-
-
}
- htmlType={true}
- handleSubmit={onfinish}
- />
+ const printsyleget = async () => {
+ try {
+ const Data = { AppId, CompId, BranchId };
+ let response = await dispatch(
+ getPrintSelectionComponentData(Data)
+ ).unwrap();
+
+ if (response?.data?.statusCode === 1) {
+ // const salesTemplates = response.data.data?.flatMap(template =>
+ // (template.ComponentDetails || []).filter(comp => comp.PrintTypeName === "Sales" && comp.SetasDefault === "Y")
+ // );
+ // setPrintTemplates(salesTemplates);
+
+ let TableData = response?.data?.data?.[0]?.ComponentDetails.map(
+ (item) => ({
+ ActiveStatus: 'A',
+ OptionDetails: item.FieldDetails,
+ StyleId: item.StyleId,
+ SetasDefault: item.SetasDefault,
+ SetasDefaultInvoice: item.SetasDefaultInvoice,
+ StyleName: item.StyleName,
+ Signature: item.Signature,
+ PrintType: item.PrintType,
+ PrintHdrName: item.PrintHdrName,
+ Notes: item?.Notes,
+ PageSize: item?.PageSize,
+ PrintTypeId: item?.PrintTypeId,
+ TermsandConditions: (item?.TermsandConditions
+ ? item?.TermsandConditions
+ : []
+ )?.map((tc) => tc?.TermsandConditions),
+ })
+ )?.sort((a, b) => {
+ if ((a.StyleName || '') === 'A4Standard') return 1;
+ if ((b.StyleName || '') === 'A4Standard') return -1;
+ const isA4orA5 = (name) => /A4|A5/i.test(name);
+ const nameA = a.StyleName || '';
+ const nameB = b.StyleName || '';
+ if (isA4orA5(nameA) && !isA4orA5(nameB)) return 1;
+ if (!isA4orA5(nameA) && isA4orA5(nameB)) return -1;
+ const numA = parseInt(nameA.match(/\d+/)?.[0]) || 0;
+ const numB = parseInt(nameB.match(/\d+/)?.[0]) || 0;
+ return numA - numB;
+ });
+ setSizeOptionData(TableData);
+ }
+ } catch (error) {
+ console.error('Error fetching print styles:', error);
+ }
+ };
+
+ // Log current values for debugging
+ console.log('Current PrintType:', getPrintTypeValue());
+ console.log('Current PageSize:', getPageSizeValue());
+ console.log('Selected Template:', selectedTemplate);
+
+ useEffect(() => {
+ const currentSettings = {
+ PrintType: getPrintTypeValue(),
+ PageSize: getPageSizeValue(),
+ selectedTemplate,
+ };
+ console.log('Current Print Settings:', currentSettings);
+
+ // Call the callback if provided
+ if (onSettingsChange && typeof onSettingsChange === 'function') {
+ onSettingsChange(currentSettings);
+ }
+ }, [selectedTemplate, PrintType, PageSize]); // Removed onSettingsChange from dependencies
+
+ // Also pass data when component mounts and when selectedTemplate changes
+ useEffect(() => {
+ if (
+ selectedTemplate &&
+ onSettingsChange &&
+ typeof onSettingsChange === 'function'
+ ) {
+ const currentSettings = {
+ PrintType: selectedTemplate.PrintType,
+ PageSize: selectedTemplate.PageSize,
+ selectedTemplate,
+ };
+ console.log('Template-based Print Settings:', currentSettings);
+ onSettingsChange(currentSettings);
+ }
+ }, [selectedTemplate]);
+
+ const onfinish = async (values) => {
+ try {
+ if (!SizeOptionData || SizeOptionData.length === 0) {
+ setMessageType('error');
+ setMessageData('Please Setup the Screen');
+ return;
+ }
+
+ if (!selectedTemplate) {
+ setMessageType('error');
+ setMessageData('Please select a template first');
+ return;
+ }
+
+ const currentPrintType = getPrintTypeValue(); // 'S' or 'C'
+ const currentPageSize = getPageSizeValue(); // 'A4' or 'A5'
+
+ // Only one "Sales" style should have SetasDefault: "Y"
+ const updatedTemplates = SizeOptionData.map((item) => {
+ if (item.PrintType === 'Sales' || item.PrintType === 'S') {
+ return {
+ ...item,
+ SetasDefault: item.StyleId === selectedTemplate.StyleId ? 'Y' : 'N',
+ };
+ }
+ return item;
+ });
+
+ let TemplateDetails = updatedTemplates.map((item) => {
+ const isSelectedTemplate = item.StyleId === selectedTemplate.StyleId;
+
+ return {
+ SizeId: null,
+ StyleId: item.StyleId,
+ SetasDefault: item.SetasDefault,
+ SetasDefaultInvoice: item.SetasDefaultInvoice,
+ PrintTypeId: item?.PrintTypeId,
+ SizeDetails: item.OptionDetails.map((opt) => ({
+ OptionId: opt.ConfigId,
+ })),
+ ...(item?.TermsandConditions?.length > 0
+ ? {
+ PrintTermsandConditions: (item?.TermsandConditions
+ ? item?.TermsandConditions
+ : []
+ )?.map((tc) => ({
+ TermsandConditions: tc,
+ })),
+ }
+ : {}),
+ ...(item?.Notes ? { Notes: item.Notes } : {}),
+ PageSize: isSelectedTemplate ? currentPageSize : item?.PageSize,
+ ...(item?.PrintHdrName ? { PrintHdrName: item.PrintHdrName } : {}),
+ ...(item?.Signature ? { Signature: item?.Signature } : {}),
+ PrintType: isSelectedTemplate ? currentPrintType : item?.PrintType,
+ };
+ });
+
+ const Data = {
+ CompId: CompId,
+ BranchId: BranchId,
+ AppId: AppId,
+ TemplateDetails: TemplateDetails,
+ CreatedBy: UserId,
+ };
+
+ // console.log('API Request Data:', Data);
+
+ const response = await dispatch(
+ putPrintSelectionComponentData(Data)
+ ).unwrap();
+
+ if (response?.data?.statusCode === 1) {
+ dispatch(changeSelectedPrintdummyData(false));
+ await printsyleget();
+ setMessageType('success');
+ setMessageData(response?.data?.response);
+ if (closeModel) {
+ closeModel();
+ }
+ }
+ } catch (error) {
+ console.error('Error setting default template:', error);
+ setMessageType('error');
+ setMessageData('Failed to set default template');
+ }
+ };
+
+ const onComplete = useCallback(() => {
+ setMessageData(null);
+ setMessageType(null);
+ }, []);
+
+ return (
+
+
+
+
Print : {selectedTemplate?.StyleName}
+
+
+
+ {
+
+
+ Customized
+
+
+
+
+
+
+
+ Standard
+
+
+
+
+ }
- )
-}
-export default SalesPrintSize
\ No newline at end of file
+
+ {currentPrintType && (
+
+ A4
+
+ A5
+
+ )}
+
+
+
+
+ }
+ htmlType={true}
+ handleSubmit={onfinish}
+ />
+
+
+ );
+};
+
+export default SalesPrintSize;
diff --git a/src/Pages/BookingScreen/Components/PrintMainPage/SelectPrintMode.jsx b/src/Pages/BookingScreen/Components/PrintMainPage/SelectPrintMode.jsx
index f01016d..6be8c8e 100644
--- a/src/Pages/BookingScreen/Components/PrintMainPage/SelectPrintMode.jsx
+++ b/src/Pages/BookingScreen/Components/PrintMainPage/SelectPrintMode.jsx
@@ -1,215 +1,215 @@
-import { ArrowRightOutlined } from "@ant-design/icons";
-import Buttons from "../../../../Components/Forms/Buttons";
-import { gettableData, postPreferenceAppNames } from "../../../../Features/PreferenceMaster/PreferenceMaster";
-import { getSession } from "../../../../Services/Others";
-import { useDispatch } from "react-redux";
-import { useEffect, useState } from "react";
-import { getPreferenceData } from "../../../../Features/BookingScreen/BookingData/BookingData";
-import { Messages } from "../../../../Components/Notifications/Messages";
-import { changeSelectedPrintdummyData } from "../../../../Features/ThemeChange/ThemeChange";
+import { ArrowRightOutlined } from '@ant-design/icons';
+import Buttons from '../../../../Components/Forms/Buttons';
+import {
+ gettableData,
+ postPreferenceAppNames,
+} from '../../../../Features/PreferenceMaster/PreferenceMaster';
+import { getSession } from '../../../../Services/Others';
+import { useDispatch } from 'react-redux';
+import { useEffect, useState } from 'react';
+import { getPreferenceData } from '../../../../Features/BookingScreen/BookingData/BookingData';
+import { Messages } from '../../../../Components/Notifications/Messages';
+import { changeSelectedPrintdummyData } from '../../../../Features/ThemeChange/ThemeChange';
const SelectPrintMode = ({ closeModel }) => {
- const CompId = getSession("CompId");
- const BranchId = getSession("BranchId");
- const AppId = getSession("AppId");
- const UserId = getSession("UserId");
- const dispatch = useDispatch();
+ const CompId = getSession('CompId');
+ const BranchId = getSession('BranchId');
+ const AppId = getSession('AppId');
+ const UserId = getSession('UserId');
+ const dispatch = useDispatch();
- const [modes, setModes] = useState([]);
- const [selected, setSelected] = useState({
- whatsapp: false,
- sms: false,
- print: false,
- email: false
+ const [modes, setModes] = useState([]);
+ const [selected, setSelected] = useState({
+ whatsapp: false,
+ sms: false,
+ print: false,
+ email: false,
+ });
+ const [messageType, setMessageType] = useState('');
+ const [messageData, setMessageData] = useState('');
+
+ console.log(selected, 'selected');
+
+ useEffect(() => {
+ fetchTableData();
+ }, []);
+
+ const fetchTableData = async () => {
+ const response = await dispatch(
+ gettableData({ CompId, BranchId, AppId })
+ ).unwrap();
+
+ const data = response?.data?.data?.[0]?.SettingDtlDetails || [];
+ console.log(data, 'datadata');
+
+ setModes(data);
+
+ // Pre-fill checkboxes from API data
+ setSelected({
+ whatsapp: !!data.find(
+ (i) =>
+ i.SettingIdName?.trim()?.toLowerCase() === 'whatsapp' &&
+ i.SettingValue === 'Y'
+ ),
+ sms: !!data.find(
+ (i) =>
+ i.SettingIdName?.trim()?.toLowerCase() === 'sms' &&
+ i.SettingValue === 'Y'
+ ),
+ print: !!data.find(
+ (i) =>
+ i.SettingIdName?.trim()?.toLowerCase() === 'print' &&
+ i.SettingValue === 'Y'
+ ),
+ email: !!data.find(
+ (i) =>
+ i.SettingIdName?.trim()?.toLowerCase() === 'email' &&
+ i.SettingValue === 'Y'
+ ),
});
- const [messageType, setMessageType] = useState("");
- const [messageData, setMessageData] = useState("");
+ };
- console.log(selected, 'selected');
+ const handleChange = (key) => {
+ setSelected((prev) => ({
+ ...prev,
+ [key]: !prev[key],
+ }));
+ };
+ const handleSave = async () => {
+ const allowed = ['whatsapp', 'sms', 'print', 'email'];
- useEffect(() => {
- fetchTableData();
- }, []);
+ const updatedSettings = modes.map((item) => {
+ const name = item.SettingIdName?.trim()?.toLowerCase();
- const fetchTableData = async () => {
-
- const response = await dispatch(
- gettableData({ CompId, BranchId, AppId })
- ).unwrap();
-
- const data = response?.data?.data?.[0]?.SettingDtlDetails || [];
- console.log(data, 'datadata');
-
- setModes(data);
-
- // Pre-fill checkboxes from API data
- setSelected({
- whatsapp: !!data.find(
- (i) =>
- i.SettingIdName?.trim()?.toLowerCase() === "whatsapp" &&
- i.SettingValue === "Y"
- ),
- sms: !!data.find(
- (i) =>
- i.SettingIdName?.trim()?.toLowerCase() === "sms" &&
- i.SettingValue === "Y"
- ),
- print: !!data.find(
- (i) =>
- i.SettingIdName?.trim()?.toLowerCase() === "print" &&
- i.SettingValue === "Y"
- ),
- email: !!data.find(
- (i) =>
- i.SettingIdName?.trim()?.toLowerCase() === "email" &&
- i.SettingValue === "Y"
- )
- });
-
- };
-
- const handleChange = (key) => {
- setSelected((prev) => ({
- ...prev,
- [key]: !prev[key]
- }));
-
-
- };
-
-
- const handleSave = async () => {
- const allowed = ["whatsapp", "sms", "print", "email"];
-
- const updatedSettings = modes.map((item) => {
- const name = item.SettingIdName?.trim()?.toLowerCase();
-
- if (allowed?.includes(name)) {
- return {
- ...item,
- SettingValue: selected[name] ? "Y" : "N"
- };
- }
-
- return item;
-
- });
-
- const payload = {
- CompId,
- BranchId,
- CreatedBy: UserId,
- AppId,
- SettingDtlDetails: updatedSettings
+ if (allowed?.includes(name)) {
+ return {
+ ...item,
+ SettingValue: selected[name] ? 'Y' : 'N',
};
+ }
- console.log(payload, "payload to send");
+ return item;
+ });
- try {
- const response = await dispatch(postPreferenceAppNames(payload)).unwrap();
-
- if (response?.data?.statusCode === 1) {
- setMessageType("success");
- setMessageData("Printer settings saved successfully.");
- dispatch(changeSelectedPrintdummyData(false));
- await updatePreference();
- closeModel()
- } else {
- setMessageType("error");
- setMessageData(response?.data?.message || "Failed to save printer settings.");
- }
- } catch (error) {
- console.error("Error while saving:", error);
- }
+ const payload = {
+ CompId,
+ BranchId,
+ CreatedBy: UserId,
+ AppId,
+ SettingDtlDetails: updatedSettings,
};
- const updatePreference = async () => {
- await dispatch(getPreferenceData({ CompId, BranchId, AppId }));
+ console.log(payload, 'payload to send');
+
+ try {
+ const response = await dispatch(postPreferenceAppNames(payload)).unwrap();
+
+ if (response?.data?.statusCode === 1) {
+ setMessageType('success');
+ setMessageData('Printer settings saved successfully.');
+ dispatch(changeSelectedPrintdummyData(false));
+ await updatePreference();
+ closeModel();
+ } else {
+ setMessageType('error');
+ setMessageData(
+ response?.data?.message || 'Failed to save printer settings.'
+ );
+ }
+ } catch (error) {
+ console.error('Error while saving:', error);
}
+ };
- return (
-
-
{
- setMessageData(null);
- setMessageType(null);
- }}
- />
-
- Select Print Mode
-
+ const updatePreference = async () => {
+ await dispatch(getPreferenceData({ CompId, BranchId, AppId }));
+ };
-
-
+ return (
+
-
- }
- htmlType={true}
- handleSubmit={handleSave}
- />
-
-
- );
+
+ }
+ htmlType={true}
+ handleSubmit={handleSave}
+ />
+
+
+ );
};
export default SelectPrintMode;
diff --git a/src/Pages/BookingScreen/PrintTemplates/A4/TaxInvoice.jsx b/src/Pages/BookingScreen/PrintTemplates/A4/TaxInvoice.jsx
index 820889d..058627f 100644
--- a/src/Pages/BookingScreen/PrintTemplates/A4/TaxInvoice.jsx
+++ b/src/Pages/BookingScreen/PrintTemplates/A4/TaxInvoice.jsx
@@ -282,6 +282,7 @@ const TaxInvoice = ({
paginatedChunks.push(chunk);
}
}
+ console.log(paginatedChunks, "paginatedChunks")
const lastChunkRows =
paginatedChunks.length > 0
@@ -878,7 +879,7 @@ const TaxInvoice = ({
>
{Number(
table2Data?.OrderType !== 'E'
- ? item.Rate - item.ProdTaxAmt
+ ? item.Rate - (item?.SinglePc === 'Y' ? (item?.TaxAmt / item?.SalesQty) : item.ProdTaxAmt)
: item.Rate || 0
).toLocaleString('en-IN', {
minimumFractionDigits: 2,
diff --git a/src/Pages/BookingScreen/PrintTemplates/ThermalPrinter/OtherServicePrintStyle1.jsx b/src/Pages/BookingScreen/PrintTemplates/ThermalPrinter/OtherServicePrintStyle1.jsx
index 20b63d1..7559f21 100644
--- a/src/Pages/BookingScreen/PrintTemplates/ThermalPrinter/OtherServicePrintStyle1.jsx
+++ b/src/Pages/BookingScreen/PrintTemplates/ThermalPrinter/OtherServicePrintStyle1.jsx
@@ -1,120 +1,47 @@
-import React from "react";
+
import { useDispatch, useSelector } from "react-redux";
import {
- dateFormatChange1,
- extractLastNumber,
- extractLastNumberOrderId,
+ dateFormatChange1
} from "../../../../Services/Others";
import {
- GlobalprintSlNo,
- GlobalprintItem,
- GlobalprintMRP,
- GlobalprintDiscount,
- GlobalprintQuantity,
- GlobalprintRate,
- GlobalprintAmount,
- GlobalprintHsnCode,
- GlobalprintQrcodet,
GlobalPritdummyData,
changeReprintDataFound,
- GloabalFieldDetails,
- GlobalprintSignature,
- GlobalprinttermsAndConditions,
- GlobalSignatureImage,
- Globalnotes,
- GlobalthemeFormat,
- GlobalBillName,
} from "../../../../Features/ThemeChange/ThemeChange";
import "../../../../Styles/BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle1.scss";
import QRCode from "react-qr-code";
-import { GlobalUpiIDprint } from "../../../../Features/BookingScreen/BookingData/BookingData";
-import signature from "../../../../Images/signatureimage.jpg"
import { ApplicationPreferences } from "../../../../Features/BrachLogin/BranchLogin";
const OtherServicePrintStyle1 = ({
- index,
- totalQuantityFilter,
- Date1,
- CashierName,
- totalQuantity,
- OrderDetailGST,
- OrderDetailIGST,
- OrderDetailVAT,
+
table2Data,
- UpiId,
PaymentStatus,
- PrintLogo,
- PrintGreeting,
printDatas,
}) => {
const dispatch = useDispatch();
- const GlobalUpiID = useSelector(GlobalUpiIDprint);
- const FieldDetails = useSelector(GloabalFieldDetails);
- const SLNO = FieldDetails?.["Sl.No"];
- const Item = FieldDetails?.["Item"];
- const MRP = FieldDetails?.["MRP"];
- const Discount = FieldDetails?.["Discount"];
- const Quantity = FieldDetails?.["Quantity"];
- const Rate = FieldDetails?.["Rate"];
- const Amount = FieldDetails?.["Amount"];
- const HsnCode = FieldDetails?.["HsnCode"];
- const Qrcodet = FieldDetails?.["Qrcode"];
- const GlobalSlNo = useSelector(GlobalprintSlNo);
- const GlobalItem = useSelector(GlobalprintItem);
- const GlobalMRP = useSelector(GlobalprintMRP);
- const GlobalDiscount = useSelector(GlobalprintDiscount);
- const GlobalQuantity = useSelector(GlobalprintQuantity);
- const GlobalRate = useSelector(GlobalprintRate);
- const GlobalAmount = useSelector(GlobalprintAmount);
- const GlobalHsnCode = useSelector(GlobalprintHsnCode);
- const GlobalQrcodet = useSelector(GlobalprintQrcodet);
+
const GlobaldummyData = useSelector(GlobalPritdummyData);
- const GlobalSignature = useSelector(GlobalprintSignature);
- const GlobaltermsAndConditions = useSelector(GlobalprinttermsAndConditions);
- const GlobalSignatureImages = useSelector(GlobalSignatureImage);
- const GlobalIsnotes = useSelector(Globalnotes);
- const GlobalthemeFormatr = useSelector(GlobalthemeFormat)
- const GlobalBilltext = useSelector(GlobalBillName)
+
const appPreferences = useSelector(ApplicationPreferences);
const bookingTypePreference = appPreferences?.find((preference) => preference?.PreferredCatName === 'Booking Type')?.PreferenceCatDetails
- const dinePreference = bookingTypePreference?.find((type) => type?.PreferredSubCatName?.toLowerCase() === "dine in" && type?.PreferredStatus === 'Y')
+
const takeAwayPreference = bookingTypePreference?.find((type) => type?.PreferredSubCatName?.toLowerCase() === "take away" && type?.PreferredStatus === 'Y')
const keysLength = Object.keys(table2Data ?? {}).length;
- let TermsAndConditions = printDatas?.TermsandConditions
- let SignatureImg = printDatas?.Signature
- let Notestext = printDatas?.Notes
- let BillName = printDatas?.PrintHdrName
+
let FormatTheme = printDatas?.PrintType == "S" ? true : false
let PageSize = printDatas?.PageSize
- const Signature = FieldDetails?.["signature"];
- const TermsnAdCondition = FieldDetails?.["terms&conditions"];
+
console.log("table2Datatable2Datatable2Datatable2Data", table2Data,table2Data?.[0]?.BranchName );
if (keysLength > 0) {
dispatch(changeReprintDataFound(true));
}
- const currentDate = new Date();
- const day = currentDate.getDate().toString().padStart(2, "0");
- const monthNames = [
- "Jan",
- "Feb",
- "Mar",
- "Apr",
- "May",
- "Jun",
- "Jul",
- "Aug",
- "Sep",
- "Oct",
- "Nov",
- "Dec",
- ];
- const monthIndex = currentDate.getMonth();
- const year = currentDate.getFullYear().toString().slice(-2);
+
+
+
const formattedDate =dateFormatChange1(table2Data?.[0]?.CreatedDate);
// `${day}-${monthNames[monthIndex]}-${year}`;
@@ -125,37 +52,13 @@ console.log("table2Datatable2Datatable2Datatable2Data", table2Data,table2Data?.[
const DineInData = table2Data?.productDetails?.filter(
(item) => item.BookingTypeName?.toLowerCase() === "dine in"
);
- let PaymentStatusSuccess = PaymentStatus?.filter(
- (ps) => ps.PaymentStatus === "S"
- );
- const TakeawayTotal = TakeawayData?.reduce(
- (accumulator, currentValue) => accumulator + currentValue.TotalAmt,
- 0
- );
- const DineInTotal = DineInData?.reduce(
- (accumulator, currentValue) => accumulator + currentValue.TotalAmt,
- 0
- );
- const aggregatedPayments = PaymentStatusSuccess?.reduce(
- (acc, paymentdata) => {
- const paymentType = paymentdata?.PaymentTypeName;
- const amount = Number(paymentdata?.Amount);
- if (acc[paymentType]) {
- acc[paymentType] += amount;
- } else {
- acc[paymentType] = amount;
- }
- return acc;
- },
- {}
- );
- const productsData = table2Data?.productDetails || [];
+
const offers = table2Data?.OrderOfferDetails || [];
- let TotalOfferAmount = 0;
+
// Calculate SalesWiseOffers total amount
offers.forEach(offer => {
@@ -163,19 +66,9 @@ console.log("table2Datatable2Datatable2Datatable2Data", table2Data,table2Data?.[
TotalOfferAmount += offer.OfferAmount;
}
});
- const hasMappedOffer = offers.some(offer =>
- ["ItemWiseOffers", "BundleOffers", "QuantityWiseOffers"].includes(offer.TableName)
- );
+
- if (hasMappedOffer) {
-
- const productTotal = productsData?.reduce((acc, item) => acc + (item?.Type != "C" ? item.OfferAmt : item.OfferValue || 0), 0);
- TotalOfferAmount += productTotal;
- } else {
- const Combothere = productsData?.filter(item => item?.Type == "C")
- const CombothereTotal = Combothere?.reduce((acc, item) => acc + (item.OfferValue || 0), 0);
- TotalOfferAmount += CombothereTotal;
- }
+
const products = [
diff --git a/src/Pages/BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle1.jsx b/src/Pages/BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle1.jsx
index 4ff7674..36b226a 100644
--- a/src/Pages/BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle1.jsx
+++ b/src/Pages/BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle1.jsx
@@ -40,7 +40,6 @@ import {
} from '../../../../Features/BookingScreen/BookingData/BookingData';
import signature from '../../../../Images/signatureimage.jpg';
import { ApplicationPreferences } from '../../../../Features/BrachLogin/BranchLogin';
-import { settingDataSelector } from '../../../../Features/PreferenceMaster/PreferenceMaster';
import Logo from '../../../../Images/Logo.jpg';
const PrintStyle1 = ({
index,
diff --git a/src/Pages/DashBoard/Chart/GraphChart.jsx b/src/Pages/DashBoard/Chart/GraphChart.jsx
index 73eec74..96e2875 100644
--- a/src/Pages/DashBoard/Chart/GraphChart.jsx
+++ b/src/Pages/DashBoard/Chart/GraphChart.jsx
@@ -1,4 +1,4 @@
-import React, { useState, useEffect } from 'react';
+import { useState, useEffect } from 'react';
import { Tooltip } from 'antd';
import './GraphChart.scss'; // For styling
import TooltipWrapper from '../../../Components/Tooltip/Tooltip';
@@ -206,36 +206,7 @@ const GraphChart = ({ datasets }) => {
.join(' ');
};
- // const renderDots = (data, color) => {
- // const maxValue = Math.max(...data.map(item => item.value));
- // const svgHeight = 200;
- // const svgWidth = 400;
- // const gap = svgWidth / (data.length - 1);
- // return data.map((point, index) => {
- // const x = index * gap;
- // const y = svgHeight - (point.value / maxValue) * svgHeight;
-
- // return (
- //
- // handleMouseOver(e, point)}
- // onMouseOut={handleMouseOut}
- // />
- //
- // {formatValue(point.value)} ({item.date})
- //
- //
- // );
- // });
- // };
const renderDots = (data, color) => {
const reversedData = [...data].reverse();
@@ -507,7 +478,7 @@ const GraphChart = ({ datasets }) => {
- {Array.from({ length: 7 }, (_, i) => {
+ {Array.from({ length: 8 }, (_, i) => {
const date = new Date();
date.setDate(date.getDate() - i);
return (
diff --git a/src/Pages/DashBoard/Chart/GraphChart.scss b/src/Pages/DashBoard/Chart/GraphChart.scss
index f38181c..68680bd 100644
--- a/src/Pages/DashBoard/Chart/GraphChart.scss
+++ b/src/Pages/DashBoard/Chart/GraphChart.scss
@@ -73,7 +73,7 @@
width: inherit;
margin-top: 10px;
.labelss {
- font-size: 11px;
+ font-size: 10px;
font-family: 'Poppins';
color: #000000;
font-weight: 400;
diff --git a/src/Pages/DashBoard/PieChart.jsx b/src/Pages/DashBoard/PieChart.jsx
index 781822a..3a2d650 100644
--- a/src/Pages/DashBoard/PieChart.jsx
+++ b/src/Pages/DashBoard/PieChart.jsx
@@ -1,93 +1,4 @@
-// import React, { useEffect, useRef, useState } from 'react';
-// import Highcharts from 'highcharts';
-// import HighchartsReact from 'highcharts-react-official';
-// import "./PieChart.scss"
-// const DynamicPieChart = ({ chartData }) => {
-// const [overallValue, setOverallValue] = useState(0);
-// const chartRef = useRef();
-
-// useEffect(() => {
-// if (chartRef.current && chartData) {
-// const chart = chartRef.current.chart;
-// chart.series[0].setData(chartData);
-// const sum = chartData.reduce((total, dataPoint) => total + dataPoint.y, 0);
-// setOverallValue(sum);
-
-// // Update the chart title to include the overall value
-// chart.setTitle({ text: `Overall Amount: ${sum}` });
-// }
-// }, [chartData]);
-
-// return (
-//
-//
-//
-// );
-// };
-
-// export default DynamicPieChart;
-
-// import React, { useEffect, useRef, useState } from 'react';
-// import Highcharts from 'highcharts';
-// import HighchartsReact from 'highcharts-react-official';
-// import "./PieChart.scss"
-// const DynamicPieChart = ({ chartData }) => {
-// const [overallValue, setOverallValue] = useState(0);
-// const chartRef = useRef();
-
-// useEffect(() => {
-// if (chartRef.current && chartData) {
-// const chart = chartRef.current.chart;
-// chart.series[0].setData(chartData);
-// const sum = chartData.reduce((total, dataPoint) => total + dataPoint.y, 0);
-// setOverallValue(sum);
-
-// // Update the chart title to include the overall value
-// chart.setTitle({ text: `Overall Amount: ${sum}` });
-// }
-// }, [chartData]);
-
-// return (
-//
-//
-//
-// );
-// };
-
-// export default DynamicPieChart;
-
-// create by sree
-import React, { useMemo } from 'react';
+import { useMemo } from 'react';
import Highcharts from 'highcharts';
import HighchartsReact from 'highcharts-react-official';
import './PieChart.scss';
@@ -105,16 +16,25 @@ const DynamicPieChart = ({ chartData }) => {
);
if (!chartData?.length) {
- return
No Data Found
;
+ return (
+
+ No Data Found
+
+ );
}
return (
diff --git a/src/Pages/DashBoard/RetailDashboard.jsx b/src/Pages/DashBoard/RetailDashboard.jsx
index f677240..b38fb69 100644
--- a/src/Pages/DashBoard/RetailDashboard.jsx
+++ b/src/Pages/DashBoard/RetailDashboard.jsx
@@ -1,28 +1,26 @@
-import React, { useCallback, useEffect, useRef, useState } from 'react';
-import '../../Styles/DashBoard/RetailDashBoard.scss';
-import GraphChart from './Chart/GraphChart';
-import { DatePicker, Space, Tooltip } from 'antd';
-import dayjs from 'dayjs';
-import { IoMdRefresh } from 'react-icons/io';
-import { CiShop } from 'react-icons/ci';
-import { FiMenu } from 'react-icons/fi';
-import PozoMind from '../../Images/pozologowhite.svg';
+import { useCallback, useEffect, useRef, useState,lazy, Suspense } from 'react';
import { useNavigate, useOutletContext } from 'react-router-dom';
-import CalendarDropdown from '../../Components/CalendarDropdown';
-import { MdKeyboardArrowDown } from 'react-icons/md';
-import { IoMdNotificationsOutline } from 'react-icons/io';
-import {
- getdashboard,
- getdashboarddate,
- getpreOrderDashBoard,
- getSalesHdr,
- getTopSellingCustomers,
-} from '../../Features/RetailDashboard/Dashboard.js';
-import { FaTimesCircle } from 'react-icons/fa';
+import { shallowEqual, useDispatch } from 'react-redux';
+import { useSelector } from 'react-redux';
+
+import { DatePicker, Tooltip } from 'antd';
+import dayjs from 'dayjs';
+
+import '../../Styles/DashBoard/RetailDashBoard.scss';
+
+const GraphChart = lazy(() => import('./Chart/GraphChart'));
+const TopSellingProductsChart = lazy(
+ () => import('./TopSellingProductsChart.jsx')
+);
+
import sandClock from '../../Images/sandClock.png';
+import Add from '../../Images/dashboard/Add.png';
+import AddPurchase from '../../Images/dashboard/AddPurchase.png';
+import invoice from '../../Images/dashboard/invoice.png';
+import user from '../../Images/dashboard/user.jpg';
+import report from '../../Images/dashboard/report.png';
+
import {
- FeatureAddon,
- getTemplate,
GlobalPricingAppPricingName,
StoredSessionData,
} from '../../Features/ThemeChange/ThemeChange.js';
@@ -31,15 +29,20 @@ import {
getAppSubscriptionDate,
getPreferenceData,
} from '../../Features/BookingScreen/BookingData/BookingData.js';
+import {
+ getdashboard,
+ getdashboarddate,
+ getpreOrderDashBoard,
+ getSalesHdr,
+ getTopSellingCustomers,
+} from '../../Features/RetailDashboard/Dashboard.js';
import {
clearSession,
- dateFormatChange,
encryptedValuesUrlFun,
ExtractDateFormate,
getSession,
} from '../../Services/Others';
-import { shallowEqual, useDispatch } from 'react-redux';
-import { useSelector } from 'react-redux';
+
import {
getAllprodIds,
getExpireProductsList,
@@ -58,28 +61,36 @@ import {
PUTLoginuser,
} from '../../Features/BrachLogin/BranchLogin.js';
import { getPurchasedAppDetails } from '../../Features/BookingScreen/Pricing/Pricing.js';
-import Add from '../../Images/dashboard/Add.png';
-import AddPurchase from '../../Images/dashboard/AddPurchase.png';
-import invoice from '../../Images/dashboard/invoice.png';
-import user from '../../Images/dashboard/user.jpg';
-import report from '../../Images/dashboard/report.png';
-import Calendar from '../../Components/Calendar/Calendar';
-import { PiSignOut } from 'react-icons/pi';
-import BSNavBarUserInfo from '../BookingScreen/Components/BSNavbar/BSNavBarUserInfo';
-import { DefaultModal } from '../../Components/Modal/DefaultModal';
-import { RadioGrpButton } from '../../Components/Forms/RadioGroup.jsx';
-import { DropDowns } from '../../Components/Forms/DropDown.jsx';
+
+const BSNavBarUserInfo = lazy(() =>
+ import('../BookingScreen/Components/BSNavbar/BSNavBarUserInfo')
+);
+const DefaultModal = lazy(() =>
+ import('../../Components/Modal/DefaultModal').then((m) => ({
+ default: m.DefaultModal,
+ }))
+);
+
+const RadioGrpButton = lazy(() =>
+ import('../../Components/Forms/RadioGroup.jsx').then((m) => ({
+ default: m.RadioGrpButton,
+ }))
+);
+
+const DropDowns = lazy(() =>
+ import('../../Components/Forms/DropDown.jsx').then((m) => ({
+ default: m.DropDowns,
+ }))
+);
import {
ChangeRedirectStatus,
getEmpAccess,
GlobalRedirectStatus,
} from '../../Features/AppPage/CenterPage.js';
import { UserDataBasedOnBranchId } from '../../Features/Reports/Reports.js';
-import { gettableData } from '../../Features/PreferenceMaster/PreferenceMaster.js';
import Loader from '../../Components/Loader/Loader.jsx';
import { getUserProfile } from '../../Features/UserAccount/userData.js';
-import TopSellingProductsChart from './TopSellingProductsChart.jsx';
import { Messages } from '../../Components/Notifications/Messages.jsx';
const commonUrl = import.meta.env.ENV_COMMON_BASE_URL;
@@ -97,7 +108,6 @@ const RetailDashboard = () => {
const navigate = useNavigate();
const dispatch = useDispatch();
const { RangePicker } = DatePicker;
- const [selectedTab, setSelectedTab] = useState('dashboard');
const tabs = [
{ value: 'dashboard', label: 'Dashboard' },
{ value: 'top-selling-products', label: 'Top Selling Products' },
@@ -116,16 +126,7 @@ const RetailDashboard = () => {
]);
const [ismounted, setIsmounted] = useState(true);
const [customerPendingBalance, setcustomerPendingBalance] = useState([]);
- console.log(PricingAppPricingName, 'PricingAppPricingName');
- // const {
- // AppId: appId,
- // CompId: compId,
- // BranchId: branchId,
- // } = SessionData || {};
- // console.log(appId, compId, branchId, 'SessionData');
- const [range1, setRange1] = useState('today');
- const [range2, setRange2] = useState('today');
- const [range3, setRange3] = useState('today');
+
const [userprofile, setUserprofile] = useState(false);
const userProfileRef = useRef(null);
@@ -142,7 +143,6 @@ const RetailDashboard = () => {
const [totalPages, setTotalPages] = useState(0);
const [loading, setLoading] = useState(false);
const [products, setProducts] = useState([]);
- console.log(selection, 'selection');
const [CompBranchData, setCompBranchData] = useState();
const [EmpAcces, setEmpAccess] = useState();
const [seletedBranchData, setseletedBranchData] = useState(BranchId);
@@ -151,7 +151,6 @@ const RetailDashboard = () => {
BrLength == 1 ? null : 'all'
);
const [ApiData, setApiData] = useState([]);
- console.log(CompBranchData, 'CompBranchData');
const [Zero, SetZero] = useState(false);
const [ResponseData, setResponseData] = useState();
const [DateApiData, setDateApiData] = useState([]);
@@ -216,18 +215,7 @@ const RetailDashboard = () => {
type?.PreferredStatus === 'Y'
);
const timerDuration = 30;
- let EndDate = AppDetails?.[0]?.ValidityEnd;
- const isoDate = EndDate; // <-- July 24
- const date = new Date(isoDate);
-
- const options = { year: 'numeric', month: 'long', day: 'numeric' };
- const formatted = date.toLocaleDateString('en-US', options);
-
- // "July 24, 2025"
-
- console.log(expiredList, lowStockList, 'lowStockList');
- console.log(TopSellingCus, preorderData, 'preorderData');
let DineInData =
ApiData?.[0]?.ChartDtl?.map((item) => {
return {
@@ -441,10 +429,6 @@ const RetailDashboard = () => {
if (res?.data?.statusCode === 1 && res?.data?.data?.length > 0) {
const remaining = res?.data?.data?.[0];
- // let RemainingDays = expData?.RemainingDays;
- // let RemainingHours=expData?.RemainingHours;
- // let RemainingMinutes=expData?.RemainingMinutes;
- // let RemainingSeconds=expData?.RemainingSeconds
const now = new Date();
@@ -1075,39 +1059,6 @@ const RetailDashboard = () => {
getSalesHdrFn();
};
- // Function to aggregate data from multiple branches
- const aggregateBranchData = (branchDataArray) => {
- const aggregated = {
- DineInOrderCount: 0,
- TakeAwayOrderCount: 0,
- SelfTakeAwayOrderCount: 0,
- OverAllSalesAmt: 0,
- OverAllDineInAmount: 0,
- OverAllTakeAwayAmount: 0,
- ChartDtl: [],
- };
-
- branchDataArray.forEach((branchData) => {
- if (branchData) {
- aggregated.DineInOrderCount += branchData.DineInOrderCount || 0;
- aggregated.TakeAwayOrderCount += branchData.TakeAwayOrderCount || 0;
- aggregated.SelfTakeAwayOrderCount +=
- branchData.SelfTakeAwayOrderCount || 0;
- aggregated.OverAllSalesAmt += branchData.OverAllSalesAmt || 0;
- aggregated.OverAllDineInAmount += branchData.OverAllDineInAmount || 0;
- aggregated.OverAllTakeAwayAmount +=
- branchData.OverAllTakeAwayAmount || 0;
-
- // Merge chart data (you might want to customize this based on your needs)
- if (branchData.ChartDtl && branchData.ChartDtl.length > 0) {
- aggregated.ChartDtl = aggregated.ChartDtl.concat(branchData.ChartDtl);
- }
- }
- });
-
- return aggregated;
- };
-
// Helper functions for fetching data from all branches
const getpreOrderDashBoardFnAllBranches = async (FromDate, ToDate) => {
if (!CompBranchData || CompBranchData.length === 0) return;
@@ -1284,14 +1235,6 @@ const RetailDashboard = () => {
setApiData([]);
}
- // const allBranchData = await Promise.all(allBranchPromises);
-
- // // Aggregate the data from all branches
- // const aggregatedData = aggregateBranchData(allBranchData);
- // setDateApiData([aggregatedData]);
- // setApiData([aggregatedData]);
- // setPiedat([aggregatedData]);
-
// Also refresh other data for all branches with date range
getpreOrderDashBoardFnAllBranches(fromDate, toDate);
getTopBuyingCustomersAllBranches(fromDate, toDate);
@@ -1477,6 +1420,7 @@ const RetailDashboard = () => {
?.toUpperCase()}
{userprofile && (
+
{
}}
Logout={Logout}
/>
+
)}
@@ -1511,6 +1456,7 @@ const RetailDashboard = () => {
{/* Branch Filter Dropdown */}
{CompBranchData?.length > 1 && selection !== 'top-selling-products' && (
+ Loading...
}>
{
defaultValue="all"
placeholder="All Branches"
/>
+
)}
@@ -1537,14 +1484,6 @@ const RetailDashboard = () => {
className="datepickerDashboardrange"
inputReadOnly={true}
/>
- {/*
-
- {' '}
-
- Refresh
-
-
10sec auto refresh
-
*/}
{selection === 'dashboard' ? (
@@ -1553,7 +1492,9 @@ const RetailDashboard = () => {
@@ -2418,28 +2359,6 @@ const RetailDashboard = () => {
No Low Stock Product
)}
-
- {/*
-
2
-
-
- Cotton Blend Mandarin Collar Self One Design Kurta
-
-
-
4
-
-
-
3
-
-
- Cotton Blend Mandarin Collar Self One Design Kurta
-
-
-
1
-
*/}
- {/* */}
@@ -2448,106 +2367,110 @@ const RetailDashboard = () => {
>
) : (
<>
-
+
}>
+
+
>
)}
-
+
-
-
({
- value: option?.UserId,
- label: option?.UserName,
- }))}
- label={}
- className="field-DropDown"
- onChangeFunction={(e) => UserDropDownChange(e)}
- isOnchanges={selectedUserData ? true : false}
- valueData={selectedUserData}
- disabled={disabled}
- />
-
-
- ChangeMethod(e)}
- />
-
-
-
- {pinInput && (
-
- {[0, 1, 2, 3].map((i) => (
- (inputRefs.current[i] = el)}
- className="inputNumber"
- type="text"
- inputMode="numeric"
- pattern="[0-9]"
- maxLength={1}
- onChange={(e) => handleChange(i, e)}
- onKeyDown={(e) => handleKeyDown(i, e)}
- style={{
- textAlign: 'center',
- width: '40px',
- fontSize: '20px',
- }}
- />
- ))}
-
- )}
-
-
-
+ >
+ <>
+
+
({
+ value: option?.UserId,
+ label: option?.UserName,
+ }))}
+ label={}
+ className="field-DropDown"
+ onChangeFunction={(e) => UserDropDownChange(e)}
+ isOnchanges={selectedUserData ? true : false}
+ valueData={selectedUserData}
+ disabled={disabled}
+ />
+
+
+ Loading...
}>
+
ChangeMethod(e)}
+ />
+
- >
- }
- />
+
+ {pinInput && (
+
+ {[0, 1, 2, 3].map((i) => (
+ (inputRefs.current[i] = el)}
+ className="inputNumber"
+ type="text"
+ inputMode="numeric"
+ pattern="[0-9]"
+ maxLength={1}
+ onChange={(e) => handleChange(i, e)}
+ onKeyDown={(e) => handleKeyDown(i, e)}
+ style={{
+ textAlign: 'center',
+ width: '40px',
+ fontSize: '20px',
+ }}
+ />
+ ))}
+
+ )}
+
+
+
+
+
+ >
+
+
);
};
diff --git a/src/Pages/DashBoard/TopSellingProductsChart.jsx b/src/Pages/DashBoard/TopSellingProductsChart.jsx
index 28d81d9..cb8ca69 100644
--- a/src/Pages/DashBoard/TopSellingProductsChart.jsx
+++ b/src/Pages/DashBoard/TopSellingProductsChart.jsx
@@ -1,525 +1,561 @@
-import { useState, useEffect, useRef, useLayoutEffect, useMemo } from 'react';
-import { BarChart, Bar, PieChart, Pie, Cell, XAxis, YAxis, CartesianGrid, Legend, Tooltip, ResponsiveContainer } from 'recharts';
-import { TrendingUp, Package, IndianRupee, ChevronLeft, ChevronRight } from 'lucide-react';
+import {
+ useState,
+ useEffect,
+ useRef,
+ useLayoutEffect,
+ useMemo,
+ lazy,
+ Suspense,
+} from 'react';
+import { PieChart, Pie, Cell, Tooltip, ResponsiveContainer } from 'recharts';
+import { TrendingUp, Package, IndianRupee } from 'lucide-react';
import './TopSellingProductsChart.scss';
import { useDispatch } from 'react-redux';
-import { getTopSellingProduct } from '../../Features/ProductPage/ProductPage';
import { getSession } from '../../Services/Others';
import { changeBreadCrumb } from '../../Features/AppPage/CenterPage';
-import { Switch, DatePicker } from 'antd';
-import moment from 'moment';
-import dayjs from 'dayjs';
-import { DropDowns } from '../../Components/Forms/DropDown';
-const { RangePicker } = DatePicker;
+import dayjs from 'dayjs';
+
+const DropDowns = lazy(() =>
+ import('../../Components/Forms/DropDown').then((module) => ({
+ default: module.DropDowns,
+ }))
+);
const subDirectory = import.meta.env.BASE_URL;
const items = [
- {
- name: 'Home',
- link: `${subDirectory}app-page/home`,
- },
+ {
+ name: 'Home',
+ link: `${subDirectory}app-page/home`,
+ },
];
-const TopSellingProducts = ({ dates = [null, null], products = [], loading = false, totalPages, page = 1, setPage = () => { }, fetchProducts = () => { }, initialDate = true }) => {
+const TopSellingProducts = ({
+ dates = [null, null],
+ products = [],
+ loading = false,
+ totalPages,
+ page = 1,
+ setPage = () => {},
+ fetchProducts = () => {},
+ initialDate = true,
+}) => {
+ const today = new Date();
+ const year = today.getFullYear();
+ const month = today.getMonth();
- const today = new Date();
- const year = today.getFullYear();
- const month = today.getMonth();
+ const formatDate = (date) =>
+ `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`;
- const formatDate = (date) =>
- `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`;
+ const intialFromDate = `${year}-${String(month + 1).padStart(2, '0')}-01`;
+ const intialToDate = formatDate(today);
- const intialFromDate = `${year}-${String(month + 1).padStart(2, '0')}-01`;
- const intialToDate = formatDate(today);
+ const dispatch = useDispatch();
- const dispatch = useDispatch();
+ const AppId = getSession('AppId');
+ const CompId = getSession('CompId');
+ const BranchId = getSession('BranchId');
- const AppId = getSession('AppId');
- const CompId = getSession('CompId');
- const BranchId = getSession('BranchId');
+ const [chartType, setChartType] = useState('bar');
+ const [metric, setMetric] = useState('sales');
+ const chartWrapperRef = useRef(null);
+ const [containerWidth, setContainerWidth] = useState(800); // fallback
+ const [windowWidth, setWindowWidth] = useState(window.innerWidth);
+ const [hoveredItem, setHoveredItem] = useState(null);
+ const [mousePosition, setMousePosition] = useState({ x: 0, y: 0 });
- const [chartType, setChartType] = useState('bar');
- const [metric, setMetric] = useState('sales');
- const chartWrapperRef = useRef(null);
- const [containerWidth, setContainerWidth] = useState(800); // fallback
- const [windowWidth, setWindowWidth] = useState(window.innerWidth);
- const [hoveredItem, setHoveredItem] = useState(null);
- const [mousePosition, setMousePosition] = useState({ x: 0, y: 0 });
- const startIndex = (page - 1) * 10;
+ console.log(products?.[0]?.TotalCount, 'products');
- console.log(products?.[0]?.TotalCount, "products")
+ const options = useMemo(() => {
+ const total = products?.[0]?.TotalCount || 0;
+ const perPage = 10;
- const options = useMemo(() => {
- const total = products?.[0]?.TotalCount || 0;
- const perPage = 10;
+ const totalPages = Math.ceil(total / perPage);
- const totalPages = Math.ceil(total / perPage);
+ const arr = [];
- const arr = [];
+ for (let page = 1; page <= totalPages; page++) {
+ const start = (page - 1) * perPage + 1;
+ const end = Math.min(page * perPage, total);
- for (let page = 1; page <= totalPages; page++) {
- const start = (page - 1) * perPage + 1;
- const end = Math.min(page * perPage, total);
-
- arr.push({
- label: `${start}-${end}`,
- value: page
- });
- }
-
- return arr;
- }, [products?.[0]?.TotalCount]);
-
- useLayoutEffect(() => {
- if (!chartWrapperRef.current) return;
- const el = chartWrapperRef.current;
-
- // set initial width
- setContainerWidth(el.clientWidth || 800);
-
- // ResizeObserver to update container width precisely
- const ro = new ResizeObserver(entries => {
- for (const entry of entries) {
- const w = Math.floor(entry.contentRect.width);
- if (w && w !== containerWidth) setContainerWidth(w);
- }
- });
- ro.observe(el);
-
- return () => ro.disconnect();
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, [chartWrapperRef.current]);
- // breakpoints
- const mobileBreakpoint = 430; // you said < 430px is problematic
- const isNarrow = containerWidth <= mobileBreakpoint;
-
- // compute sizes based on actual container width
- // make pie fill a good portion of container (leave some padding)
- const pieOuterRadius = Math.max(48, Math.floor(containerWidth * (isNarrow ? 0.36 : 0.28)));
- const pieInnerRadius = Math.floor(pieOuterRadius * (isNarrow ? 0.5 : 0.55));
-
- // height for ResponsiveContainer: tether to containerWidth so chart stays proportional
- const responsiveHeight = Math.max(220, Math.floor(containerWidth * (isNarrow ? 0.62 : 0.5)));
-
- // tweak minAngle: small screens should allow smaller minAngle so slices remain visible
- const minAngle = isNarrow ? 4 : 8;
-
-
- console.log(pieOuterRadius, "pieOuterRadius")
-
- // const COLORS = ['#2563eb', '#7c3aed', '#db2777', '#ea580c', '#16a34a', '#0891b2', '#d97706', '#65a30d', '#4f46e5', '#0d9488'];
- const COLORS = [
- '#4f8df5', // lighter blue (was #2563eb)
- '#9a6df3', // lighter violet (was #7c3aed)
- '#e95b96', // lighter pink (was #db2777)
- '#f48b3c', // lighter orange (was #ea580c)
- '#34c86a', // lighter green (was #16a34a)
- '#33bcd4', // lighter cyan (was #0891b2)
- '#e39a1a', // lighter amber (was #d97706)
- '#8bc329', // lighter lime (was #65a30d)
- '#6d63ef', // lighter indigo (was #4f46e5)
- '#35bfa9' // lighter teal (was #0d9488)
- ];
-
- useEffect(() => {
- try {
- dispatch(changeBreadCrumb({ items: items }));
- } catch (error) {
- console.log(error?.message, 'error displaying breadcrumbs');
- }
- }, []);
-
- const handlePageChange = (data) => {
- setPage(prev => prev + data)
+ arr.push({
+ label: `${start}-${end}`,
+ value: page,
+ });
}
- const CustomTooltip = ({ active, payload }) => {
- if (active && payload && payload?.[0]) {
- const product = payload?.[0]?.payload;
- return (
-
-
{product?.ProdName} - {product?.UOMName}
- {(product?.BrandName) ?
Brand: {product?.BrandName}
: null}
-
-
Variants:
- {product?.variantDetails?.map((variant, idx) => (
-
- {variant?.ProdVariantName}:
-
- {variant?.SalesCount} sold | ₹{variant?.Revenue}
-
-
- ))}
-
-
-
- Total Sales:
- {product?.TotalSoldQty}
-
-
- Total Revenue:
- ₹{product?.TotalRevenue}
-
-
-
- );
- }
- return null;
- };
+ return arr;
+ }, [products?.[0]?.TotalCount]);
- const renderPercentInside = ({
- cx, cy, midAngle, innerRadius, outerRadius, percent, value
- }) => {
- const percentValue = Math.round(percent * 100);
- // hide labels for very small percentages on narrow screens
- if (percentValue < (isNarrow ? 3 : 2)) return null;
+ useLayoutEffect(() => {
+ if (!chartWrapperRef.current) return;
+ const el = chartWrapperRef.current;
- const RADIAN = Math.PI / 180;
- // place label inside slice (closer to inner radius on narrow screens)
- const radius = innerRadius + (outerRadius - innerRadius) * (isNarrow ? 0.55 : 0.6);
+ // set initial width
+ setContainerWidth(el.clientWidth || 800);
- const x = cx + radius * Math.cos(-midAngle * RADIAN);
- const y = cy + radius * Math.sin(-midAngle * RADIAN);
+ // ResizeObserver to update container width precisely
+ const ro = new ResizeObserver((entries) => {
+ for (const entry of entries) {
+ const w = Math.floor(entry.contentRect.width);
+ if (w && w !== containerWidth) setContainerWidth(w);
+ }
+ });
+ ro.observe(el);
- const fontSize = isNarrow ? 10 : 12;
+ return () => ro.disconnect();
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [chartWrapperRef.current]);
+ // breakpoints
+ const mobileBreakpoint = 430; // you said < 430px is problematic
+ const isNarrow = containerWidth <= mobileBreakpoint;
- // choose contrasting color: white usually works on colored slices
- return (
-
- {/* {`${percentValue}%`} */}
- {value}
-
- );
- };
- const getBenchmarkValue = (maxValue) => {
- if (maxValue <= 0) return 100;
+ // compute sizes based on actual container width
+ // make pie fill a good portion of container (leave some padding)
+ const pieOuterRadius = Math.max(
+ 48,
+ Math.floor(containerWidth * (isNarrow ? 0.36 : 0.28))
+ );
+ const pieInnerRadius = Math.floor(pieOuterRadius * (isNarrow ? 0.5 : 0.55));
- const benchmarks = [
- // Fine granularity for small numbers, coarser for large numbers
- 1, 2, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50,
- 60, 70, 80, 90, 100, 125, 150, 175, 200, 225, 250, 275, 300,
- 350, 400, 450, 500, 600, 700, 800, 900, 1000,
- 1250, 1500, 1750, 2000, 2500, 3000, 3500, 4000, 4500, 5000,
- 6000, 7000, 8000, 9000, 10000, 12500, 15000, 17500, 20000, 25000,
- 30000, 35000, 40000, 45000, 50000, 60000, 70000, 80000, 90000, 100000,
- 125000, 150000, 175000, 200000, 250000, 300000, 350000, 400000, 450000, 500000,
- 600000, 700000, 800000, 900000, 1000000
- ];
+ // height for ResponsiveContainer: tether to containerWidth so chart stays proportional
+ const responsiveHeight = Math.max(
+ 220,
+ Math.floor(containerWidth * (isNarrow ? 0.62 : 0.5))
+ );
- const benchmark = benchmarks.find(b => b >= maxValue);
- return benchmark || Math.ceil(maxValue / 10000) * 10000;
- };
+ // tweak minAngle: small screens should allow smaller minAngle so slices remain visible
+ const minAngle = isNarrow ? 4 : 8;
- const chartData = products?.map(p => ({
- ...p,
- name: p?.ProdName,
- value: metric === 'sales' ? p?.TotalSoldQty : p?.TotalRevenue,
- benchMarkValue: metric === 'sales' ? p?.TotalRevenueCount : p?.TotalRevenueAmount
- }));
+ console.log(pieOuterRadius, 'pieOuterRadius');
- const benchmarkValue = getBenchmarkValue(Math.max(...(chartData?.map(d => d?.benchMarkValue) || [0])));
+ // const COLORS = ['#2563eb', '#7c3aed', '#db2777', '#ea580c', '#16a34a', '#0891b2', '#d97706', '#65a30d', '#4f46e5', '#0d9488'];
+ const COLORS = [
+ '#4f8df5', // lighter blue (was #2563eb)
+ '#9a6df3', // lighter violet (was #7c3aed)
+ '#e95b96', // lighter pink (was #db2777)
+ '#f48b3c', // lighter orange (was #ea580c)
+ '#34c86a', // lighter green (was #16a34a)
+ '#33bcd4', // lighter cyan (was #0891b2)
+ '#e39a1a', // lighter amber (was #d97706)
+ '#8bc329', // lighter lime (was #65a30d)
+ '#6d63ef', // lighter indigo (was #4f46e5)
+ '#35bfa9', // lighter teal (was #0d9488)
+ ];
- return (
-
-
- {/* Header */}
- {/*
-
Top Selling Products
-
-
Date Range :
-
current && current > moment().endOf('day')}
- onChange={async (dates) => {
- setDates(dates);
- const FromDate = dates?.[0]?.format('YYYY-MM-DD') || intialFromDate;
- const ToDate = dates?.[1]?.format('YYYY-MM-DD') || intialToDate;
- await fetchProducts({ AppId, CompId, BranchId, FromDate, ToDate, pageNumber: 1 });
- setPage(1);
- }}
- value={dates}
- />
-
-
*/}
+ useEffect(() => {
+ try {
+ dispatch(changeBreadCrumb({ items: items }));
+ } catch (error) {
+ console.log(error?.message, 'error displaying breadcrumbs');
+ }
+ }, []);
-
- {/* Stats Cards */}
-
-
-
-
-
Total Products
-
{products?.length}
-
-
-
-
-
-
-
-
Total Sales
-
- {products?.reduce((sum, p) => sum + (p?.TotalSoldQty || 0), 0)}
-
-
-
-
-
-
-
-
-
Total Revenue
-
- ₹{products?.reduce((sum, p) => sum + (p?.TotalRevenue || 0), 0)?.toFixed(2)}
-
-
-
-
-
-
-
- {/* Controls */}
-
-
-
-
setMetric('sales')}
- className={`btn-metric ${metric === 'sales' ? 'active' : ''}`}
- >
-
- Sales Count
-
-
setMetric('revenue')}
- className={`btn-metric ${metric === 'revenue' ? 'active' : ''}`}
- >
-
- Revenue
-
-
-
- {/*
setChartType(checked ? 'bar' : 'pie')}
- checkedChildren="Bar Chart"
- unCheckedChildren="Pie Chart"
- className="bar-pie-switch"
- value={chartType === 'bar' ? true : false}
- /> */}
- setChartType('bar')}
- className={`btn-chart-type ${chartType === 'bar' ? 'active' : ''}`}
- >
- Bar Chart
-
- setChartType('pie')}
- className={`btn-chart-type ${chartType === 'pie' ? 'active' : ''}`}
- >
- Pie Chart
-
-
- {/* {(dates?.[0] && dates?.[1]) && (
-
-
-
{`${dates[0]?.format('DD/MMM/YYYY') || intialFromDate} - ${dates[1]?.format('DD/MMM/YYYY') || intialToDate}`}
-
- )} */}
-
-
{
- setPage(value);
- const FromDate = dates?.[0]?.format('YYYY-MM-DD') || intialFromDate;
- const ToDate = dates?.[1]?.format('YYYY-MM-DD') || intialToDate;
- await fetchProducts({ AppId, CompId, BranchId, FromDate, ToDate, pageNumber: value });
- }}
- isOnchanges={page ? true : false}
- />
-
-
-
-
- {((initialDate ? true : (!dates && !dates?.[0] && !dates?.[1])) && intialFromDate && intialToDate) &&
{`${dayjs(intialFromDate)?.format('DD/MMM/YYYY')} - ${dayjs(intialToDate)?.format('DD/MMM/YYYY')}`}
}
-
-
-
- {/* Chart */}
-
-
-
-
- {loading && products?.length === 0 ? (
-
- ) : chartData?.length === 0 ? (
-
- No data available
-
- ) : (
- <>
- {chartType === 'bar' ? (
-
-
-
-
- {[
- 0,
- Math.round(benchmarkValue * 0.25),
- Math.round(benchmarkValue * 0.5),
- Math.round(benchmarkValue * 0.75),
- benchmarkValue
- ].map((num, i) => (
-
- ))}
-
-
-
- {chartData?.length > 0 ? (
- <>
- {chartData?.map((item, index) => (
-
{
- setHoveredItem(item);
- setMousePosition({ x: e.clientX, y: e.clientY });
- }}
- // style={{}}
- onMouseLeave={() => setHoveredItem(null)}
- onMouseMove={(e) => setMousePosition({ x: e.clientX, y: e.clientY })}
- >
-
{`#${(index + 1) + ((page - 1) * 10)}`}{item?.name}
-
-
-
-
- {/* {((item?.value / Math.max(...chartData.map(d => d?.value))) * 100).toFixed(1)}% */}
-
-
-
-
{item?.value}
-
- ))}
- >
-
- ) : (
-
- )}
-
- ) : (
- /* Replace your existing
with this */
- /* PIE + RIGHT-LEGEND: replace the existing pie rendering */
-
-
-
-
-
- {chartData.map((entry, index) => (
- |
- ))}
-
- } />
-
-
-
-
-
- {(() => {
- const total = chartData.reduce((s, d) => s + (Number(d?.value || 0)), 0) || 1;
- return chartData.map((d, i) => {
- const color = COLORS[i % COLORS.length];
- const value = Number(d?.value || 0);
- const percent = total ? ((value / total) * 100) : 0;
- return (
-
-
-
-
{d?.name}
-
- {value}
- {percent.toFixed(2)}%
-
-
-
- );
- });
- })()}
-
-
-
- )}
-
- >
- )}
-
-
-
-
+ const CustomTooltip = ({ active, payload }) => {
+ if (active && payload && payload?.[0]) {
+ const product = payload?.[0]?.payload;
+ return (
+
+
+ {product?.ProdName} - {product?.UOMName}
+
+ {product?.BrandName ? (
+
Brand: {product?.BrandName}
+ ) : null}
+
+
Variants:
+ {product?.variantDetails?.map((variant, idx) => (
+
+
+ {variant?.ProdVariantName}:
+
+
+ {variant?.SalesCount} sold | ₹{variant?.Revenue}
+
+
+ ))}
+
+
+
+ Total Sales:
+ {product?.TotalSoldQty}
- {hoveredItem && (
-
-
-
- )}
+
+ Total Revenue:
+ ₹{product?.TotalRevenue}
+
+
+ );
+ }
+ return null;
+ };
+
+ const renderPercentInside = ({
+ cx,
+ cy,
+ midAngle,
+ innerRadius,
+ outerRadius,
+ percent,
+ value,
+ }) => {
+ const percentValue = Math.round(percent * 100);
+ // hide labels for very small percentages on narrow screens
+ if (percentValue < (isNarrow ? 3 : 2)) return null;
+
+ const RADIAN = Math.PI / 180;
+ // place label inside slice (closer to inner radius on narrow screens)
+ const radius =
+ innerRadius + (outerRadius - innerRadius) * (isNarrow ? 0.55 : 0.6);
+
+ const x = cx + radius * Math.cos(-midAngle * RADIAN);
+ const y = cy + radius * Math.sin(-midAngle * RADIAN);
+
+ const fontSize = isNarrow ? 10 : 12;
+
+ // choose contrasting color: white usually works on colored slices
+ return (
+
+ {/* {`${percentValue}%`} */}
+ {value}
+
);
+ };
+ const getBenchmarkValue = (maxValue) => {
+ if (maxValue <= 0) return 100;
+
+ const benchmarks = [
+ // Fine granularity for small numbers, coarser for large numbers
+ 1, 2, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 60, 70, 80, 90, 100, 125,
+ 150, 175, 200, 225, 250, 275, 300, 350, 400, 450, 500, 600, 700, 800, 900,
+ 1000, 1250, 1500, 1750, 2000, 2500, 3000, 3500, 4000, 4500, 5000, 6000,
+ 7000, 8000, 9000, 10000, 12500, 15000, 17500, 20000, 25000, 30000, 35000,
+ 40000, 45000, 50000, 60000, 70000, 80000, 90000, 100000, 125000, 150000,
+ 175000, 200000, 250000, 300000, 350000, 400000, 450000, 500000, 600000,
+ 700000, 800000, 900000, 1000000,
+ ];
+
+ const benchmark = benchmarks.find((b) => b >= maxValue);
+ return benchmark || Math.ceil(maxValue / 10000) * 10000;
+ };
+
+ const chartData = products?.map((p) => ({
+ ...p,
+ name: p?.ProdName,
+ value: metric === 'sales' ? p?.TotalSoldQty : p?.TotalRevenue,
+ benchMarkValue:
+ metric === 'sales' ? p?.TotalRevenueCount : p?.TotalRevenueAmount,
+ }));
+
+ const benchmarkValue = getBenchmarkValue(
+ Math.max(...(chartData?.map((d) => d?.benchMarkValue) || [0]))
+ );
+
+ return (
+
+
+ {/* Stats Cards */}
+
+
+
+
+
Total Products
+
{products?.length}
+
+
+
+
+
+
+
+
Total Sales
+
+ {products?.reduce(
+ (sum, p) => sum + (p?.TotalSoldQty || 0),
+ 0
+ )}
+
+
+
+
+
+
+
+
+
Total Revenue
+
+ ₹
+ {products
+ ?.reduce((sum, p) => sum + (p?.TotalRevenue || 0), 0)
+ ?.toFixed(2)}
+
+
+
+
+
+
+
+ {/* Controls */}
+
+
+
+
setMetric('sales')}
+ className={`btn-metric ${metric === 'sales' ? 'active' : ''}`}
+ >
+
+ Sales Count
+
+
setMetric('revenue')}
+ className={`btn-metric ${metric === 'revenue' ? 'active' : ''}`}
+ >
+
+ Revenue
+
+
+
+
setChartType('bar')}
+ className={`btn-chart-type ${chartType === 'bar' ? 'active' : ''}`}
+ >
+ Bar Chart
+
+
setChartType('pie')}
+ className={`btn-chart-type ${chartType === 'pie' ? 'active' : ''}`}
+ >
+ Pie Chart
+
+
+
+
Loading...}>
+
{
+ setPage(value);
+ const FromDate =
+ dates?.[0]?.format('YYYY-MM-DD') || intialFromDate;
+ const ToDate =
+ dates?.[1]?.format('YYYY-MM-DD') || intialToDate;
+ await fetchProducts({
+ AppId,
+ CompId,
+ BranchId,
+ FromDate,
+ ToDate,
+ pageNumber: value,
+ });
+ }}
+ isOnchanges={page ? true : false}
+ />
+
+
+
+
+ {(initialDate ? true : !dates && !dates?.[0] && !dates?.[1]) &&
+ intialFromDate &&
+ intialToDate && (
+
{`${dayjs(intialFromDate)?.format('DD/MMM/YYYY')} - ${dayjs(intialToDate)?.format('DD/MMM/YYYY')}`}
+ )}
+
+
+ {/* Chart */}
+
+
+ {loading && products?.length === 0 ? (
+
+ ) : chartData?.length === 0 ? (
+
No data available
+ ) : (
+ <>
+ {chartType === 'bar' ? (
+
+
+
+
+ {[
+ 0,
+ Math.round(benchmarkValue * 0.25),
+ Math.round(benchmarkValue * 0.5),
+ Math.round(benchmarkValue * 0.75),
+ benchmarkValue,
+ ].map((num, i) => (
+
+ ))}
+
+
+
+ {chartData?.length > 0 ? (
+ <>
+ {chartData?.map((item, index) => (
+
{
+ setHoveredItem(item);
+ setMousePosition({
+ x: e.clientX,
+ y: e.clientY,
+ });
+ }}
+ // style={{}}
+ onMouseLeave={() => setHoveredItem(null)}
+ onMouseMove={(e) =>
+ setMousePosition({ x: e.clientX, y: e.clientY })
+ }
+ >
+
+ {`#${index + 1 + (page - 1) * 10}`}
+ {item?.name}
+
+
+
+
+ {/* {((item?.value / Math.max(...chartData.map(d => d?.value))) * 100).toFixed(1)}% */}
+
+
+
+
+ {item?.value}
+
+
+ ))}
+ >
+ ) : (
+
+ )}
+
+ ) : (
+ /* Replace your existing
with this */
+ /* PIE + RIGHT-LEGEND: replace the existing pie rendering */
+
+
+
+
+
+ {chartData.map((entry, index) => (
+ |
+ ))}
+
+ } />
+
+
+
+
+
+ {(() => {
+ const total =
+ chartData.reduce(
+ (s, d) => s + Number(d?.value || 0),
+ 0
+ ) || 1;
+ return chartData.map((d, i) => {
+ const color = COLORS[i % COLORS.length];
+ const value = Number(d?.value || 0);
+ const percent = total ? (value / total) * 100 : 0;
+ return (
+
+
+
+
{d?.name}
+
+
+ {value}
+
+
+ {percent.toFixed(2)}%
+
+
+
+
+ );
+ });
+ })()}
+
+
+ )}
+ >
+ )}
+
+
+
+
+ {hoveredItem && (
+
+
+
+ )}
+
+ );
};
-export default TopSellingProducts;
\ No newline at end of file
+export default TopSellingProducts;
diff --git a/src/Pages/DeliveryChallan/DeliveryChallan.scss b/src/Pages/DeliveryChallan/DeliveryChallan.scss
index 7adb85d..0818c13 100644
--- a/src/Pages/DeliveryChallan/DeliveryChallan.scss
+++ b/src/Pages/DeliveryChallan/DeliveryChallan.scss
@@ -4,7 +4,7 @@
flex-wrap: wrap;
gap: 1rem;
- .ant-input-affix-wrapper>input.ant-input {
+ .ant-input-affix-wrapper > input.ant-input {
padding: 4px 1px !important;
padding-top: 1rem !important;
}
@@ -61,6 +61,10 @@
.DeliveryChallan-inputForm .ant-table-content {
width: 70vw;
}
+.DeliveryChallan-inputForm .ant-table-thead tr {
+ background-color: #2c88ee !important;
+
+ }
.DeliveryChallan-inputForm {
display: flex;
@@ -107,8 +111,8 @@
// right: 100px;
}
-.ant-table-wrapper .ant-table-tbody>tr.ant-table-row:hover>td,
-.ant-table-wrapper .ant-table-tbody>tr>th.ant-table-cell-row-hover>td.ant-table-cell-row-hover {
+.ant-table-wrapper .ant-table-tbody > tr.ant-table-row:hover > td,
+.ant-table-wrapper .ant-table-tbody > tr > th.ant-table-cell-row-hover > td.ant-table-cell-row-hover {
background: rgb(224, 223, 223) !important;
font-size: unset !important;
transition-duration: 0.4s !important;
@@ -129,7 +133,6 @@
}
.Deliverychallan-table {
-
// width: 70px;
.ant-table table {
border-spacing: 0px;
@@ -138,4 +141,8 @@
.ant-table-wrapper table {
width: 84% !important;
}
+}
+.product-scan .sales-quotation{
+ display: flex;
+
}
\ No newline at end of file
diff --git a/src/Pages/DeliveryChallan/Deliverychallan.jsx b/src/Pages/DeliveryChallan/Deliverychallan.jsx
index 20a8ac9..e851d21 100644
--- a/src/Pages/DeliveryChallan/Deliverychallan.jsx
+++ b/src/Pages/DeliveryChallan/Deliverychallan.jsx
@@ -61,6 +61,7 @@ import { useSelector } from 'react-redux';
import { getPrintSelectionComponentData } from '../../Features/ThemeChange/ThemeChange.js';
import { DCPDFMobilePrint } from './DCPDFMobilePrint.js';
import { isMobile } from 'react-device-detect';
+
const DeliveryChellanForm = () => {
const { SadminuserAccess } = useAuth();
diff --git a/src/Pages/DeliveryChallanToInvoice/DeliveryChallanToInvoice.scss b/src/Pages/DeliveryChallanToInvoice/DeliveryChallanToInvoice.scss
index b023641..46669ca 100644
--- a/src/Pages/DeliveryChallanToInvoice/DeliveryChallanToInvoice.scss
+++ b/src/Pages/DeliveryChallanToInvoice/DeliveryChallanToInvoice.scss
@@ -24,6 +24,9 @@
vertical-align: middle;
height: 35px;
}
+ .ant-table-thead tr {
+ background-color: #2c88ee !important;
+ }
}
.dc-to-invoice-payment-mode {
@@ -46,4 +49,16 @@
margin: 0px 2rem;
gap: 10px;
padding-top: 0;
-}
\ No newline at end of file
+}
+
+.delivery-challan-to-invoice-form {
+ width: 100%;
+}
+
+.DCformDivAnt {
+ display: flex;
+ align-items: flex-start;
+ gap: 1rem;
+ justify-content: flex-start;
+ flex-direction: column;
+}
diff --git a/src/Pages/DeliveryChallanToInvoice/DeliveryChallanToInvoiceForm.jsx b/src/Pages/DeliveryChallanToInvoice/DeliveryChallanToInvoiceForm.jsx
index 59131d3..259458b 100644
--- a/src/Pages/DeliveryChallanToInvoice/DeliveryChallanToInvoiceForm.jsx
+++ b/src/Pages/DeliveryChallanToInvoice/DeliveryChallanToInvoiceForm.jsx
@@ -342,7 +342,7 @@ const DeliveryChallanToInvoiceForm = () => {
{
/>
>}
-
+
{
)}
-
+
diff --git a/src/Pages/Kiosk/KioskBookingPage.jsx b/src/Pages/Kiosk/KioskBookingPage.jsx
index b224cc0..8313af3 100644
--- a/src/Pages/Kiosk/KioskBookingPage.jsx
+++ b/src/Pages/Kiosk/KioskBookingPage.jsx
@@ -1,4 +1,4 @@
-import React, { useEffect, useState } from 'react';
+import { useEffect, useState } from 'react';
import { useSelector, useDispatch } from 'react-redux';
import axios from 'axios';
import { Skeleton } from 'antd';
@@ -64,119 +64,7 @@ const KioskBookingPage = () => {
};
useEffect(() => {
- // const fetchData = async () => {
- // const queryParams = await getQueryParams();
-
- // console.log("queryParams", queryParams)
- // if (Object.keys(queryParams)?.length !== 0) {
-
- // console.log("queryParams", queryParams)
- // if(!sessionStorage.getItem('auth')){
- // let data = {
- // username: "1000000001",
- // password: "1234"
- // }
- // const response = await axios.post(`${apiUrlToken}/jwtTokenGenerator`, data, {
- // headers: {
- // 'Content-Type': 'application/json',
- // 'Accept': 'application/json',
- // },
- // });
-
- // const { token } = response?.data;
- // sessionStorage.setItem('auth', token)
- // sessionStore("LoginType","Kiosk")
- // }
- // const MACAddress = queryParams?.MD
- // if (MACAddress) {
- // console.log("MACAddress", MACAddress)
- // setDeviceAddress(MACAddress)
- // setDevicePresent(true)
- // let deviceMACResponse = await dispatch(getDeviceAccess({ DeviceAddress: MACAddress })).unwrap();
- // if (deviceMACResponse?.data?.statusCode == 1 && deviceMACResponse?.data?.data?.length > 0 && deviceMACResponse?.data?.data?.[0]?.KioskStatus === 'Y') {
- // setDeviceAccess(true)
- // let responseData = deviceMACResponse?.data?.data?.[0]
- // responseData?.MobileNo != null && responseData?.MobileNo != undefined && sessionStore("MobileNo", responseData?.MobileNo);
- // responseData?.UserId != null && responseData?.UserId != undefined && sessionStore("UserId", responseData?.UserId);
- // responseData?.UserType != null && responseData?.UserType != undefined && sessionStore("UserType", responseData?.UserType);
- // responseData?.CompId != null && responseData?.CompId != undefined && sessionStore("CompId", responseData?.CompId);
- // responseData?.CompName != null && responseData?.CompName != undefined && sessionStore("CompName", responseData?.CompName);
- // responseData?.AppId != null && responseData?.AppId != undefined && sessionStore("AppId", responseData?.AppId);
- // responseData?.AppName != null && responseData?.AppName != undefined && sessionStore("AppName", responseData?.AppName);
- // responseData?.BranchId != null && responseData?.BranchId != undefined && sessionStore("BranchId", responseData?.BranchId);
- // responseData?.userName != null && responseData?.userName != undefined && sessionStore("userName", responseData?.UserName);
- // responseData?.SessionId != null && responseData?.SessionId != undefined && sessionStore("SessionId", responseData?.SessionId);
- // sessionStore("hasRefreshed", true);
- // dispatch(getKioskTemplate({ CompId: responseData?.CompId, BranchId: responseData?.BranchId, AppId: responseData?.AppId })).unwrap();
- // dispatch(getProductCategories({ CompId: responseData?.CompId, BranchId: responseData?.BranchId, AppId: responseData?.AppId })).unwrap();
- // } else {
- // setDeviceAccess(false)
- // }
- // } else {
- // const MobileNoValue = decryptedValuesFun(queryParams?.MN);
- // const UserIdValue = decryptedValuesFun(queryParams?.UD);
- // const UserTypeValue = decryptedValuesFun(queryParams?.UT);
- // const CompIdValue = decryptedValuesFun(queryParams?.CD);
- // const AppIdValue = decryptedValuesFun(queryParams?.AD);
- // const BranchIdValue = decryptedValuesFun(queryParams?.BD);
- // const OrderIdValue = decryptedValuesFun(queryParams?.OD);
- // const AmountValue = decryptedValuesFun(queryParams?.AM);
- // let CompNameValue = null, AppNameValue = null;
- // if (CompIdValue) {
- // let response = await dispatch(getCompanyData({ CompId: CompIdValue })).unwrap();
- // if (response?.data?.statusCode == 1) {
- // CompNameValue = response?.data?.data?.[0]?.["CompName"];
- // } else {
- // CompNameValue = null;
- // }
- // }
- // if (AppIdValue) {
- // let appResponse = await dispatch(getAllApplications({ AppId: AppIdValue })).unwrap();
- // if (appResponse?.data?.statusCode == 1) {
- // AppNameValue = appResponse?.data?.data?.[0]?.["AppName"];
- // } else {
- // AppNameValue = null;
- // }
- // }
- // let userNameValue = null;
- // if (queryParams?.UN != null && queryParams?.UN != undefined) {
- // userNameValue = decryptedValuesFun(queryParams?.UN);
- // }
- // console.log("queryParams", MobileNoValue, UserIdValue, UserTypeValue, CompIdValue, AppIdValue, BranchIdValue)
- // if (MobileNoValue && UserIdValue && UserTypeValue && CompIdValue && AppIdValue && BranchIdValue) {
- // sessionStore("MobileNo", MobileNoValue);
- // sessionStore("UserId", UserIdValue);
- // sessionStore("UserType", UserTypeValue);
- // sessionStore("CompId", CompIdValue);
- // sessionStore("CompName", CompNameValue);
- // sessionStore("AppId", AppIdValue);
- // sessionStore("AppName", AppNameValue);
- // sessionStore("BranchId", BranchIdValue);
- // if (userNameValue != null) {
- // sessionStore("userName", userNameValue);
- // }
- // dispatch(getKioskTemplate({ CompId: CompIdValue, BranchId: BranchIdValue, AppId: AppIdValue })).unwrap();
- // dispatch(getProductCategories({ CompId: CompIdValue, BranchId: BranchIdValue, AppId: AppIdValue })).unwrap();
- // dispatch(changeKioskPageName('OrderView'))
- // dispatch(changePaymentgatewayRedirect(true))
- // dispatch(changeKioskCustomerMobileNo(MobileNoValue))
- // dispatch(changePGFailedTransId(OrderIdValue))
- // dispatch(changePGFailedAmt(AmountValue))
- // const url = new URL(window.location);
- // url.search = '';
- // window.history.replaceState({}, document.title, url.toString());
- // }
- // else {
- // console.error("One or more decrypted values are null.");
- // }
- // }
-
- // } else {
- // dispatch(getKioskTemplate({ CompId: CompId, BranchId: BranchId, AppId: AppId })).unwrap();
- // dispatch(getProductCategories({ CompId: CompId, BranchId: BranchId, AppId: AppId })).unwrap();
- // }
- // }
fetchData();
}, []);
diff --git a/src/Pages/Offer/Offer/OfferList.scss b/src/Pages/Offer/Offer/OfferList.scss
index 5751a44..90098fd 100644
--- a/src/Pages/Offer/Offer/OfferList.scss
+++ b/src/Pages/Offer/Offer/OfferList.scss
@@ -1,9 +1,9 @@
.OfferList-Master {
- padding: 20px;
+ padding: 0;
background: #fff;
min-height: 100vh;
width: 100%;
- margin: 0 0 1rem 1rem;
+ margin: 0 0 0 0;
overflow: auto;
margin-bottom: 2rem;
border-radius: 12px;
@@ -477,6 +477,12 @@
font-size: 14px;
color: #878787;
}
+ .ant-input-affix-wrapper {
+ width: 250px !important;
+ }
+ .ant-input {
+ padding: 3px 14px 9px 11px !important;
+ }
}
// Table Styles
diff --git a/src/Pages/Payment/PaymentDetails/PaymentDetailsList.jsx b/src/Pages/Payment/PaymentDetails/PaymentDetailsList.jsx
index aeff985..1135c62 100644
--- a/src/Pages/Payment/PaymentDetails/PaymentDetailsList.jsx
+++ b/src/Pages/Payment/PaymentDetails/PaymentDetailsList.jsx
@@ -1156,6 +1156,7 @@ const PaymentDetailsList = () => {
flexWrap: 'wrap',
alignItems: 'flex-start',
gap: '1rem',
+ display: 'flex',
}}
>
{
const buildInitialValues = () => ({
dashboard: allSettingsMap['dashboard'] === 'Y',
- shortcutkeys:allSettingsMap['shortcutkeys']==="Y",
+ shortcutkeys: allSettingsMap['shortcutkeys'] === 'Y',
autoreceivestock: allSettingsMap['autoreceivestock'] === 'Y',
decimal: allSettingsMap['decimal'] === 'Y',
enabledModules: [
@@ -287,7 +287,7 @@ const PreferenceList = () => {
const key = setting.SettingIdName.toLowerCase();
const boolValues = {
dashboard: values.dashboard,
- shortcutkeys:values.shortcutkeys,
+ shortcutkeys: values.shortcutkeys,
autoreceivestock: values.autoreceivestock,
decimal: values.decimal,
searchfocus: values.searchfocus,
@@ -564,7 +564,7 @@ const PreferenceList = () => {
Sales Page
{renderCheckbox('searchfocus', 'Always focus the search bar?')}
- {renderCheckbox(
+ {renderCheckbox(
'shortcutkeys',
'Would you like to enable the shortcut keys?'
)}
@@ -589,7 +589,7 @@ const PreferenceList = () => {
)}
- {((allSettingsMap['dinein'] !== undefined && dinePreference) ||
+ {((allSettingsMap['dinein'] !== undefined && dinePreference) ||
allSettingsMap['estimation'] !== undefined) && (
{
'customisedbillnumber',
'Do you Want Customised Bill Number?'
)}
- {renderCheckbox('scanlayout', 'Do you Want Scan Layout Page?')}
+ {renderCheckbox('scanlayout', 'Do you Want Scan Layout Page?')}
{renderCheckbox('upiqr', 'Do you want to show the UPI QR code?')}
{/* {renderCheckbox('editbill', 'Do you want to edit the previously created bill?')} */}
@@ -749,7 +749,6 @@ const PreferenceList = () => {
'estimateprintheader',
'Do you want to include a header when printing Estimate bills?'
)}
-
label {
+ .ant-form-item-label > label {
font-weight: 500;
color: #000000;
font-size: 16px;
@@ -62,7 +62,7 @@
.submitButton {
position: unset;
- >button {
+ > button {
width: max-content;
bottom: 30px;
}
@@ -83,7 +83,7 @@
.menu-section {
padding: 10px 0;
- >div {
+ > div {
font-family: "Poppins";
font-weight: 400;
font-size: 14px;
@@ -99,6 +99,14 @@
&:hover {
background-color: #c0cbf8;
}
+ @media (max-width: 500px) {
+ border: none !important;
+ text-decoration: none !important;
+ font-style: unset !important;
+ }
+ }
+ @media (max-width: 500px) {
+ overflow: auto;
}
}
@@ -118,7 +126,7 @@
font-size: 1rem;
}
- .ant-form-item-label>label {
+ .ant-form-item-label > label {
font-size: 14px;
}
@@ -141,7 +149,7 @@
margin: 0;
text-decoration: underline;
- >div {
+ > div {
font-size: 12px;
margin: 0;
background-color: unset;
@@ -167,4 +175,4 @@
.primary_Button {
width: 200px !important;
}
-}
\ No newline at end of file
+}
diff --git a/src/Pages/Product/ProductForm.jsx b/src/Pages/Product/ProductForm.jsx
index 9a3add1..5f08c76 100644
--- a/src/Pages/Product/ProductForm.jsx
+++ b/src/Pages/Product/ProductForm.jsx
@@ -125,7 +125,7 @@ const ProductForm = ({ formType }) => {
UomTypePreference?.some?.(
(e) =>
e?.PreferredSubCatName?.toLowerCase() ==
- item?.ConfigName?.toLowerCase() && e?.PreferredStatus == 'Y'
+ item?.ConfigName?.toLowerCase() && e?.PreferredStatus == 'Y'
)
);
console.log(UomTypePreference, 'UomTypePreference');
@@ -537,9 +537,12 @@ const ProductForm = ({ formType }) => {
useEffect(() => {
if (
- AppId !== undefined && AppId !== null &&
- CompId !== undefined && CompId !== null &&
- BranchId !== undefined && BranchId !== null
+ AppId !== undefined &&
+ AppId !== null &&
+ CompId !== undefined &&
+ CompId !== null &&
+ BranchId !== undefined &&
+ BranchId !== null
) {
productFetchData();
fetchRackData();
@@ -1125,7 +1128,7 @@ const ProductForm = ({ formType }) => {
(item) =>
parseFloat(item.MRP) === parseFloat(subVariantPriceData?.MRP) &&
parseFloat(item.SellPrice) ===
- parseFloat(subVariantPriceData?.SellPrice) &&
+ parseFloat(subVariantPriceData?.SellPrice) &&
//dhana 18-02-2025
item.ProdVariantName == subVariantPriceData?.ProdVariantName
);
@@ -1140,20 +1143,20 @@ const ProductForm = ({ formType }) => {
SellPrice: subVariantPriceData?.SellPrice,
WhSalePrice:
subVariantPriceData?.WhSalePrice == undefined ||
- subVariantPriceData?.WhSalePrice == null ||
- subVariantPriceData?.WhSalePrice == ''
+ subVariantPriceData?.WhSalePrice == null ||
+ subVariantPriceData?.WhSalePrice == ''
? 0
: subVariantPriceData?.WhSalePrice,
OfferPrice:
subVariantPriceData?.OfferPrice == undefined ||
- subVariantPriceData?.OfferPrice == null ||
- subVariantPriceData?.OfferPrice == ''
+ subVariantPriceData?.OfferPrice == null ||
+ subVariantPriceData?.OfferPrice == ''
? 0
: subVariantPriceData?.OfferPrice,
SpecialPrice:
subVariantPriceData?.SpecialPrice == undefined ||
- subVariantPriceData?.SpecialPrice == null ||
- subVariantPriceData?.SpecialPrice == ''
+ subVariantPriceData?.SpecialPrice == null ||
+ subVariantPriceData?.SpecialPrice == ''
? 0
: subVariantPriceData?.SpecialPrice,
InwardDtlId: null,
@@ -1209,20 +1212,20 @@ const ProductForm = ({ formType }) => {
SellPrice: subVariantPriceData?.SellPrice,
WhSalePrice:
subVariantPriceData?.WhSalePrice == undefined ||
- subVariantPriceData?.WhSalePrice == null ||
- subVariantPriceData?.WhSalePrice == ''
+ subVariantPriceData?.WhSalePrice == null ||
+ subVariantPriceData?.WhSalePrice == ''
? 0
: subVariantPriceData?.WhSalePrice,
OfferPrice:
subVariantPriceData?.OfferPrice == undefined ||
- subVariantPriceData?.OfferPrice == null ||
- subVariantPriceData?.OfferPrice == ''
+ subVariantPriceData?.OfferPrice == null ||
+ subVariantPriceData?.OfferPrice == ''
? 0
: subVariantPriceData?.OfferPrice,
SpecialPrice:
subVariantPriceData?.SpecialPrice == undefined ||
- subVariantPriceData?.SpecialPrice == null ||
- subVariantPriceData?.SpecialPrice == ''
+ subVariantPriceData?.SpecialPrice == null ||
+ subVariantPriceData?.SpecialPrice == ''
? 0
: subVariantPriceData?.SpecialPrice,
InwardDtlId: null,
@@ -1288,20 +1291,20 @@ const ProductForm = ({ formType }) => {
SellPrice: subVariantPriceData?.SellPrice,
WhSalePrice:
subVariantPriceData?.WhSalePrice == undefined ||
- subVariantPriceData?.WhSalePrice == null ||
- subVariantPriceData?.WhSalePrice == ''
+ subVariantPriceData?.WhSalePrice == null ||
+ subVariantPriceData?.WhSalePrice == ''
? 0
: subVariantPriceData?.WhSalePrice,
OfferPrice:
subVariantPriceData?.OfferPrice == undefined ||
- subVariantPriceData?.OfferPrice == null ||
- subVariantPriceData?.OfferPrice == ''
+ subVariantPriceData?.OfferPrice == null ||
+ subVariantPriceData?.OfferPrice == ''
? 0
: subVariantPriceData?.OfferPrice,
SpecialPrice:
subVariantPriceData?.SpecialPrice == undefined ||
- subVariantPriceData?.SpecialPrice == null ||
- subVariantPriceData?.SpecialPrice == ''
+ subVariantPriceData?.SpecialPrice == null ||
+ subVariantPriceData?.SpecialPrice == ''
? 0
: subVariantPriceData?.SpecialPrice,
InwardDtlId: null,
@@ -1356,20 +1359,20 @@ const ProductForm = ({ formType }) => {
SellPrice: subVariantPriceData?.SellPrice,
WhSalePrice:
subVariantPriceData?.WhSalePrice == undefined ||
- subVariantPriceData?.WhSalePrice == null ||
- subVariantPriceData?.WhSalePrice == ''
+ subVariantPriceData?.WhSalePrice == null ||
+ subVariantPriceData?.WhSalePrice == ''
? 0
: subVariantPriceData?.WhSalePrice,
OfferPrice:
subVariantPriceData?.OfferPrice == undefined ||
- subVariantPriceData?.OfferPrice == null ||
- subVariantPriceData?.OfferPrice == ''
+ subVariantPriceData?.OfferPrice == null ||
+ subVariantPriceData?.OfferPrice == ''
? 0
: subVariantPriceData?.OfferPrice,
SpecialPrice:
subVariantPriceData?.SpecialPrice == undefined ||
- subVariantPriceData?.SpecialPrice == null ||
- subVariantPriceData?.SpecialPrice == ''
+ subVariantPriceData?.SpecialPrice == null ||
+ subVariantPriceData?.SpecialPrice == ''
? 0
: subVariantPriceData?.SpecialPrice,
InwardDtlId: null,
@@ -1438,17 +1441,17 @@ const ProductForm = ({ formType }) => {
(item) =>
parseFloat(item.MRP) === parseFloat(subVariantPriceData?.MRP) &&
parseFloat(item.SellPrice) ===
- parseFloat(subVariantPriceData?.SellPrice)
+ parseFloat(subVariantPriceData?.SellPrice)
);
if (
existsData?.length == 0 ||
(parseFloat(variantPriceData[variantEditIndex]?.MRP) ===
parseFloat(subVariantPriceData?.MRP) &&
parseFloat(variantPriceData[variantEditIndex]?.SellPrice) ===
- parseFloat(subVariantPriceData?.SellPrice) &&
+ parseFloat(subVariantPriceData?.SellPrice) &&
//dhana 18-02-2025
variantPriceData[variantEditIndex]?.ProdVariantName ==
- subVariantPriceData?.ProdVariantName)
+ subVariantPriceData?.ProdVariantName)
) {
let editVariantData = [...variantPriceData];
if (
@@ -1466,20 +1469,20 @@ const ProductForm = ({ formType }) => {
SellPrice: subVariantPriceData?.SellPrice,
WhSalePrice:
subVariantPriceData?.WhSalePrice == undefined ||
- subVariantPriceData?.WhSalePrice == null ||
- subVariantPriceData?.WhSalePrice == ''
+ subVariantPriceData?.WhSalePrice == null ||
+ subVariantPriceData?.WhSalePrice == ''
? 0
: subVariantPriceData?.WhSalePrice,
OfferPrice:
subVariantPriceData?.OfferPrice == undefined ||
- subVariantPriceData?.OfferPrice == null ||
- subVariantPriceData?.OfferPrice == ''
+ subVariantPriceData?.OfferPrice == null ||
+ subVariantPriceData?.OfferPrice == ''
? 0
: subVariantPriceData?.OfferPrice,
SpecialPrice:
subVariantPriceData?.SpecialPrice == undefined ||
- subVariantPriceData?.SpecialPrice == null ||
- subVariantPriceData?.SpecialPrice == ''
+ subVariantPriceData?.SpecialPrice == null ||
+ subVariantPriceData?.SpecialPrice == ''
? 0
: subVariantPriceData?.SpecialPrice,
InwardDtlId: editVariantData[variantEditIndex]?.InwardDtlId,
@@ -1493,20 +1496,20 @@ const ProductForm = ({ formType }) => {
SellPrice: subVariantPriceData?.SellPrice,
WhSalePrice:
subVariantPriceData?.WhSalePrice == undefined ||
- subVariantPriceData?.WhSalePrice == null ||
- subVariantPriceData?.WhSalePrice == ''
+ subVariantPriceData?.WhSalePrice == null ||
+ subVariantPriceData?.WhSalePrice == ''
? 0
: subVariantPriceData?.WhSalePrice,
OfferPrice:
subVariantPriceData?.OfferPrice == undefined ||
- subVariantPriceData?.OfferPrice == null ||
- subVariantPriceData?.OfferPrice == ''
+ subVariantPriceData?.OfferPrice == null ||
+ subVariantPriceData?.OfferPrice == ''
? 0
: subVariantPriceData?.OfferPrice,
SpecialPrice:
subVariantPriceData?.SpecialPrice == undefined ||
- subVariantPriceData?.SpecialPrice == null ||
- subVariantPriceData?.SpecialPrice == ''
+ subVariantPriceData?.SpecialPrice == null ||
+ subVariantPriceData?.SpecialPrice == ''
? 0
: subVariantPriceData?.SpecialPrice,
InwardDtlId: editVariantData[variantEditIndex]?.InwardDtlId,
@@ -1634,20 +1637,20 @@ const ProductForm = ({ formType }) => {
SellPrice: row?.SellPrice,
WhSalePrice:
row?.WhSalePrice == undefined ||
- row?.WhSalePrice == null ||
- row?.WhSalePrice == ''
+ row?.WhSalePrice == null ||
+ row?.WhSalePrice == ''
? 0
: row?.WhSalePrice,
OfferPrice:
row?.OfferPrice == undefined ||
- row?.OfferPrice == null ||
- row?.OfferPrice == ''
+ row?.OfferPrice == null ||
+ row?.OfferPrice == ''
? 0
: row?.OfferPrice,
SpecialPrice:
row?.SpecialPrice == undefined ||
- row?.SpecialPrice == null ||
- row?.SpecialPrice == ''
+ row?.SpecialPrice == null ||
+ row?.SpecialPrice == ''
? 0
: row?.SpecialPrice,
InwardDtlId: row?.InwardDtlId,
@@ -1661,20 +1664,20 @@ const ProductForm = ({ formType }) => {
SellPrice: row?.SellPrice,
WhSalePrice:
row?.WhSalePrice == undefined ||
- row?.WhSalePrice == null ||
- row?.WhSalePrice == ''
+ row?.WhSalePrice == null ||
+ row?.WhSalePrice == ''
? 0
: row?.WhSalePrice,
OfferPrice:
row?.OfferPrice == undefined ||
- row?.OfferPrice == null ||
- row?.OfferPrice == ''
+ row?.OfferPrice == null ||
+ row?.OfferPrice == ''
? 0
: row?.OfferPrice,
SpecialPrice:
row?.SpecialPrice == undefined ||
- row?.SpecialPrice == null ||
- row?.SpecialPrice == ''
+ row?.SpecialPrice == null ||
+ row?.SpecialPrice == ''
? 0
: row?.SpecialPrice,
InwardDtlId: row?.InwardDtlId,
@@ -1811,14 +1814,14 @@ const ProductForm = ({ formType }) => {
postData['InwardDate'] = new Date().toJSON();
postData['AutoGenerateQr'] =
values?.QRCode === undefined ||
- values?.QRCode === null ||
- values?.QRCode === ''
+ values?.QRCode === null ||
+ values?.QRCode === ''
? QrcodeAuto
: 'N';
postData['AutoGenerateSingleQr'] =
values?.OnePcQR === undefined ||
- values?.OnePcQR === null ||
- values?.OnePcQR === ''
+ values?.OnePcQR === null ||
+ values?.OnePcQR === ''
? QrcodeAutoSingle
: 'N';
postData['CreatedBy'] = UserId;
@@ -2136,6 +2139,7 @@ const ProductForm = ({ formType }) => {
initialValues={
editstate || { LowStockCount: 0, ExpiryNotificationDays: 0 }
}
+ style={{ marginTop: '0' }}
>
@@ -2174,26 +2178,12 @@ const ProductForm = ({ formType }) => {
/>
- {/* */}
-
- {/*
*/}
- {/*