Update src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable2/BsBill2.jsx
This commit is contained in:
parent
5f5ca99409
commit
03fb7f9d6f
|
|
@ -1,6 +1,6 @@
|
||||||
import React, { useEffect, useState, Suspense } from 'react';
|
import React, { useEffect, useState, Suspense } from 'react';
|
||||||
import { useDispatch, useSelector } from 'react-redux';
|
import { useDispatch, useSelector } from 'react-redux';
|
||||||
import { Badge } from 'antd';
|
import { Badge, message } from 'antd';
|
||||||
import defaultimage from '../../../../../Images/defaultItemImg.png';
|
import defaultimage from '../../../../../Images/defaultItemImg.png';
|
||||||
import {
|
import {
|
||||||
GlobalOrderCardDetails,
|
GlobalOrderCardDetails,
|
||||||
|
|
@ -57,6 +57,7 @@ import { useApplyOfferto_CardDetail } from '../../UtillComponents/BSNavBarOffer/
|
||||||
import { ClearOfferAppliedProducts } from '../../../../../Features/Offer/Offernew/BookingOffernew.js';
|
import { ClearOfferAppliedProducts } from '../../../../../Features/Offer/Offernew/BookingOffernew.js';
|
||||||
import { useUtilsComponent } from '../../../../../Services/utils.js';
|
import { useUtilsComponent } from '../../../../../Services/utils.js';
|
||||||
import CustomerPriceHistory from '../../UtillComponents/CustomerPriceHistory.jsx';
|
import CustomerPriceHistory from '../../UtillComponents/CustomerPriceHistory.jsx';
|
||||||
|
import { calculateOverAllQtyLimit } from '../../../../../utils/calculations.js';
|
||||||
|
|
||||||
const MinusOutlined = React.lazy(
|
const MinusOutlined = React.lazy(
|
||||||
() => import('@ant-design/icons/MinusOutlined')
|
() => import('@ant-design/icons/MinusOutlined')
|
||||||
|
|
@ -110,8 +111,17 @@ const BsBill2 = () => {
|
||||||
const OtherServicesglobal = useSelector(GlobalOtherSevices);
|
const OtherServicesglobal = useSelector(GlobalOtherSevices);
|
||||||
const GetCustId = useSelector(GlobalCustId);
|
const GetCustId = useSelector(GlobalCustId);
|
||||||
const selectedCustomer = useSelector(GlobalSelOption);
|
const selectedCustomer = useSelector(GlobalSelOption);
|
||||||
|
const overAllLimitPreferenece =
|
||||||
|
preferenceDatas?.[0]?.['SettingDtlDetails']?.find(
|
||||||
|
(item) => (item.SettingIdName?.toLowerCase() === 'overalllimit') && item?.SettingValue === 'Y');
|
||||||
|
const itemWiseLimitPreferenece =
|
||||||
|
preferenceDatas?.[0]?.['SettingDtlDetails']?.find(
|
||||||
|
(item) => item.SettingIdName?.toLowerCase() === 'itemwiselimit' && item?.SettingValue === 'Y');
|
||||||
|
const maxQtyLimit = itemWiseLimitPreferenece?.SettingCount || overAllLimitPreferenece?.SettingCount || null;
|
||||||
|
|
||||||
const [customerPriceHistoryOpen, setCustomerPriceHistoryOpen] = useState(false);
|
|
||||||
|
const [customerPriceHistoryOpen, setCustomerPriceHistoryOpen] =
|
||||||
|
useState(false);
|
||||||
const [customerProduct, setCustomerProduct] = useState(null);
|
const [customerProduct, setCustomerProduct] = useState(null);
|
||||||
|
|
||||||
const BillOrderPre = preferenceDatas?.[0]?.SettingDtlDetails?.find(
|
const BillOrderPre = preferenceDatas?.[0]?.SettingDtlDetails?.find(
|
||||||
|
|
@ -268,8 +278,18 @@ const BsBill2 = () => {
|
||||||
const handleCustomerProductPriceHistory = (item) => {
|
const handleCustomerProductPriceHistory = (item) => {
|
||||||
setCustomerPriceHistoryOpen(true);
|
setCustomerPriceHistoryOpen(true);
|
||||||
setCustomerProduct(item?.ProdId);
|
setCustomerProduct(item?.ProdId);
|
||||||
}
|
};
|
||||||
const increase = async (item) => {
|
const increase = async (item) => {
|
||||||
|
if ((overAllLimitPreferenece || itemWiseLimitPreferenece) && maxQtyLimit) {
|
||||||
|
if (overAllLimitPreferenece) {
|
||||||
|
const calculatedOverAllQty = calculateOverAllQtyLimit(CartOrderDetails);
|
||||||
|
if ((calculatedOverAllQty + 1) > maxQtyLimit) {
|
||||||
|
message.warning(`Overall Quantity Limit Exceeds than ${maxQtyLimit}`)
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
const OtherOrderDatas = CartOrderDetails?.filter(
|
const OtherOrderDatas = CartOrderDetails?.filter(
|
||||||
(cartItem) =>
|
(cartItem) =>
|
||||||
!(
|
!(
|
||||||
|
|
@ -1003,8 +1023,6 @@ const BsBill2 = () => {
|
||||||
} else {
|
} else {
|
||||||
dispatch(changeOrderCardDetails(UpdatedData));
|
dispatch(changeOrderCardDetails(UpdatedData));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} else if (
|
} else if (
|
||||||
item?.BookingTypeName !== 'Dine In' &&
|
item?.BookingTypeName !== 'Dine In' &&
|
||||||
OrderType === 'Hold'
|
OrderType === 'Hold'
|
||||||
|
|
@ -2233,7 +2251,7 @@ const BsBill2 = () => {
|
||||||
ProductDetail={Modaldata}
|
ProductDetail={Modaldata}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{(customerPriceHistoryOpen && GetCustId) &&
|
{customerPriceHistoryOpen && GetCustId && (
|
||||||
<CustomerPriceHistory
|
<CustomerPriceHistory
|
||||||
open={customerPriceHistoryOpen}
|
open={customerPriceHistoryOpen}
|
||||||
custId={GetCustId}
|
custId={GetCustId}
|
||||||
|
|
@ -2242,7 +2260,7 @@ const BsBill2 = () => {
|
||||||
setCustomerProduct={setCustomerProduct}
|
setCustomerProduct={setCustomerProduct}
|
||||||
selectedCustomer={selectedCustomer}
|
selectedCustomer={selectedCustomer}
|
||||||
/>
|
/>
|
||||||
}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue