diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable1/BST1Payment.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable1/BST1Payment.jsx index 6af8c08..07327ae 100644 --- a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable1/BST1Payment.jsx +++ b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable1/BST1Payment.jsx @@ -220,6 +220,7 @@ import BSCustomerSelect from '../../UtillComponents/BSSelectCustomer.jsx'; import PozoAddCustomerIcon from '../../UtillComponents/Pozo retail icons/PozoAddCustomerIcon.jsx'; import PozoCartIcon from '../../UtillComponents/PozoCartIcon.jsx'; import BSBillingTable3 from '../BSBillingTable3/BSBillingTable3.jsx'; +import useCountUp from '../../UtillComponents/useCountUp.jsx'; const subDirectory = import.meta.env.ENV_BASE_URL; const MainHomeUrl = import.meta.env.ENV_MAIN_BASE_URL; @@ -3584,6 +3585,17 @@ export default function BST1Payment() { (arr) => Array.isArray(arr) && arr.some((err) => err) ); }; + + const CountUp = useCountUp( + safeRound( + OrderType === 'Failed' + ? FailedTotalAmt + : credit && overAllBal >= 0 + ? Math.max(0, TotalAmount - overAllBal) + : TotalAmount + ) + ); + return ( <>
@@ -4291,8 +4303,8 @@ export default function BST1Payment() {
) : (
- ₹{' '} - + /> */}
) ) : ( diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable1/BalanceAndReceived.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable1/BalanceAndReceived.jsx index 5911b82..811e811 100644 --- a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable1/BalanceAndReceived.jsx +++ b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable1/BalanceAndReceived.jsx @@ -7,12 +7,12 @@ import { PreferenceData, } from '../../../../../Features/BookingScreen/BookingData/BookingData'; import { GlobalSelectedFont } from '../../../../../Features/ThemeChange/ThemeChange'; -import CountUp from 'react-countup'; import '../../../../../Styles/BookingScreen/Components/BSBillingTables/BSBillingTable1/BSBPayment.scss'; import { useAuth } from '../../../../../AuthContext'; import TooltipWrapper from '../../../../../Components/Tooltip/Tooltip'; import { isMobile } from 'react-device-detect'; import { getSession } from '../../../../../Services/Others'; +import useCountUp from '../../UtillComponents/useCountUp'; const PaymentInput = ({ orderType, @@ -50,7 +50,11 @@ const PaymentInput = ({ const [addnewAccess, setaddnewAccess] = useState(true); const UserType = getSession('UserType'); const preferenceDatas = useSelector(PreferenceData); - const allowDecimal = preferenceDatas?.[0]?.SettingDtlDetails?.find((setting) => setting?.SettingIdName?.toLowerCase() === "decimal" && setting?.SettingValue === 'Y'); + const allowDecimal = preferenceDatas?.[0]?.SettingDtlDetails?.find( + (setting) => + setting?.SettingIdName?.toLowerCase() === 'decimal' && + setting?.SettingValue === 'Y' + ); useEffect(() => { const receivedInput = document.getElementById('recived'); @@ -116,6 +120,10 @@ const PaymentInput = ({ return allowDecimal ? num.toFixed(2) : Math.round(num).toString(); } + const CountUp = useCountUp( + OrderType === 'Failed' ? failedTotalAmt : safeRound(totalAmount) + ); + return ( <> {BillingTableName === 'BillingTable1' && ( @@ -138,9 +146,9 @@ const PaymentInput = ({ addnewAccess ? 'price-button-disabled' : FirstPaymentclick === false && - OrderCardDetail?.length > 0 && - paybtnselected && - CheckBookingStatus != 'Close' + OrderCardDetail?.length > 0 && + paybtnselected && + CheckBookingStatus != 'Close' ? !OrderStatus ? 'price-button' : 'price-button Order' @@ -157,31 +165,51 @@ const PaymentInput = ({ style={{ fontFamily: FontFamily['head'] }} > {isMobile && - (!OrderStatus ? salesBillEdit && (currentOrderNetAmount < previousNetAmount) ?
Refund: ₹{(previousNetAmount || 0) - (currentOrderNetAmount || 0)}
: - `₹ ${Math.round( - OrderType === 'Failed' ? failedTotalAmt : credit && overAllBal >= 0 - ? Math.max(0, totalAmount - overAllBal) - : totalAmount - )}` - : 'ORDER')} + (!OrderStatus ? ( + salesBillEdit && currentOrderNetAmount < previousNetAmount ? ( +
+ Refund: ₹ + {(previousNetAmount || 0) - (currentOrderNetAmount || 0)} +
+ ) : ( + `₹ ${Math.round( + OrderType === 'Failed' + ? failedTotalAmt + : credit && overAllBal >= 0 + ? Math.max(0, totalAmount - overAllBal) + : totalAmount + )}` + ) + ) : ( + 'ORDER' + ))} - {!isMobile && !OrderStatus && ((salesBillEdit && (currentOrderNetAmount < previousNetAmount)) ?
Refund: ₹{(previousNetAmount || 0) - (currentOrderNetAmount || 0)}
: ( - <> - ₹{' '} - {/* + Refund: ₹ + {(previousNetAmount || 0) - (currentOrderNetAmount || 0)} + + ) : ( + <> + ₹ {CountUp} + {/* */} - {OrderType === 'Failed' - ? failedTotalAmt - : safeRound((credit && overAllBal >= 0) - ? Math.max(0, totalAmount - overAllBal) - : totalAmount)} - - ))} + {/* {OrderType === 'Failed' + ? failedTotalAmt + : safeRound( + credit && overAllBal >= 0 + ? Math.max(0, totalAmount - overAllBal) + : totalAmount + )} */} + + ))} {!isMobile && OrderStatus && 'ORDER'} diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable3/BSBillingTable3pay.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable3/BSBillingTable3pay.jsx index 8e59af6..02f93fb 100644 --- a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable3/BSBillingTable3pay.jsx +++ b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable3/BSBillingTable3pay.jsx @@ -210,6 +210,7 @@ import UpiPopover from '../StandardTable/Utils/UpiPopOver.jsx'; import MobileMultiPdfPrintTrigger from '../../UtillComponents/MobileMultiPdfPrintTrigger.jsx'; import { useDateStore } from '../../../../../Features/BookingScreen/BookingData/DateStore.js'; import CustomerMobileNumberModal from '../../BookingFunctionality/CustomerOTP.jsx'; +import useCountUp from '../../UtillComponents/useCountUp.jsx'; const PaymentGatewayEmbedded = lazy( () => import('../../UtillComponents/PaymentGatewayEmbedded.jsx') ); @@ -3636,6 +3637,17 @@ const BSBillingTable3Pay = () => { (arr) => Array.isArray(arr) && arr.some((err) => err) ); }; + + const CountUp = useCountUp( + safeRound( + OrderType === 'Failed' + ? FailedTotalAmt + : credit && overAllBal >= 0 + ? Math.max(0, TotalAmount - overAllBal) + : TotalAmount + ) + ); + return ( <>
@@ -4537,8 +4549,8 @@ const BSBillingTable3Pay = () => { )}` ) : (
- ₹{' '} - { ? Math.max(0, TotalAmount - overAllBal) : TotalAmount )} - /> + /> */}
)}

diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/StandardTable/StandardTablePayment.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/StandardTable/StandardTablePayment.jsx index 25f61ce..ff6ad45 100644 --- a/src/Pages/BookingScreen/Components/BSBillingTables/StandardTable/StandardTablePayment.jsx +++ b/src/Pages/BookingScreen/Components/BSBillingTables/StandardTable/StandardTablePayment.jsx @@ -233,6 +233,7 @@ import { MdSms } from 'react-icons/md'; import '../../../../BookingScreen/Components/BSBillingTables/StandardTable/StandardTable.scss'; import BSCustomerSelect from '../../UtillComponents/BSSelectCustomer.jsx'; import BSNavBarAddUser from '../../UtillComponents/BSNavBarAddUser.jsx'; +import useCountUp from '../../UtillComponents/useCountUp.jsx'; // const subDirectory = import.meta.env.ENV_BASE_URL; @@ -3430,6 +3431,16 @@ const StandardTablePayment = () => { return allowDecimal ? num.toFixed(2) : Math.round(num).toString(); } + const CountUp = useCountUp( + safeRound( + OrderType === 'Failed' + ? FailedTotalAmt + : credit && overAllBal >= 0 + ? Math.max(0, TotalAmount - overAllBal) + : TotalAmount + ) + ); + return (
{ )}` ) : (
- ₹{' '} - { ? Math.max(0, TotalAmount - overAllBal) : TotalAmount )} - /> + /> */}
)}

diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/StandardTable/StandardTablePaymentBackup.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/StandardTable/StandardTablePaymentBackup.jsx deleted file mode 100644 index 5f3ab7b..0000000 --- a/src/Pages/BookingScreen/Components/BSBillingTables/StandardTable/StandardTablePaymentBackup.jsx +++ /dev/null @@ -1,2631 +0,0 @@ -import { FaMoneyBillWave, FaPrint, FaWhatsapp } from "react-icons/fa"; -import { FaMobileScreenButton } from "react-icons/fa6"; -import moment from 'moment'; -import { FaCreditCard } from "react-icons/fa6"; -import { - changeBookingType, - ChangeComboCarddata, changeCustomerID, ChangeNavHoldData, changeOrderCardDetails, - changeOrderType, changeOtherServiceTicketClaim, ChangeOverAllDiscEstimate, - ChangeOverAllDiscSales, changePaymentloader, changePaymentTransactionNumber, - changeReorderHoldDetails, changeReorderProductDetails, changeSelectChair, - changeSelectedCustId, changeSelectedOption, changeSelectedTableDetails, changeSelectTable, - changeSelProdWiseEst, changeSummeryComboOfferAmount, changeSummeryTotalAmount, changeTipAmount, changeUpiIDName, changeUpiIDoptionId, changeUpiIDprint, - getCardDataWithoutSub, getCardDataWithoutSubmodule, getConfigType, getLayoutproductCard, - GetPaymentdeviceResponse, getSalesDetailData, getSelectedFavItems, getUnpaidData, - GlobalBookingType, GlobalBookingTypeBoth, GlobalComboOfferAmount, GlobalCommonPaymentOptions, - GlobalCustId, - GlobalEstimateBooking, GlobalFailedTotalAmt, GlobalNavHoldData, GlobalOrderCardDetails, - GlobalOrderType, GlobalOtherServiceTicketClaim, GlobalOtherSevices, GlobalOverAllDiscEstimate, - GlobalOverAllDiscSales, GlobalPayementloader, GlobalProductCategorie, GlobalProductSubCategorie, - GlobalReorderHoldDetails, GlobalSelCustId, GlobalSelectedTableDetails, GlobalSelOption, GlobalSelProdWiseEst, - GlobalSummeryTotalItems, GlobaltipAmount, Globalunpaidflow, PaymentGatewayGetdetail, PostBookingData, - PostPaymentdevice, PreferenceData, PutBookingData, PutBookingPaymentStatusChange, PutPendingPaymentList, - putSplitpaymentStatus -} from '../../../../../Features/BookingScreen/BookingData/BookingData'; -import { shallowEqual, useSelector } from 'react-redux'; -import { Global_OrderOfferDetail, Global_OverallOfferAmount } from "../../../../../Features/Offer/Offer"; -import { useCallback, useEffect, useState } from "react"; -import { settingDataSelector } from "../../../../../Features/PreferenceMaster/PreferenceMaster"; -import { getTemplateData, GlobalprintDatas, GlobalSelectedFont, SelectedPrintTemplate, StoredSessionData } from "../../../../../Features/ThemeChange/ThemeChange"; -import { getCustomerDisplayWindow } from "../../../../../Features/customerDisplayWindow/customerDisplayWindow"; -import { ChangeTotalAmount, globalExtraTotalAmount } from "../../../../../Features/ExteraCharges/ExtraCharges"; -import { extractLastNumberOrderId } from "../../../../../Services/Others"; -import { useDispatch } from "react-redux"; -import { getPaymentOptionsData } from "../../../../../Features/BookingScreen/BookingData/KioskBookingData"; -import { PostOtherServices } from "../../../../../Features/OtherServices/OtherServices"; -import { getCombolist } from "../../../../../Features/ComboMaster/ComboMaster"; -import paygate from '../../../../../Images/paygate.png'; -import defaultupi from '../../../../../Images/defaultupi.png'; -import paydevice from '../../../../../Images/paydevice.png'; -import QrinScreen from '../../BookingFunctionality/DynamicScreenQr.jsx'; -import { changeholddata, gettinghold } from "../../../../../Features/BookingScreen/HoldOption/HoldOption"; -import { Tooltip } from "antd"; -import { changeSalesPaymentoption, GlobalSalesPaymentoption } from "../../../../../Features/Payment/Paymentoptions/Paymentoptions"; -import UpiPopover from "./Utils/UpiPopOver"; -import { isMobile } from 'react-device-detect'; -import { MobilePdfPrint } from "../../BookingFunctionality/MobilePdfPrint"; -import IndividualTokenMobilePrint from "../../BookingFunctionality/IndividualTokenMobilePrint"; -import SingleTokenMobilePrint from "../../BookingFunctionality/SingleTokenMobilePrint"; -import MobilePrint from "../../BookingFunctionality/MobilePrint"; -import { PrintStyleFunction } from "../../../../paymentpdfPage/PrintStyleFunction"; -import { printDiv } from "../../../../../Services/WSOthers"; -import { MdSms } from "react-icons/md"; -import WhatsAppShare from "../../../../WhatsAppShare/whatsAppShare"; -import SMSShare from "../../../../WhatsAppShare/SmsShare"; -import { GlobalBookingStatus } from "../../../../../Features/Payment/PaymentReceivedRetail/PaymentReceivedRetail"; -import { useAuth } from "../../../../../AuthContext"; -import CountUp from "react-countup"; -import { BiRightArrowAlt } from "react-icons/bi"; -import { GlobalpreOrderOpen } from "../../../../../Features/BookingScreen/PreOrder/PreOrder"; -import BsBillingCreditCustomer from "../../BookingFunctionality/BSBillingCreditCustomer"; -import TokensinglePrint from "../../../../paymentpdfPage/TokenOnlyPrints/TokeninsinglePrint"; -import PaymentPdfBooking from "../../../../paymentpdfPage/PaymentPdfBooking"; -import { DefaultModal } from "../../../../../Components/Modal/DefaultModal"; -import Buttons from "../../../../../Components/Forms/Buttons"; -import { ArrowRightOutlined } from '@ant-design/icons'; -import Paymentoption from "../../../../Payment/PaymentOptions/PaymentOptions"; -import PozoSplitPaymentIcon from "../../UtillComponents/Pozo retail icons/PozoSplitPaymentIcon"; -import SplitPayment from '../../BookingFunctionality/SplitPayment'; -import BSCreditCustomer from "../../UtillComponents/BSCreditCustomer"; -import PozoAdvanceIcon from "../../UtillComponents/Pozo retail icons/PozoAdvanceIcon"; -import { GlobalAddCustomerDetails } from "../../../../../Features/BookingScreen/Customer/addCustomer"; -import { useNavigate } from "react-router-dom"; -import { ApplicationPreferences } from "../../../../../Features/BrachLogin/BranchLogin"; -import PozoDineInIcon from "../../UtillComponents/Pozo retail icons/PozoDineIn"; -import { Messages } from "../../../../../Components/Notifications/Messages"; - -const subDirectory = import.meta.env.BASE_URL; -const MainHomeUrl = import.meta.env.ENV_MAIN_BASE_URL; -const currentDateValue = moment().format('YYYY-MM-DD HH:mm:ss'); - -const StandardTablePayment = () => { - - const { SadminuserAccess } = useAuth(); - let SAAccessCommonMaster = SadminuserAccess?.find( - (e) => e?.MenuName === 'Sales' - ); - const dispatch = useDispatch(); - const navigate = useNavigate(); - const SessionData = useSelector(StoredSessionData); - const BranchId = SessionData?.BranchId; - const AppId = SessionData?.AppId; - const CompId = SessionData?.CompId; - const UserId = SessionData?.UserId; - const UserType = SessionData?.UserType; - - const FontFamily = useSelector(GlobalSelectedFont); - const prodCat = useSelector(GlobalProductCategorie); - const ProdSubCat = useSelector(GlobalProductSubCategorie); - const templateData = useSelector(getTemplateData); - const printerTemplateStyle = useSelector(SelectedPrintTemplate); - const printDatas = useSelector(GlobalprintDatas); - const ReportholdData = useSelector(GlobalReorderHoldDetails); - const FailedTotalAmt = useSelector(GlobalFailedTotalAmt); - const orderCardDetail = useSelector(GlobalOrderCardDetails); - const preOrder = useSelector(GlobalpreOrderOpen); - const OverallOfferAmount = useSelector(Global_OverallOfferAmount); - const SelectedTableDetails = useSelector(GlobalSelectedTableDetails); - const globalTipAmount = useSelector(GlobaltipAmount); - const GlobalExtraCharge = useSelector(globalExtraTotalAmount); - const GlobalSalesPaymentoptions = useSelector(GlobalSalesPaymentoption); - const Discount = - useSelector(Global_OverallOfferAmount) + - Number(useSelector(GlobalComboOfferAmount)); - const OverAllSales = useSelector(GlobalOverAllDiscSales); - const OverAllEstimate = useSelector(GlobalOverAllDiscEstimate); - const OfferCheckedInSetup = templateData?.BookingNavbar?.[1].some( - (item) => item?.OptionName == 'Offer' - ); - const BookingType = useSelector(GlobalBookingType); - const BookingTypeBoth = useSelector(GlobalBookingTypeBoth); - const preferenceDatas = useSelector(PreferenceData); - const preferenceDetails = preferenceDatas?.[0]?.SettingDtlDetails; - const OtherServiceTicketClaim = useSelector(GlobalOtherServiceTicketClaim); - const NavHoldData = useSelector(GlobalNavHoldData); - const SettingDataSelector = useSelector(settingDataSelector); - const [SelectedBookingType, setSelectedBookingType] = useState(null); - const GlobaluseOptions = useSelector(GlobalCommonPaymentOptions); - const SelCustId = useSelector(GlobalSelCustId); - const OrderOfferDetail = useSelector(Global_OrderOfferDetail, shallowEqual); - const GlobProdwisedata = useSelector(GlobalSelProdWiseEst); - const GlobEstBooking = useSelector(GlobalEstimateBooking); - const OtherServicesglobal = useSelector(GlobalOtherSevices); - const OrderType = useSelector(GlobalOrderType); - const unpaidFlow = useSelector(Globalunpaidflow); - const selOption = useSelector(GlobalSelOption); - const paymentloader = useSelector(GlobalPayementloader); - const BookingStatus = useSelector(GlobalBookingStatus); - const GlobalAddCustomerDetails1 = useSelector(GlobalAddCustomerDetails); - const GetCustId = useSelector(GlobalCustId); - 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 [blink, setBlink] = useState(false); - const [showWhatsAppShare, setShowWhatsAppShare] = useState(false); - const [showSMSShare, setSMSShare] = useState(false); - const [formattedDate, setFormattedDate] = useState(''); - const [OrderStatus, setOrderStatus] = useState(true); - const [OtherServicesPrintDetails, setOtherServicesPrintDetails] = useState([]); - const [UpiOpen, setUpiOpen] = useState(false); - const [useOptions, setuseOptions] = useState([]); - const [PaymentOptions, setPaymentOptions] = useState([]); - const [addnewAccess, setaddnewAccess] = useState(true); - const [empData, setEmpData] = useState(); - const [paybtnselected, setPaybtnselected] = useState( - PaymentOptions?.[0]?.ModeId - ); - const [Paybtnnameselected, setPaybtnnameselected] = useState( - PaymentOptions?.[0]?.ModeName - ); - const [payBtns, setPayBtns] = useState(); - console.log(payBtns, "payBtnspayBtns") - const [creditCustomerOpen, setcreditCustomerOpen] = useState(false); - const [Splitpayment, setSplitpayment] = useState(false); - const [PrintOrderDetails, setPrintOrderDetails] = useState([]); - const [PaymentUpiOptions, setPaymentUpiOptions] = useState([]); - const [PaymentDeviceCard, setPaymentDeviceCard] = useState([]); - const [SelectedCardOption, setSelectedCardOption] = useState(null); - const [PaymentgatewayCard, setPaymentgatewayCard] = useState([]); - const [PaymentgatewayUPI, setPaymentgatewayUPI] = useState([]); - const [PaymentDeviceUPI, setPaymentDeviceUPI] = useState([]); - const [ConfigDataList, setConfigDataList] = useState([]); - const [TotalAmount, setTotalAmount] = useState(0); - const [FirstPaymentclick, setFirstPaymentclick] = useState(false); - const [UpinotSelected, setUpinotSelected] = useState(false); - const [brachName, setbrachName] = useState(''); - const [messageType, setMessageType] = useState(null); - const [messageData, setMessageData] = useState(null); - const [UpiOptionOpen, setUpiOptionOpen] = useState(false); - const [SelectedUpiOption, setSelectedUpiOption] = useState(); - const [UpiOption, setUpiOption] = useState(''); - const [UpiId, setUpiId] = useState(); - const [Success, SetSuccess] = useState(); - const [qrCode, setQrCode] = useState(false); - const [CardoptionnotSelected, setCardoptionnotSelected] = useState(false); - const [CreditCustomer, setCreditCustomer] = useState(false); - const [UpiPayOption, setUpiPayOption] = useState([]); - const [SelectedUPIPayOption, setSelectedUPIPayOption] = useState('Default'); - const [CardPayOption, setCardPayOption] = useState([]); - const [MobileNoWhatsApp, setMobileNoWhatsApp] = useState(); - - const allowedNames = ['whatsapp', 'Print', 'SMS']; - - const allowDecimal = preferenceDetails?.find((setting) => - setting?.SettingIdName?.toLowerCase() === "decimal" - && setting?.SettingValue === 'Y' - ); - - const filteredSettingNames = preferenceDetails?.filter((item) => - allowedNames.includes(item?.SettingIdName) - && item?.SettingValue === 'Y' - )?.map((item) => item?.SettingIdName); - - const preferenceOffer = preferenceDetails?.find( - (item) => item.SettingIdName === 'Offer' - )?.SettingValue === 'Y'; - - const UomPrint = preferenceDetails?.filter( - (i) => i.SettingIdName === 'PrintUom' - )?.[0]; - - const Estimation = preferenceDetails?.find( - (item) => item.SettingIdName == 'Estimation' - ); - - const MobileA4Print = preferenceDetails?.find( - (setting) => setting?.SettingIdName?.toLowerCase() === "mobilea4" - && setting?.SettingValue === 'Y' - ); - - const TokenOnly = preferenceDetails?.filter( - (i) => i.SettingIdName === 'TokenOnly' - )?.[0]; - - const IndividualToken = preferenceDetails?.filter( - (i) => i.SettingIdName === 'AllProductindividualToken' - )?.[0]; - - const CheckOrderType = orderCardDetail?.filter( - (a) => a?.BookingTypeName !== BookingType - ); - const CheckBookingStatus = - BookingStatus?.find((item) => item.ScreenType === 'Booking') - ?.ScreenStatus ?? 'Open'; - - const orderIdsArray = - PrintOrderDetails?.[0]?.OrderDetails?.map( - (orderDetail) => orderDetail?.OrderId - ) || []; - const customerNameOrMobile = MobileNoWhatsApp?.CustName?.trim() - ? `Dear ${MobileNoWhatsApp?.CustName}` - : `Dear ${MobileNoWhatsApp?.value}`; - const documentUrl = `${MainHomeUrl}viewbill?code=${orderIdsArray}`; - const encodedMessage = `${customerNameOrMobile},\n\n🙏 Thank you for being a valuable customer!\n\n🧾 To view your bill, please click the link below:\n${documentUrl}`; - - - const isDisabled = - (BookingType === 'Dine In' || BookingTypeBoth || CheckOrderType?.length > 0) && - !unpaidFlow && - OrderStatus; - - const formatAmount = (value) => { - return allowDecimal ? parseFloat(value || 0).toFixed(2) : Math.round(value || 0); - }; - - console.log(BookingType, BookingTypeBoth, CheckOrderType, unpaidFlow, 'ffffffffffff') - useEffect(() => { - if (NavHoldData) { - AddBookingDetails('Hold'); - } - }, [NavHoldData]); - - useEffect(() => { - let hasAccess = false; - - if (UserType === 'Admin' || UserType === 'Super Admin') { - hasAccess = true; - } else if (UserType === 'Employee') { - hasAccess = empData?.AddAccess === 'Y'; - } else if (UserType === 'Super Admin User') { - hasAccess = SAAccessCommonMaster?.AddAccess === 'Y'; - } - - setaddnewAccess(!hasAccess); - }, [empData, SAAccessCommonMaster, UserType]); - - useEffect(() => { - if (selOption) { - closePrintOption(); - setMobileNoWhatsApp(selOption); - } - }, [selOption]); - - useEffect(() => { - const handleKeyPress = (event) => { - if (event.key === 'F4' && isButtonActive() && !isF4Pressed.current) { - isF4Pressed.current = true; - // BranchFinancialStatus==='N'? financialYearError(): - handleButtonClick(); - setTimeout(() => { - isF4Pressed.current = false; // Reset after a short delay - }, 1000); - } - }; - - window.addEventListener('keydown', handleKeyPress); - return () => { - window.removeEventListener('keydown', handleKeyPress); - }; - }, [ - FirstPaymentclick, - orderCardDetail, - paybtnselected, - OrderStatus, - qrCode, - SelectedUPIPayOption, - TotalAmount, - SelectedUpiOption, - SelectedCardOption, - ]); - - useEffect(() => { - const handleKeyPress = (event) => { - if (event.shiftKey && event.code === 'KeyM') { - if ( - document.activeElement.tagName !== 'INPUT' && - document.activeElement.tagName !== 'TEXTAREA' - ) { - event.preventDefault(); - setBlink(true); - } - } - }; - const handleClickOutside = (event) => { - setBlink(false); - }; - window.addEventListener('keydown', handleKeyPress); - window.addEventListener('mousedown', handleClickOutside); - return () => { - window.removeEventListener('keydown', handleKeyPress); - window.addEventListener('mousedown', handleClickOutside); - }; - }, []); - - useEffect(() => { - setPaybtnnameselected(PaymentOptions?.[0]?.ModeName); - setPaybtnselected(PaymentOptions?.[0]?.ModeId); - setQrCode(false); - }, [PaymentOptions]); - - useEffect(() => { - if (!preOrder) { - const totalSum = orderCardDetail?.reduce((acc, card) => acc + parseFloat(card.OrderRate * card.OrderQty || 0), 0); - - const extra = GlobalExtraCharge?.reduce((acc, obj) => acc + (obj.TotalAmt || 0), 0); - - let withComboSum = 0; - const withComboOffer_CardDetail = orderCardDetail?.filter(item => item.Type === 'C'); - if (withComboOffer_CardDetail?.length > 0) { - withComboSum = formatAmount( - withComboOffer_CardDetail.reduce( - (acc, card) => acc + parseFloat(card.OrderRate * card.OrderQty - card.TotalAmt || 0), - 0 - ) - ); - } - - let Total = (extra === undefined - ? totalSum - OverallOfferAmount - withComboSum - : totalSum + extra - OverallOfferAmount - withComboSum - ); - - // Subtract OtherServiceTicketClaim?.totalTicketamount if present and > 0 - if (OtherServiceTicketClaim?.TotalAmt > 0) { - if ((Total - OtherServiceTicketClaim.TotalAmt) > 0) { - Total -= OtherServiceTicketClaim.TotalAmt; - } else { - - dispatch(changeOtherServiceTicketClaim({ - TicketId: null, - TotalAmt: 0, - ParkingClaimed: false, - ServiceCategory: null, - })); - } - - } else if (OtherServiceTicketClaim?.OtherType == "Remove") { - dispatch(changeOtherServiceTicketClaim({ - TicketId: null, - TotalAmt: 0, - ParkingClaimed: false, - ServiceCategory: null, - })); - - } - - let withdiscTotal = Total - ((OverAllSales || 0) + (OverAllEstimate || 0)); - - setTotalAmount( - formatAmount( - withdiscTotal > 0 - ? (Number(withdiscTotal) + Number(globalTipAmount)).toFixed(2) - : (Number(Total) + Number(globalTipAmount)).toFixed(2) - ) - ); - - dispatch( - changeSummeryTotalAmount( - formatAmount(withdiscTotal > 0 ? withdiscTotal : Number(Total)) - ) - ); - - dispatch(changeSummeryComboOfferAmount(withComboSum)); - - if (withdiscTotal <= 0) { - dispatch(ChangeOverAllDiscSales(0)); - dispatch(ChangeOverAllDiscEstimate(0)); - } - } else { - setTotalAmount(0); - dispatch(changeSummeryTotalAmount(0)); - dispatch(changeSummeryComboOfferAmount(0)); - } - }, [orderCardDetail, GlobalExtraCharge, OverAllSales, OverAllEstimate, globalTipAmount, OtherServiceTicketClaim]); - - - useEffect(() => { - if ( - PrintOrderDetails?.length > 0 && - (!filteredSettingNames || - filteredSettingNames?.includes('Print') || - filteredSettingNames?.length === 0) && - ( - (!filteredSettingNames?.includes('whatsapp') && - (!isMobile || !filteredSettingNames?.includes('SMS'))) || - ( - (filteredSettingNames?.includes('whatsapp') || - (isMobile && filteredSettingNames?.includes('SMS'))) && - (!MobileNoWhatsApp || Object.keys(MobileNoWhatsApp).length === 0) - ) - ) - ) { - handlePrintOrToken(); - } - }, [PrintOrderDetails]); - - useEffect(() => { - getPaymentOptionFeature(); - getBookingTypeId(); - }, []) - - useEffect(() => { - getPaymentOptionFeature(); - }, [GlobaluseOptions]); - - useEffect(() => { - getBookingTypeId(); - }, [BookingType]) - - useEffect(() => { - if (SelCustId) { - setPayBtns(PaymentOptions); - } else { - const withoutCustomer = PaymentOptions?.filter?.( - (item) => item?.ModeName?.toLowerCase() !== 'credit' - ); - setPayBtns(withoutCustomer); - } - }, [PaymentUpiOptions, PaymentOptions, SelCustId]); - - useEffect(() => { - if ( - (BookingType === 'Dine In' || - BookingTypeBoth || - CheckOrderType?.length > 0) && - !unpaidFlow - ) { - setOrderStatus(true); - } else { - setOrderStatus(false); - } - }, [BookingTypeBoth, BookingType, unpaidFlow]); - - useEffect(() => { - if (UserType === 'Employee') { - fetchApi() - } - }, [UserType]) - - const isButtonActive = () => { - const baseCondition = - FirstPaymentclick === false && - orderCardDetail?.length > 0 && - paybtnselected && - CheckBookingStatus !== 'Close'; - let accessCondition = true; - if (UserType === 'Employee') { - accessCondition = empData?.AddAccess === 'Y'; - } else if (UserType === 'Super Admin User') { - accessCondition = SAAccessCommonMaster?.AddAccess === 'Y'; - } - return baseCondition && accessCondition; - }; - - const fetchApi = async () => { - let data = { - CompId: CompId, - BranchId: BranchId, - AppId: AppId, - EmpId: UserId, - }; - let response = await dispatch(getEmpAccess(data)).unwrap(); - let datas = response?.data?.data?.[0]?.EmpAccessDetails?.filter( - (item) => item.ConfigName === 'Sales' - ); - setEmpData(datas?.[0]); - }; - - - const handleButtonClick = () => { - if (qrCode && SelectedUPIPayOption === 'Default') { - UpiPayment(); - } else { - OrderStatus - ? AddBookingDetails('Dine-In', false) - : AddBookingDetails(BookingType, true); - } - }; - - const handleCreditCustomer = (type) => { - setCreditCustomer(false); - if (type == 'Submit') { - Booking(BookingType, true); - } - if (type == 'Cancel') { - setPaybtnselected(PaymentOptions?.[0]?.ModeId); - setPaybtnnameselected(PaymentOptions?.[0]?.ModeName); - } - const customerDisplayWindow = getCustomerDisplayWindow(); - if (customerDisplayWindow && !customerDisplayWindow.closed) { - const updatedRemovedData = { - type: 'remove', - keyValue: 'OrderTotalAmount', - }; - customerDisplayWindow.postMessage(updatedRemovedData, '*'); - } else { - console.error( - 'Customer display window is not available or has been closed.' - ); - } - }; - - const getBookingTypeId = async () => { - let tempconfigdata = await dispatch( - getConfigType({ TypeName: 'Booking Type' }) - ).unwrap(); - 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); - } - }; - - const UpiPayment = () => { - if (OrderStatus) { - AddBookingDetails('Dine-In', false); - } else { - if (SelectedUpiOption && TotalAmount == 0) { - Upimodel('Submit'); - } else if (SelectedUpiOption) { - setUpiOpen(true); - const customerDisplayWindow = getCustomerDisplayWindow(); - if (customerDisplayWindow && !customerDisplayWindow.closed) { - const updatedData = { - OrderTotalAmount: TotalAmount, - }; - customerDisplayWindow.postMessage(updatedData, '*'); - } else { - console.error( - 'Customer display window is not available or has been closed.' - ); - } - } else { - setUpinotSelected(true); - setMessageType('error'); - setMessageData('Please Select Upi Option'); - } - } - }; - - const Upimodel = (type) => { - setUpiOpen(false); - - if (type == 'Submit') { - AddBookingDetails(BookingType, true); - } - const customerDisplayWindow = getCustomerDisplayWindow(); - if (customerDisplayWindow && !customerDisplayWindow.closed) { - const updatedRemovedData = { - type: 'remove', - keyValue: 'OrderTotalAmount', - }; - customerDisplayWindow.postMessage(updatedRemovedData, '*'); - } else { - console.error( - 'Customer display window is not available or has been closed.' - ); - } - }; - - const AddBookingDetails = async (value, pay) => { - const customerDisplayWindow = getCustomerDisplayWindow(); - const OnUpiSelected = PaymentOptions?.find( - (item) => item.ModeId === paybtnselected - ); - - if ( - OnUpiSelected?.ModeName?.toLowerCase() === 'upi' && - SelectedUPIPayOption?.toLowerCase() === 'default' - ) { - SetSuccess(false); - setTimeout(function () { - SetSuccess(true); - // Add your state change code here - // For example: - // setNewState(newValue); - }, 3000); - if (SelectedUpiOption) { - Booking(value, pay); - } else { - setUpinotSelected(true); - setMessageType('error'); - setMessageData('Please Select Upi Option'); - } - } - else if ( - OnUpiSelected?.ModeName?.toLowerCase() === 'card' && - PaymentgatewayCard?.length > 0 && - PaymentDeviceCard?.length > 0 - ) { - if (SelectedCardOption) { - if (SelectedCardOption?.toLowerCase() === 'pg') { - if (customerDisplayWindow && !customerDisplayWindow.closed) { - if (SelCustId) { - Booking(value, pay); - } else { - setMessageType('error'); - setMessageData('Please Select Customer'); - } - } else { - setMessageType('error'); - setMessageData('Please Set the customer display'); - } - } else { - Booking(value, pay); - } - } else { - setCardoptionnotSelected(true); - setMessageType('error'); - setMessageData('Please Select Card Option'); - } - } else if (OnUpiSelected?.ModeName?.toLowerCase() === 'credit') { - if (!SelCustId) { - setMessageType('error'); - setMessageData('Please Select Customer'); - } else { - setCreditCustomer(true); - const customerDisplayWindow = getCustomerDisplayWindow(); - if (customerDisplayWindow && !customerDisplayWindow.closed) { - const updatedData = { - OrderTotalAmount: TotalAmount, - }; - customerDisplayWindow.postMessage(updatedData, '*'); - } else { - console.error( - 'Customer display window is not available or has been closed.' - ); - } - } - } else if ( - OnUpiSelected?.ModeName?.toLowerCase() === 'upi' && - SelectedUPIPayOption?.toLowerCase() === 'pg' - ) { - if (customerDisplayWindow && !customerDisplayWindow.closed) { - if (SelCustId) { - Booking(value, pay); - } else { - setMessageType('error'); - setMessageData('Please Select Customer'); - } - } else { - setMessageType('error'); - setMessageData('Please Set the customer display'); - } - } else if ( - OnUpiSelected?.ModeName?.toLowerCase() === 'card' && - SelectedCardOption?.toLowerCase() === 'pg' - ) { - if (customerDisplayWindow && !customerDisplayWindow.closed) { - if (SelCustId) { - Booking(value, pay); - } else { - setMessageType('error'); - setMessageData('Please Select Customer'); - } - } else { - setMessageType('error'); - setMessageData('Please Set the customer display'); - } - } else { - Booking(value, pay); - } - }; - - const Booking = async (value, pay) => { - const TakAwayId = ConfigDataList?.find( - (a) => a?.ConfigName === 'TakeAway' - )?.ConfigId; - const DineinId = ConfigDataList?.find( - (a) => a?.ConfigName === 'Dine In' - )?.ConfigId; - - setFirstPaymentclick(true); - let temporderdetail = orderCardDetail?.map((a) => ({ - ProdId: a.ProdId, - Type: a.Type, - OrderQty: a.OrderQty, - OrderRate: a.OrderRate, - TotalAmt: a.OrderQty * a.OrderRate, - TaxAmt: a.TaxAmt, - RefundQty: 0, - InwardDtlId: a.InwardDtlId, - TaxId: a.TaxId, - ProdNameQty: - UomPrint?.SettingValue === 'N' - ? `${a.ProdName} ${a.UomName?.toLowerCase() === 'half' ? '(Half)' : ''}` - : `${a.ProdName} ${a.Size} ${a.UomName}`, - OrderStatus: 'O', - OrderType: - BookingType === 'Dine In' || - BookingTypeBoth || - Estimation?.SettingValue == 'N' - ? 'S' - : GlobEstBooking === 'OvrAllEst' - ? 'E' - : GlobEstBooking === 'ParEst' - ? GlobProdwisedata?.includes( - a.InwardDtlId + ' ' + a?.BookingTypeName - ) - ? 'E' - : 'S' - : 'S', - SinglePc: a.SinglePc, - BookingType: a.BookingTypeName === 'Dine In' ? DineinId : TakAwayId, - OfferValue: a?.Type === 'C' ? a?.OfferValue : a.Offer, - OfferAmt: a?.Type === 'C' ? a?.TotalAmt : a.Offer, - OfferType: a?.Type === 'C' ? a?.OfferType : '', - CounterName: a?.TokenAvailable === 'Y' ? a?.CounterName : null, - ProductIdentifierDtls: a.ProductIdentifierDtls, - ModelNumber: a.ModelNumber, - BatchRef: a.BatchRef, - })); - const NotSlectedTypeFind = temporderdetail?.find( - (a) => a?.BookingType != SelectedBookingType - ); - const { totalwithouttax, totaltax } = orderCardDetail?.reduce( - (totals, card) => { - totals.totalwithouttax += parseFloat(card.WithoutTaxRate || 0); - totals.totaltax += parseFloat(card.TaxAmt || 0); - return totals; - }, - { totalwithouttax: 0, totaltax: 0 } - ) || { totalwithouttax: 0, totaltax: 0 }; - let updatedOfferDetails = OrderOfferDetail; - if (GlobEstBooking !== 'Sales') { - updatedOfferDetails = OrderOfferDetail?.filter( - (item) => - !( - item.TableName === 'LoyaltyPoints' && - item.TableUniqueName === 'UniqueId' && - item.Type === 'A' - ) - ); - } - let temppostdata = { - CompId: CompId, - BranchId: BranchId, - AppId: AppId, - OrderDate: formattedDate, - OrderType: - Object.keys(ReportholdData)?.length > 0 - ? ReportholdData?.OrderType - : 'S', - CustSuppId: SelCustId ? SelCustId : null, - Reference: 'test', - BookingType: - NotSlectedTypeFind && !BookingTypeBoth - ? NotSlectedTypeFind?.BookingType - : SelectedBookingType, - ServiceProvider: 0, - ActiveStatus: 'A', - CreatedBy: UserId, - AddlInfo: 'test', - BillAmount: totalwithouttax.toFixed(2), - OverallDiscSales: OverAllSales > 0 ? OverAllSales : 0, - OverallDiscEst: OverAllEstimate > 0 ? OverAllEstimate : 0, - TaxAmount: totaltax.toFixed(2), - VatAmount: 0, - NetAmount: Math.round(TotalAmount), - PaymentType: - Paybtnnameselected?.toLowerCase() === 'upi' - ? SelectedUPIPayOption?.toLowerCase() === 'pd' - ? PaymentDeviceUPI?.[0]?.ModeId - : SelectedUPIPayOption?.toLowerCase() === 'pg' - ? PaymentgatewayUPI?.[0]?.ModeId - : paybtnselected - : paybtnselected - ? paybtnselected - : null, - GivenAmt: 0, - BalGiven: 0, - BookingMedia: 'DW', - RefundAmount: 0, - ServiceCategory: OtherServiceTicketClaim?.ServiceCategory || null, - OtherServiceTicketId: OtherServiceTicketClaim?.TicketId || null, - OtherServiceTicketAmount: OtherServiceTicketClaim?.TotalAmt || null, - PaymentStatus: - Paybtnnameselected?.toLowerCase() === 'cash' - ? 'S' - : Paybtnnameselected?.toLowerCase() === 'credit' - ? 'S' - : Paybtnnameselected?.toLowerCase() === 'upi' && - SelectedUPIPayOption?.toLowerCase() === 'default' - ? 'S' - : 'P', - OrderDtlDetails: - Object.keys(ReportholdData)?.length > 0 - ? ProductSummary(temporderdetail) - : temporderdetail, - // (BookingType === "Dine In" || BookingTypeBoth) - ExtraChargeDetails: - GlobalExtraCharge?.length > 0 - ? extrachargesbookingtype(GlobalExtraCharge) - : null, - SalesTableLinkDetails: - SelectedTableDetails?.length > 0 ? globalTipAmount === 0 ? SelectedTableDetails : SelectedTableDetails?.map(item => ({ ...item, "TipsAmount": globalTipAmount })) : null, - - SalesPaymentType: 'normal', - PaymentDetail: [ - { - PaymentType: - Paybtnnameselected?.toLowerCase() === 'upi' - ? SelectedUPIPayOption?.toLowerCase() === 'pd' - ? PaymentDeviceUPI?.[0]?.ModeId - : SelectedUPIPayOption?.toLowerCase() === 'pg' - ? PaymentgatewayUPI?.[0]?.ModeId - : paybtnselected - : paybtnselected - ? paybtnselected - : null, - Amount: Math.round(TotalAmount), - PaymentOptionType: - Paybtnnameselected?.toLowerCase() === 'cash' - ? 'PC' - : Paybtnnameselected?.toLowerCase() === 'credit' - ? 'PC' - : Paybtnnameselected?.toLowerCase() === 'card' - ? SelectedCardOption - : Paybtnnameselected?.toLowerCase() === 'upi' - ? SelectedUPIPayOption?.toLowerCase() === 'default' - ? 'PC' - : SelectedUPIPayOption - : null, - ModeOfPayment: - SelectedUPIPayOption?.toLowerCase() === 'default' - ? PaymentUpiOptions?.find((upipay) => upipay?.UPIId === UpiId) - ?.UPIDetailId - : null, - AccountDtl: - Paybtnnameselected?.toLowerCase() === 'upi' && - SelectedUPIPayOption?.toLowerCase() === 'default' - ? useOptions?.[0]?.PaymentDetails?.Payatthecounter?.find( - (upipay) => upipay?.UPIId === UpiId - ) - : (Paybtnnameselected?.toLowerCase() === 'upi' && - SelectedUPIPayOption?.toLowerCase() === 'pd') || - (Paybtnnameselected?.toLowerCase() === 'card' && - SelectedCardOption?.toLowerCase() === 'pd') - ? useOptions?.[0]?.PaymentDetails?.PaymentDevice - : (Paybtnnameselected?.toLowerCase() === 'upi' && - SelectedUPIPayOption?.toLowerCase() === 'pg') || - (Paybtnnameselected?.toLowerCase() === 'card' && - SelectedCardOption?.toLowerCase() === 'pg') - ? useOptions?.[0]?.PaymentDetails?.PaymentGateway - : [], - PaymentStatus: - Paybtnnameselected?.toLowerCase() === 'cash' - ? 'S' - : Paybtnnameselected?.toLowerCase() === 'credit' - ? 'S' - : Paybtnnameselected?.toLowerCase() === 'upi' && - SelectedUPIPayOption?.toLowerCase() === 'default' - ? 'S' - : 'P', - Debit: 0, - Credit: - Paybtnnameselected?.toLowerCase() === 'credit' - ? Math.round(TotalAmount) - : 0, - }, - ], - OrderOfferDetail: updatedOfferDetails, - }; - let PostData = temppostdata; - - if (value === 'Dine-In') { - PostData['PaymentStatus'] = pay ? 'S' : 'P'; - PostData['PaymentDetail'] = !pay && []; - PostData['PaymentType'] = !pay && ''; - } else if (value === 'Hold') { - (PostData['PaymentStatus'] = pay ? 'S' : 'P'), - (PostData['PaymentDetail'] = !pay && []); - PostData['PaymentType'] = !pay && ''; - PostData['ActiveStatus'] = pay ? 'A' : 'D'; - } else if (value === 'Unpaid') { - PostData['PaymentStatus'] = pay ? 'S' : 'P'; - PostData['PaymentDetail'] = !pay && []; - PostData['PaymentType'] = !pay && ''; - PostData['PrintType'] = 'Y'; - } - Object.keys(ReportholdData)?.length > 0 - ? OrderType === 'Failed' - ? PutFailedPayment(PostData, value, pay) - : PutBooking(PostData, value, pay) - : !OtherServicesglobal ? PostBooking(PostData, value) : OtherServicePostBooking(PostData, value); - getstockbadge(); - Combocarddata(); - }; - - const PostBooking = async (PostData, value) => { - let response = await dispatch(PostBookingData(PostData)).unwrap(); - if (response?.data?.statusCode == 1) { - let Paymentdevicefilter = response?.data?.PaymentOrderDtl?.filter( - (item) => - item?.PaymentOptionType?.toLowerCase() === 'pd' && - item?.PaymentStatus === 'P' - ); - let PaymentGatewayfilter = response?.data?.PaymentOrderDtl?.filter( - (item) => - item?.PaymentOptionType?.toLowerCase() === 'pg' && - item?.PaymentStatus === 'P' - ); - let PayatCounterfilter = response?.data?.PaymentOrderDtl?.filter( - (item) => item?.PaymentOptionType?.toLowerCase() === 'pc' - ); - if ( - PayatCounterfilter?.length === 1 || - response?.data?.PaymentOrderDtl?.length === 0 - ) { - setMessageType('success'); - setMessageData( - response?.data?.response + - ' ' + - (response?.data?.OrderDetails?.length > 0 - ? response?.data?.OrderId && - extractLastNumberOrderId( - response?.data?.OrderId, - response?.data?.OrderDetails?.[0]?.FYStatus - ) - : '') - ); - response?.data?.OrderDetails?.length > 0 && - setPrintOrderDetails([response?.data]); - CustomerDisplay(value); - ClearAllGlobalStateDatas(value); - } - - if (Paymentdevicefilter?.length === 1) { - if ( - Paymentdevicefilter?.[0]?.PaymentOptionType?.toLowerCase() === 'pd' - ) { - PaymentDeviceFlow(Paymentdevicefilter, value); - } - } else { - console.log('more pd data'); - } - if (PaymentGatewayfilter?.length === 1) { - if ( - PaymentGatewayfilter?.[0]?.PaymentOptionType?.toLowerCase() === 'pg' - ) { - await dispatch(changePaymentloader(true)); - const customerDisplayWindow = getCustomerDisplayWindow(); - if (customerDisplayWindow && !customerDisplayWindow.closed) { - const updatedData = { - OrderBookingId: PaymentGatewayfilter?.[0]?.OrderId, - Paymentgateway: true, - OrderPaymentId: PaymentGatewayfilter?.[0]?.PaymentOrderId, - OrderTotalAmount: PaymentGatewayfilter?.[0]?.Amount, - }; - customerDisplayWindow.postMessage(updatedData, '*'); - } else { - console.error( - 'Customer display window is not available or has been closed.' - ); - } - const checkPaymentStatus = async () => { - const intervalId = setInterval(async () => { - try { - let getpaymentgatewaydetail = await dispatch( - PaymentGatewayGetdetail(PaymentGatewayfilter?.[0]?.OrderId) - ).unwrap(); - - if (getpaymentgatewaydetail?.data?.statusCode === 1) { - let paymentdataget = - getpaymentgatewaydetail?.data?.PaymentOrderDtl?.find( - (item) => - item?.PaymentOrderId === - PaymentGatewayfilter?.[0]?.PaymentOrderId - )?.PaymentStatus; - - if (paymentdataget === 'S') { - setMessageType('success'); - setMessageData('Payment Success'); - await dispatch(changePaymentloader(false)); - if ( - getpaymentgatewaydetail?.data?.OrderDetails?.length > 0 - ) { - setPrintOrderDetails([getpaymentgatewaydetail?.data]); - CustomerDisplay(value); - ClearAllGlobalStateDatas(value); - } - - clearInterval(intervalId); // Stop the loop when payment is successful - } else if (paymentdataget === 'F') { - setMessageType('error'); - setMessageData('Payment Failed'); - setFirstPaymentclick(false); - await dispatch(changePaymentloader(false)); - setPaybtnselected(PaymentOptions?.[0]?.ModeId); - setPaybtnnameselected(PaymentOptions?.[0]?.ModeName); - clearInterval(intervalId); // Stop the loop when payment fails - CustomerDisplayRemovedData(); - ClearAllGlobalStateDatas(value); - } - } - } catch (error) { - console.error('Error fetching payment details: ', error); - } - }, 3000); // Call the API every 3 seconds - }; - - // Call the function to start checking payment status - checkPaymentStatus(); - } - } - else { - console.log('more pg data'); - } - } - else { - setMessageType('error'); - setMessageData(response?.data?.response); - setFirstPaymentclick(false); - } - }; - - const PutBooking = async (putdatas, value, pay) => { - let putdata = putdatas; - putdata['OrderId'] = ReportholdData?.OrderId; - putdata['SalesId'] = ReportholdData?.SalesId; - putdata['UpdatedBy'] = UserId; - if (value === 'Dine-In') { - putdata['PaymentStatus'] = pay ? 'S' : 'P'; - putdata['PaymentDetail'] = !pay && []; - putdata['PaymentType'] = !pay && ''; - } else if (value === 'Hold') { - (putdata['PaymentStatus'] = pay ? 'S' : 'P'), - (putdata['PaymentDetail'] = !pay && []); - putdata['PaymentType'] = !pay && ''; - putdata['ActiveStatus'] = pay ? 'A' : 'D'; - } else if (value === 'Unpaid') { - putdata['PaymentStatus'] = pay ? 'S' : 'P'; - putdata['PaymentDetail'] = !pay && []; - putdata['PaymentType'] = !pay && ''; - putdata['PrintType'] = 'Y'; - } - let response = await dispatch(PutBookingData(putdata)).unwrap(); - if (value !== 'Unpaid') { - if (response?.data?.statusCode == 1) { - let Paymentdevicefilter = response?.data?.PaymentOrderDtl?.filter( - (item) => - item?.PaymentOptionType?.toLowerCase() === 'pd' && - item?.PaymentStatus === 'P' - ); - let PaymentGatewayfilter = response?.data?.PaymentOrderDtl?.filter( - (item) => - item?.PaymentOptionType?.toLowerCase() === 'pg' && - item?.PaymentStatus === 'P' - ); - let PayatCounterfilter = response?.data?.PaymentOrderDtl?.filter( - (item) => item?.PaymentOptionType?.toLowerCase() === 'pc' - ); - if ( - PayatCounterfilter?.length === 1 || - response?.data?.PaymentOrderDtl?.length === 0 - ) { - setMessageType('success'); - setMessageData( - response?.data?.response + - ' ' + - (response?.data?.OrderDetails?.length > 0 - ? response?.data?.OrderId && - extractLastNumberOrderId( - response?.data?.OrderId, - response?.data?.OrderDetails?.[0]?.FYStatus - ) - : '') - ); - response?.data?.OrderDetails?.length > 0 && - setPrintOrderDetails([response?.data]); - CustomerDisplay(value); - ClearAllGlobalStateDatas(value); - } - if (Paymentdevicefilter?.length === 1) { - if ( - Paymentdevicefilter?.[0]?.PaymentOptionType?.toLowerCase() === 'pd' - ) { - PaymentDeviceFlow(Paymentdevicefilter, value); - } - } else { - console.log('more pd data'); - } - if (PaymentGatewayfilter?.length === 1) { - PaymentGatewayFlow(PaymentGatewayfilter); - } else { - console.log('more pg data'); - } - } - } else { - setPrintOrderDetails([response?.data]); - await dispatch(changeOrderCardDetails([])); - await dispatch(changeReorderHoldDetails({})); - await dispatch(changeReorderProductDetails([])); - setFirstPaymentclick(false); - await dispatch(changeBookingType('TakeAway')); - await dispatch(changeSelectTable([])); - await dispatch(changeSelectChair([])); - getUnpaiddatas(); - } - }; - - const PutFailedPayment = async (PayData, value, pay) => { - let tempsplitdata = { - CompId: PayData?.CompId, - BranchId: PayData?.BranchId, - AppId: PayData?.AppId, - CustSuppId: PayData?.SelCustId ? SelCustId : null, - UpdatedBy: UserId, - OrderId: ReportholdData?.OrderId, - PaymentType: PayData?.PaymentDetail?.[0]?.PaymentType, - Amount: FailedTotalAmt, - PaymentOptionType: PayData?.PaymentDetail?.[0]?.PaymentOptionType, - ModeOfPayment: PayData?.PaymentDetail?.[0]?.ModeOfPayment, - AccountDtl: PayData?.PaymentDetail?.[0]?.AccountDtl, - PaymentStatus: PayData?.PaymentDetail?.[0]?.PaymentStatus, - Debit: PayData?.PaymentDetail?.[0]?.Debit, - Credit: PayData?.PaymentDetail?.[0]?.Credit, - }; - - let response = await dispatch( - putSplitpaymentStatus(tempsplitdata) - ).unwrap(); - if (response?.data?.statusCode == 1) { - let Paymentdevicefilter = response?.data?.PaymentOrderDtl?.filter( - (item) => - item?.PaymentOptionType?.toLowerCase() === 'pd' && - item?.PaymentStatus === 'P' - ); - let PaymentGatewayfilter = response?.data?.PaymentOrderDtl?.filter( - (item) => - item?.PaymentOptionType?.toLowerCase() === 'pg' && - item?.PaymentStatus === 'P' - ); - let PayatCounterfilter = response?.data?.PaymentOrderDtl?.filter( - (item) => - item?.PaymentOptionType?.toLowerCase() === 'pc' && - item?.PaymentType === PayData?.PaymentDetail?.[0]?.PaymentType - ); - if ( - PayatCounterfilter?.length > 0 || - response?.data?.PaymentOrderDtl?.length === 0 - ) { - setMessageType('success'); - - // setSplitSelPayMode({...SplitSelPayMode,...{[`PaymentStatus-${i}`]:"S"}}) - - const customerDisplayWindow = getCustomerDisplayWindow(); - if (customerDisplayWindow && !customerDisplayWindow.closed) { - const updatedData = { - upi: null, - }; - customerDisplayWindow.postMessage(updatedData, '*'); - } else { - console.error( - 'Customer display window is not available or has been closed.' - ); - } - setMessageData( - response?.data?.response + - ' ' + - (response?.data?.OrderDetails?.length > 0 - ? response?.data?.OrderId && - extractLastNumberOrderId( - response?.data?.OrderId, - response?.data?.OrderDetails?.[0]?.FYStatus - ) - : '') - ); - if (response?.data?.OrderDetails?.length > 0) { - setPrintOrderDetails([response?.data]); - CustomerDisplay(); - ClearAllGlobalStateDatas(); - } - } - if (Paymentdevicefilter?.length === 1) { - if ( - Paymentdevicefilter?.[0]?.PaymentOptionType?.toLowerCase() === 'pd' - ) { - PaymentDeviceFlow(Paymentdevicefilter, value); - } - } - - if (PaymentGatewayfilter?.length === 1) { - if ( - PaymentGatewayfilter?.[0]?.PaymentOptionType?.toLowerCase() === 'pg' - ) { - PaymentGatewayFlow(PaymentGatewayfilter, value); - } - } - } - }; - - const OtherServicePostBooking = async (PostData, value) => { - console.log(PostData, value, "PostData, value"); - - let postdata = { - "AppId": AppId, - "CompId": CompId, - "BranchId": BranchId, - "BillAmount": PostData?.BillAmount, - "TaxAmount": PostData?.TaxAmount, - "NetAmount": PostData?.NetAmount, - "OtherServicesTicketDetails": orderCardDetail.map((item) => ({ - ServiceId: item.ServiceId, - ServiceCategory: item.ServiceCategory, - VehicleNumber: item.VehicleNo || "", - Qty: item.OrderQty, - Rate: item.Rate, - TaxAmount: item.TaxAmt, - TotalAmount: item.TotalAmt - })), - PaymentDetail: PostData?.PaymentDetail, - "CreatedBy": UserId - } - - let Response = await dispatch(PostOtherServices(postdata)).unwrap(); - - if (Response?.data?.statusCode == 1) { - setMessageType('success'); - setMessageData(Response?.data?.response); - ClearAllGlobalStateDatas(value); - setOtherServicesPrintDetails([Response?.data?.OtherServicesTicketDetails?.[0]]); - } - - console.log(postdata, "PostdataPostdataPostdata"); - - } - - const getstockbadge = async () => { - let data = { - CompId: CompId, - BranchId: BranchId, - AppId: AppId, - }; - await dispatch(getSelectedFavItems(data)).unwrap(); - - let data1 = { - CompId: CompId, - BranchId: BranchId, - AppId: AppId, - ProdSubCat: ProdSubCat, - }; - - let data2 = { - compId: CompId, - branchId: BranchId, - appId: AppId, - prodCat: prodCat, - }; - - if ( - templateData?.BookingLayout?.[1]?.some( - (item) => item?.OptionName === 'SubCategory' - ) && - ProdSubCat - ) { - await dispatch(getLayoutproductCard(data1)).unwrap(); - } else if ( - !templateData?.BookingLayout?.[1]?.some( - (item) => item?.OptionName === 'SubCategory' - ) - ) { - await dispatch(getCardDataWithoutSubmodule(data2)).unwrap(); - } else { - await dispatch(getCardDataWithoutSub(data2)).unwrap(); - } - }; - - const Combocarddata = async () => { - let data = { - CompId: CompId, - BranchId: BranchId, - AppId: AppId, - ActiveStatus: 'A', - }; - - let response = await dispatch(getCombolist(data)).unwrap(); - let datas = response?.data?.data; - await dispatch(ChangeComboCarddata(datas)); - if (response?.data?.statusCode === 1) { - // let Data = response?.data?.data - // let comboList = Data?.map((item, index) => ({ - // ...item, - // id: `${item.ComboName || 'Combo'}-${index}`, - // ProdName:item?.ComboName, - // OverAllQty:item?.OverallQuantity - // })); - // setCombocardata(comboList); - } - }; - - const CustomerDisplay = (value) => { - const customerDisplayWindow = getCustomerDisplayWindow(); - if (value == 'TakeAway') { - if (customerDisplayWindow && !customerDisplayWindow.closed) { - const updatedData = { - userData: [], - ExtraCharges: [], - Paymentgateway: false, - upioption1: 'okk', - type: 'remove', - keyValue: 'customer', - }; - customerDisplayWindow.postMessage(updatedData, '*'); - const updatedRemovedData = { - type: 'remove', - keyValue: 'OrderTotalAmount', - }; - customerDisplayWindow.postMessage(updatedRemovedData, '*'); - } else { - console.error( - 'Customer display window is not available or has been closed.' - ); - } - } else { - if (customerDisplayWindow && !customerDisplayWindow.closed) { - const updatedData = { - type: 'remove', - keyValue: 'customer', - }; - customerDisplayWindow.postMessage(updatedData, '*'); - } else { - console.error( - 'Customer display window is not available or has been closed.' - ); - } - } - }; - - const CustomerDisplayRemovedData = () => { - const customerDisplayWindow = getCustomerDisplayWindow(); - if (customerDisplayWindow && !customerDisplayWindow.closed) { - const updatedData = { - userData: [], - ExtraCharges: [], - Paymentgateway: false, - type: 'remove', - keyValue: 'customer', - }; - customerDisplayWindow.postMessage(updatedData, '*'); - const updatedRemovedData = { - type: 'remove', - keyValue: 'OrderTotalAmount', - }; - customerDisplayWindow.postMessage(updatedRemovedData, '*'); - } else { - console.error( - 'Customer display window is not available or has been closed.' - ); - } - }; - - const PaymentDeviceFlow = async (Paymentdevicefilter, value) => { - await dispatch(changePaymentloader(true)); - await dispatch( - changePaymentTransactionNumber(Paymentdevicefilter?.[0]?.PaymentOrderId) - ); - let paymentdetail = { - TransactionNumber: Paymentdevicefilter?.[0]?.PaymentOrderId, - SequenceNumber: 1, - AllowedPaymentMode: - Paymentdevicefilter?.[0]?.PaymentTypeName?.toLowerCase() === 'card' - ? '1' - : Paymentdevicefilter?.[0]?.PaymentTypeName?.toLowerCase() === 'upi' - ? '10' - : '', - Amount: `${parseInt(Paymentdevicefilter?.[0]?.Amount) * 100}`, - ClientID: useOptions?.[0]?.PDConfigDetails?.[0]?.ClientId, - StoreID: useOptions?.[0]?.PDConfigDetails?.[0]?.StoreId, - UserID: useOptions?.[0]?.PDConfigDetails?.[0]?.UserId, - MerchantID: useOptions?.[0]?.PDConfigDetails?.[0]?.MerchantId, - SecurityToken: useOptions?.[0]?.PDConfigDetails?.[0]?.SecurityToken, - IMEI: useOptions?.[0]?.PDConfigDetails?.[0]?.IMEI, - AutoCancelDurationInMinutes: - useOptions?.[0]?.PDConfigDetails?.[0]?.AutoCancelDurationInMinutes, - }; - let apiresponse = await dispatch(PostPaymentdevice(paymentdetail)).unwrap(); - if (apiresponse?.ResponseMessage?.toLowerCase() === 'approved') { - let pendingPaymentList = { - MerchantID: useOptions?.[0]?.PDConfigDetails?.[0]?.MerchantId, - SecurityToken: useOptions?.[0]?.PDConfigDetails?.[0]?.SecurityToken, - ClientID: useOptions?.[0]?.PDConfigDetails?.[0]?.ClientId, - StoreID: useOptions?.[0]?.PDConfigDetails?.[0]?.StoreId, - IMEI: useOptions?.[0]?.PDConfigDetails?.[0]?.IMEI, - PlutusTransactionReferenceId: apiresponse?.PlutusTransactionReferenceID, - PaymentOrderId: Paymentdevicefilter?.[0]?.PaymentOrderId, - UpdatedBy: UserId, - }; - await dispatch(PutPendingPaymentList(pendingPaymentList)).unwrap(); - let isApproved = false; - const startTime = Date.now(); - let postpaymentdata = { - MerchantID: useOptions?.[0]?.PDConfigDetails?.[0]?.MerchantId, - SecurityToken: useOptions?.[0]?.PDConfigDetails?.[0]?.SecurityToken, - ClientID: useOptions?.[0]?.PDConfigDetails?.[0]?.ClientId, - StoreID: useOptions?.[0]?.PDConfigDetails?.[0]?.StoreId, - IMEI: useOptions?.[0]?.PDConfigDetails?.[0]?.IMEI, - PlutusTransactionReferenceID: apiresponse?.PlutusTransactionReferenceID, - }; - // Loop to call the second API every 3 seconds - while (!isApproved) { - let ApiResponseget = await dispatch( - GetPaymentdeviceResponse(postpaymentdata) - ).unwrap(); - - if (ApiResponseget?.ResponseMessage?.toLowerCase() === 'txn approved') { - let putbookingdata = { - OrderBookingId: Paymentdevicefilter?.[0]?.OrderId, - OrderId: Paymentdevicefilter?.[0]?.PaymentOrderId, - PaymentStatus: 'S', - Amount: Paymentdevicefilter?.[0]?.Amount, - ResponseDtl: [ApiResponseget], - PaymentType: Paymentdevicefilter?.[0]?.PaymentType, - UpdatedBy: UserId, - }; - - let bookingpaymentupdate = await dispatch( - PutBookingPaymentStatusChange(putbookingdata) - ).unwrap(); - if (bookingpaymentupdate?.data?.statusCode === 1) { - setMessageType('success'); - setMessageData( - bookingpaymentupdate?.data?.response + - ' ' + - (bookingpaymentupdate?.data?.OrderDetails?.length > 0 - ? bookingpaymentupdate?.data?.OrderId && - extractLastNumberOrderId( - bookingpaymentupdate?.data?.OrderId, - bookingpaymentupdate?.data?.OrderDetail?.[0]?.FYStatus - ) - : '') - ); - bookingpaymentupdate?.data?.OrderDetails?.length > 0 && - setPrintOrderDetails([bookingpaymentupdate?.data]); - CustomerDisplay(value); - ClearAllGlobalStateDatas(value); - await dispatch(changePaymentloader(false)); - } - isApproved = true; - console.log('Transaction Approved!'); - // Exit the loop - break; - } - - // Check if 1 minute has passed - if ( - Date.now() - startTime > - useOptions?.[0]?.PDConfigDetails?.[0]?.AutoCancelDurationInMinutes * - 60000 - ) { - // 60,000 ms = 1 minute - - let putbookingdata = { - OrderBookingId: Paymentdevicefilter?.[0]?.OrderId, - OrderId: Paymentdevicefilter?.[0]?.PaymentOrderId, - PaymentStatus: 'F', - Amount: Paymentdevicefilter?.[0]?.Amount, - ResponseDtl: [ApiResponseget], - PaymentType: Paymentdevicefilter?.[0]?.PaymentType, - UpdatedBy: UserId, - }; - - let bookingpaymentupdate = await dispatch( - PutBookingPaymentStatusChange(putbookingdata) - ).unwrap(); - if (bookingpaymentupdate?.data?.statusCode === 1) { - setMessageType('error'); - setMessageData( - `Payment Failed. Your Transaction Number is ${Paymentdevicefilter?.[0]?.PaymentOrderId}` - ); - setFirstPaymentclick(false); - setPaybtnselected(PaymentOptions?.[0]?.ModeId); - setPaybtnnameselected(PaymentOptions?.[0]?.ModeName); - await dispatch(changePaymentloader(false)); - CustomerDisplayRemovedData(); - ClearAllGlobalStateDatas(value); - } - - console.error('Transaction not approved within 1 minute.'); - // Send an error message or handle the timeout - // You can dispatch an action, show a notification, etc. - break; - } - - // Wait for 3 seconds before making the next call - await new Promise((resolve) => setTimeout(resolve, 3000)); - } - } else { - let putbookingdata = { - OrderBookingId: Paymentdevicefilter?.[0]?.OrderId, - OrderId: Paymentdevicefilter?.[0]?.PaymentOrderId, - PaymentStatus: 'F', - Amount: Paymentdevicefilter?.[0]?.Amount, - PaymentType: Paymentdevicefilter?.[0]?.PaymentType, - UpdatedBy: UserId, - }; - let bookingpaymentupdate = await dispatch( - PutBookingPaymentStatusChange(putbookingdata) - ).unwrap(); - if (bookingpaymentupdate?.data?.statusCode === 1) { - setMessageType('error'); - setMessageData(apiresponse?.ResponseMessage); - setFirstPaymentclick(false); - setPaybtnselected(PaymentOptions?.[0]?.ModeId); - setPaybtnnameselected(PaymentOptions?.[0]?.ModeName); - dispatch(changePaymentloader(false)); - CustomerDisplayRemovedData(); - ClearAllGlobalStateDatas(value); - } - } - }; - - const PaymentGatewayFlow = async (PaymentGatewayfilter) => { - if (PaymentGatewayfilter?.[0]?.PaymentOptionType?.toLowerCase() === 'pg') { - await dispatch(changePaymentloader(true)); - const customerDisplayWindow = getCustomerDisplayWindow(); - if (customerDisplayWindow && !customerDisplayWindow.closed) { - const updatedData = { - OrderBookingId: PaymentGatewayfilter?.[0]?.OrderId, - Paymentgateway: true, - OrderPaymentId: PaymentGatewayfilter?.[0]?.PaymentOrderId, - OrderTotalAmount: PaymentGatewayfilter?.[0]?.Amount, - }; - customerDisplayWindow.postMessage(updatedData, '*'); - } else { - console.error( - 'Customer display window is not available or has been closed.' - ); - } - const checkPaymentStatus = async () => { - const intervalId = setInterval(async () => { - try { - let getpaymentgatewaydetail = await dispatch( - PaymentGatewayGetdetail(PaymentGatewayfilter?.[0]?.OrderId) - ).unwrap(); - - if (getpaymentgatewaydetail?.data?.statusCode === 1) { - let paymentdataget = - getpaymentgatewaydetail?.data?.PaymentOrderDtl?.find( - (item) => - item?.PaymentOrderId === - PaymentGatewayfilter?.[0]?.PaymentOrderId - )?.PaymentStatus; - - if (paymentdataget === 'S') { - setMessageType('success'); - setMessageData('Payment Success'); - await dispatch(changePaymentloader(false)); - if (getpaymentgatewaydetail?.data?.OrderDetails?.length > 0) { - setPrintOrderDetails([getpaymentgatewaydetail?.data]); - CustomerDisplay(value); - ClearAllGlobalStateDatas(value); - } - clearInterval(intervalId); // Stop the loop when payment is successful - } else if (paymentdataget === 'F') { - setMessageType('error'); - setMessageData('Payment Failed'); - await dispatch(changePaymentloader(false)); - setFirstPaymentclick(false); - setPaybtnselected(PaymentOptions?.[0]?.ModeId); - setPaybtnnameselected(PaymentOptions?.[0]?.ModeName); - clearInterval(intervalId); // Stop the loop when payment fails - CustomerDisplayRemovedData(); - ClearAllGlobalStateDatas(value); - // const customerDisplayWindow = getCustomerDisplayWindow(); - // if (customerDisplayWindow && !customerDisplayWindow.closed) { - // const updatedData = { - // userData: orderCardDetail, - // ExtraCharges: GlobalExtraCharge, - // upi: GlobalUpiID, - // customer: selOption != null ? selOption : GetCustId, - // paymentMethod: Paybtnnameselected, - // Paymentgateway: false, - // OrderTotalAmount: PaymentGatewayfilter?.[0]?.Amount - - // }; - // customerDisplayWindow.postMessage(updatedData, '*'); - // } - } - } - } catch (error) { - console.error('Error fetching payment details: ', error); - } - }, 3000); // Call the API every 3 seconds - }; - - // Call the function to start checking payment status - checkPaymentStatus(); - } - }; - - const getPaymentOptionFeature = async () => { - - const FiltersalesPayment = GlobaluseOptions?.filter( - (item) => item.FlowName?.toLowerCase() === 'sales' - ); - setuseOptions(FiltersalesPayment); - const filterpaycounter = FiltersalesPayment?.[0]?.OptionDetails?.filter( - (item) => item?.OptionName?.toLowerCase() === 'pay at the counter' - ); - const filterpaymentgateway = FiltersalesPayment?.[0]?.OptionDetails?.filter( - (item) => item?.OptionName?.toLowerCase() === 'payment gateway' - ); - const filterpaymentdevice = FiltersalesPayment?.[0]?.OptionDetails?.filter( - (item) => item?.OptionName?.toLowerCase() === 'payment device' - ); - const cardinpaymentgateway = - filterpaymentgateway?.[0]?.ModeDetails?.filter((item) => - item?.ModeName?.toLowerCase()?.includes('card') - ) || []; - const cardinpaymentdevice = - filterpaymentdevice?.[0]?.ModeDetails?.filter((item) => - item?.ModeName?.toLowerCase()?.includes('card') - ) || []; - - const upiinpaymentgateway = - filterpaymentgateway?.[0]?.ModeDetails?.filter((item) => - item?.ModeName?.toLowerCase()?.includes('upi') - ) || []; - const upiinpaymentdevice = - filterpaymentdevice?.[0]?.ModeDetails?.filter((item) => - item?.ModeName?.toLowerCase()?.includes('upi') - ) || []; - - setPaymentOptions(filterpaycounter?.[0]?.ModeDetails); - setPaymentUpiOptions( - FiltersalesPayment?.[0]?.PaymentDetails?.Payatthecounter - ); - setPaymentDeviceCard(cardinpaymentdevice); - setPaymentgatewayCard(cardinpaymentgateway); - setPaymentgatewayUPI(upiinpaymentgateway); - setPaymentDeviceUPI(upiinpaymentdevice); - const cardoptions = []; - if (cardinpaymentgateway?.length > 0) { - cardoptions.push({ - label: 'Payment Gateway', - value: 'PG', - imgSrc: paygate, - }); - } - if (cardinpaymentdevice?.length > 0) { - cardoptions.push({ - label: 'Payment Device', - value: 'PD', - imgSrc: paydevice, - }); - } - setCardPayOption(cardoptions); - const options = []; - - if (FiltersalesPayment?.[0]?.PaymentDetails?.Payatthecounter?.length > 0) { - options.push({ - label: 'Default UPI', - value: 'Default', - imgSrc: defaultupi, - }); - } - - if (upiinpaymentgateway?.length > 0) { - options.push({ label: 'Payment Gateway', value: 'PG', imgSrc: paygate }); - } - - if (upiinpaymentdevice?.length > 0) { - options.push({ label: 'Payment Device', value: 'PD', imgSrc: paydevice }); - } - setUpiPayOption(options); - // } - }; - - const ProductSummary = (salesData) => { - // Create a map to store the aggregated values for each unique product - const productMap = new Map(); - // Iterate over the sales data to aggregate values - salesData.forEach((item) => { - const key = `${item.ProdId}-${item.InwardDtlId}-${item.BookingType}-${item.SinglePc}-${item.OrderRate}`; - if (productMap.has(key)) { - const existingItem = productMap.get(key); - existingItem.OrderQty += item.OrderQty || 0; - existingItem.TotalAmt += item.TotalAmt || 0; - existingItem.TaxAmt = - parseFloat(existingItem.TaxAmt) + parseFloat(item.TaxAmt) || 0; - } else { - // If the key doesn't exist, add a new entry - productMap.set(key, { ...item }); - } - }); - - // Convert the map values back to an array - const aggregatedProducts = Array.from(productMap.values()); - - return aggregatedProducts; - }; - - const extrachargesbookingtype = (extradata) => { - const TakAwayId = ConfigDataList?.find( - (a) => a?.ConfigName === 'TakeAway' - )?.ConfigId; - const DineinId = ConfigDataList?.find( - (a) => a?.ConfigName === 'Dine In' - )?.ConfigId; - let tempdata = extradata?.map((data) => ({ - ...data, - BookingType: data?.BookingTypeName === 'Dine In' ? DineinId : TakAwayId, - })); - return tempdata; - }; - - const getUnpaiddatas = async () => { - let data = { - CompId: CompId, - BranchId: BranchId, - AppId: AppId, - }; - await dispatch(getUnpaidData(data)).unwrap(); - }; - - const AddUPIPaymentOption = async (data) => { - setSelectedUpiOption(''); - setUpiOption(''); - setUpiId(''); - await dispatch(changeUpiIDprint(null)); - await dispatch(changeUpiIDName('')); - await dispatch(changeUpiIDoptionId(null)); - setSelectedUPIPayOption(data); - setUpinotSelected(false); - setCardoptionnotSelected(false); - if (data !== 'Default') { - setUpiOptionOpen(false); - } - }; - - const hideDefault = () => { - setUpiOptionOpen(false); - }; - - const handleUPIButtonClick = (id, name) => { - if (paymentloader === false) { - setPaybtnnameselected(name); - setPaybtnselected(id); - let brachName1 = PaymentUpiOptions?.[0]?.BrName; - setbrachName(brachName1); - if (UpiPayOption?.length === 1) { - setSelectedUPIPayOption(UpiPayOption?.[0]?.value); - if (UpiPayOption?.[0]?.value?.toLowerCase() === 'default') { - if (PaymentUpiOptions?.length === 1) { - addUpiOption( - PaymentUpiOptions?.[0]?.Mode, - PaymentUpiOptions?.[0]?.ModeName, - PaymentUpiOptions?.[0]?.UPIId - ); - } - } - } - - setQrCode(true); - SetSuccess(true); - } - }; - - const handlePaymentMode = (id, name) => { - if (paymentloader === false) { - setPaybtnselected(id); - setPaybtnnameselected(name); - if (CardPayOption?.length === 1) { - setSelectedCardOption(CardPayOption?.[0]?.value); - } - setUpiOptionOpen(false); - setQrCode(false); - setUpinotSelected(false); - setCardoptionnotSelected(false); - } - }; - - const addUpiOption = async (id, name, UPIId) => { - await dispatch(changeUpiIDprint(UPIId)); - await dispatch(changeUpiIDName(name)); - await dispatch(changeUpiIDoptionId(id)); - setSelectedUpiOption(id); - setUpiOption(name); - setUpiId(UPIId); - setUpinotSelected(false); - setCardoptionnotSelected(false); - // setQrCode(true) - }; - - const ClearAllGlobalStateDatas = async (value) => { - if (OfferCheckedInSetup && preferenceOffer) { - await applyOffer([]); - } else { - dispatch(changeOrderCardDetails([])); - } - dispatch(changeOtherServiceTicketClaim({ - TotalAmt: 0, - ParkingClaimed: false, - })); - dispatch(changeTipAmount(0)); - await dispatch(ChangeTotalAmount([])); - await dispatch(changeReorderHoldDetails({})); - await dispatch(changeReorderProductDetails([])); - setFirstPaymentclick(false); - await dispatch(ChangeNavHoldData(false)); - await dispatch(changeCustomerID(null)); - await dispatch(changeSelectedCustId()); - await dispatch(changeSelectedOption(null)); - setPaybtnselected(PaymentOptions?.[0]?.ModeId); - setPaybtnnameselected(PaymentOptions?.[0]?.ModeName); - setQrCode(false); - setUpinotSelected(false); - getHolddata(); - await dispatch(changeBookingType('TakeAway')); - await dispatch(changeSelProdWiseEst([])); - await dispatch(ChangeOverAllDiscSales(null)); - await dispatch(ChangeOverAllDiscEstimate(null)); - // await dispatch(changeEstimateBooking(null)) - getstockbadge(); - Combocarddata(); - getUnpaiddatas(); - await dispatch(changeSelectTable([])); - await dispatch(changeSelectChair([])); - await dispatch(changeSelectedTableDetails([])); - await dispatch(changeOrderType()); - if (value === 'Dine-In') { - navigate(`${subDirectory}sales/dine-in`); - } - let data = { - CompId: CompId, - BranchId: BranchId, - AppId: AppId, - UserId: UserId, - FromDate: currentDateValue, - ToDate: currentDateValue, - }; - await dispatch(getSalesDetailData(data)); - }; - - const getHolddata = async () => { - const data = { CompId: CompId, BranchId: BranchId, AppId: AppId }; - let response = await dispatch(gettinghold(data)).unwrap(); - if (response?.data?.statusCode == 1) { - dispatch(changeholddata(response?.data?.data)); - } else { - dispatch(changeholddata([])); - } - }; - - const handlePrintOrToken = async () => { - const dinein = - PrintOrderDetails?.[0]?.OrderDetails?.[0]?.productDetails?.some( - (product) => product.BookingTypeName === 'Dine In' - ); - const Tokenthere = - PrintOrderDetails?.[0]?.OrderDetails?.[0]?.productDetails?.some( - (product) => product.TokenAvailable === 'Y' - ); - if (isMobile) { - if (MobileA4Print) { - await MobilePdfPrint({ - printerTemplateStyle, - printDatas, - PrintOrderDetails, - setPrintOrderDetails - }); - - } else { - if (Tokenthere && TokenOnly?.SettingValue === 'Y' && !dinein) { - if (IndividualToken?.SettingValue === 'Y' && !dinein) { - IndividualTokenMobilePrint(PrintOrderDetails, UpiId, 'Booking'); - closePrintOption(); - } else { - SingleTokenMobilePrint(PrintOrderDetails, UpiId, 'Booking'); - closePrintOption(); - } - } else { - MobilePrint(appPreferences, PrintOrderDetails, UpiId, 'Booking', SettingDataSelector); - closePrintOption(); - } - } - - } else { - if (Tokenthere && TokenOnly?.SettingValue === 'Y' && !dinein) { - AllProductTokenFunction(); - } else { - Print(); - } - } - }; - - const Print = async () => { - const style = await PrintStyleFunction( - printerTemplateStyle == undefined ? 'Style 13' : printerTemplateStyle, - 'Sales' - ); - const stylesMap = { - 'Style 1': 'PrintStyle1', - 'Style 2': 'PrintStyle2', - 'Style 3': 'PrintStyle3', - 'Style 4': 'PrintStyle4', - 'Style 5': 'PrintStyle5', - 'Style 6': 'PrintStyle6', - 'Style 7': 'PrintStyle7', - 'Style 8': 'PrintStyle8', - 'Style 9': 'PrintStyle9', - 'Style 10': 'PrintStyle10', - 'Style 11': 'PrintStyle11', - 'Style 12': 'PrintStyle12', - 'Style 13': 'RePrint', - A4: 'PrintStyleA4', - A5: 'PrintStyleA5', - A4Standard: 'A4Standard', - - }; - - const selectedStyle = - stylesMap[ - printerTemplateStyle == undefined ? 'Style 13' : printerTemplateStyle - ]; - - if (selectedStyle) { - await Promise.all( - PrintOrderDetails?.[0]?.OrderDetails?.map( - async (orderDetail, index) => { - await printDiv(`${selectedStyle}-${index}`, style); // Use unique IDs for each print - if (orderDetail?.BookingTypeName !== 'Dine In') { - const groupedTokens = orderDetail?.productDetails?.reduce( - (acc, item, idx) => { - if (item.TokenAvailable === 'Y') { - if (!item.CounterName) { - // If CounterName is null or empty - acc[`individual-${idx}`] = [item]; // Unique entry for each null/empty CounterName item - } else { - if (!acc[item.CounterName]) { - acc[item.CounterName] = []; - } - acc[item.CounterName].push(item); // Group by CounterName - } - } - return acc; - }, - {} - ); - - // Iterate over grouped tokens and print them - const tokensToPrint = Object.entries(groupedTokens).map( - async ([counterName, items], idx) => { - // Use the counterName (or unique identifier for individual items) as part of the tokenId - const tokenId = `${idx}-${counterName}`; - await TokenPrint(tokenId, items); // Pass all grouped items to the print function - } - ); - if (tokensToPrint?.length > 0) { - await Promise.all(tokensToPrint); - } - } - } - ) - ); - - setPrintOrderDetails([]); - closePrintOption(); - } - }; - - const AllProductTokenFunction = async () => { - if (IndividualToken?.SettingValue === 'Y') { - await Promise.all( - PrintOrderDetails?.[0]?.OrderDetails?.map( - async (orderDetail, index) => { - const groupedTokens = orderDetail?.productDetails?.reduce( - (acc, item, idx) => { - if (item.TokenAvailable === 'Y') { - if (!item.CounterName) { - // If CounterName is null or empty - acc[`single-${idx}`] = [item]; // Unique entry for each null/empty CounterName item - } else { - if (!acc[item.CounterName]) { - acc[item.CounterName] = []; - } - acc[item.CounterName].push(item); // Group by CounterName - } - } - return acc; - }, - {} - ); - - // Iterate over grouped tokens and print them - const tokensToPrint = Object.entries(groupedTokens).map( - async ([counterName, items], idx) => { - // Use the counterName (or unique identifier for individual items) as part of the tokenId - const tokenId = `${idx}-${counterName}`; - await TokenPrint(tokenId, items); // Pass all grouped items to the print function - } - ); - if (tokensToPrint?.length > 0) { - await Promise.all(tokensToPrint); - } - setPrintOrderDetails([]); - closePrintOption(); - } - ) - ); - } else { - await Promise.all( - PrintOrderDetails?.[0]?.OrderDetails?.map( - async (orderDetail, index) => { - await TokenPrint(`${index}-${orderDetail?.OrderId}`); - } - ) - ); - setPrintOrderDetails([]); - closePrintOption(); - } - }; - - const handlePaymentOptions = async () => { - dispatch(changeSalesPaymentoption(true)); - dispatch( - getPaymentOptionsData({ - AppId: AppId, - CompId: CompId, - BranchId: BranchId, - }) - ); - }; - - const closePrintOption = () => { - setShowWhatsAppShare(false); - setSMSShare(false); - setPrintOrderDetails([]); - setMobileNoWhatsApp(); - }; - - const handleWhatsAppClick = () => { - setShowWhatsAppShare(true); - }; - - const handleSMSClick = () => { - setSMSShare(true); - }; - - const EnableUpiOptions = () => { - setUpiOptionOpen(!UpiOptionOpen); - }; - - - function safeRound(amountStr) { - if (amountStr == null) return allowDecimal ? '0.00' : '0'; - - const cleaned = String(amountStr).replace(/[^0-9.-]+/g, ''); - const num = Number(cleaned); - - if (isNaN(num)) return allowDecimal ? '0.00' : '0'; - - return allowDecimal ? num.toFixed(2) : Math.round(num).toString(); - } - - const CreditCustomer1 = () => { - if ( - orderCardDetail?.length === 0 && - (selOption?.value !== undefined || - GlobalAddCustomerDetails1?.length > 0 || - GetCustId?.CustMobile !== undefined) - ) { - setcreditCustomerOpen(true); - } else { - if (selOption?.value == undefined) { - setMessageType('warning'); - setMessageData('Please Select the Customer'); - } - } - }; - - const SplitPaymentOpen = () => { - if (orderCardDetail?.length > 0) { - // const updatedData = { - // userData: OrderCardDetail, - // ExtraCharges: GlobalExtraCharge, - // customer: selOption != null ? selOption : GetCustId, - // Paymentgateway: false, - // }; - // setFailedOrderData(updatedData); - setSplitpayment(true); - } else { - setMessageType('warning'); - setMessageData('Please Select the Product'); - } - }; - - const CreditCustomerHAndleCancel = () => { - setcreditCustomerOpen(false); - }; - - const handlesplitpaymentclose = () => { - setSplitpayment(false); - setPaybtnselected(PaymentOptions?.[0]?.ModeId); - setPaybtnnameselected(PaymentOptions?.[0]?.ModeName); - const customerDisplayWindow = getCustomerDisplayWindow(); - if (customerDisplayWindow && !customerDisplayWindow.closed) { - const updatedData = { - paymentMethod: PaymentOptions?.[0]?.ModeName, - Paymentgateway: false, - }; - customerDisplayWindow.postMessage(updatedData, '*'); - } else { - console.error( - 'Customer display window is not available or has been closed.' - ); - } - }; - - const onComplete = useCallback(() => { - setMessageData(null); - setMessageType(null); - }, []); - - const changeOrderStatus = () => { - setOrderStatus(!OrderStatus); - setPaybtnnameselected(PaymentOptions?.[0]?.ModeName); - setPaybtnselected(PaymentOptions?.[0]?.ModeId); - }; - - return ( -
- -
-
-
Items :
-

{orderCardDetail?.length || 0}

-
-
-
Total Qty :
-

{orderCardDetail?.reduce((acc, data) => data?.OrderQty + acc, 0)}

-
-
-
MRP Total :
-

₹{orderCardDetail?.reduce((acc, data) => parseFloat(data?.TotalAmt || 0) + acc, 0)}

-
-
-
Discount :
-

-₹{(OverAllSales > 0 ? OverAllSales : 0) + - (OverAllEstimate > 0 ? OverAllEstimate : 0) + - (Discount > 0 ? Discount : 0)}

-
-
-
Total :
-

₹{orderCardDetail?.reduce((acc, data) => parseFloat(data?.TotalAmt || 0) + acc, 0) - ((OverAllSales > 0 ? OverAllSales : 0) + - (OverAllEstimate > 0 ? OverAllEstimate : 0) + - (Discount > 0 ? Discount : 0))}

-
-
-
-
- {' '} - 0 && 'not-allowed', - color: - orderCardDetail?.length > 0 || - (selOption?.value === undefined && - GlobalAddCustomerDetails1?.length === 0 && - GetCustId?.CustMobile === undefined) - ? 'gray' - : 'rgb(18, 146, 238)', - fontSize: '28px', - }} - />{' '} -
- - {!OtherServicesglobal && ( - - {' '} -
- -
-
- )} - - {dinePreference && (BookingType === 'Dine In' || - BookingTypeBoth || - CheckOrderType?.length > 0) && - !unpaidFlow && ( -
- - {' '} - - FirstPaymentclick === false && !addnewAccess - ? changeOrderStatus() - : '' - } - /> - - {/* {FirstPaymentclick === false && !addnewAccess && !OrderStatus && } */} -
- )} -
- -
- {payBtns?.length > 0 ? ( - payBtns.map((payment) => { - const mode = payment.ModeName?.toLowerCase(); - const isSelected = paybtnselected === payment.ModeId; - const buttonClass = - isSelected ? 'paybutton-selected' : 'paybutton'; - - const handleClick = - mode === 'upi' - ? () => handleUPIButtonClick(payment.ModeId, payment.ModeName) - : () => handlePaymentMode(payment.ModeId, payment.ModeName); - - return ( -
- -
- ); - }) - ) : ( -
- Please Set Payment Options -
- )} - - {/* {PrintOrderDetails?.length > 0 && ( -
- {filteredSettingNames?.includes('whatsapp') && ( - - )} - - {filteredSettingNames?.includes('SMS') && isMobile && ( - - )} -
- )} - - {showWhatsAppShare && ( - closePrintOption(false)} - /> - )} - - {showSMSShare && isMobile && ( - closePrintOption(false)} - /> - )} */} -
-
- - -
0 && - paybtnselected && - CheckBookingStatus !== 'Close' - ? !OrderStatus - ? 'standard-pay-btn' - : 'standard-pay-btn order-complete' - : 'standard-pay-btn-disabled' - } - onClick={handleButtonClick} - > - {!OrderStatus ? ( - <> -

- {isMobile ? ( - `₹ ${safeRound(OrderType === 'Failed' ? FailedTotalAmt : TotalAmount)}` - ) : ( -

- ₹{' '} - -
- )} -

- -
- -
- - ) : ( -
ORDER
- )} -
-
- - { - UpiOpen && ( - { - Upimodel('Cancel'); - }} - footer={false} - children={ -
-
-
- -
- -
-

- {' '} - RS : - {OrderType === 'Failed' - ? FailedTotalAmt - : Math.round(TotalAmount)}{' '} -

-
-
- -
- {(selOption || SelCustId) && ( -
- Sent Payment Link - Your Alt Text -
- )} - -
- } - handleSubmit={() => { - Upimodel('Submit'); - }} - /> -
- -
-
- } - /> - ) - } - { - PrintOrderDetails?.length > 0 && - PrintOrderDetails?.[0]?.OrderDetails?.map((orderDetail, index) => ( -
- -
- )) - } - { - PrintOrderDetails?.length > 0 && - (TokenOnly?.SettingValue === 'Y' || - IndividualToken?.SettingValue === 'Y') && - PrintOrderDetails?.[0]?.OrderDetails?.map((orderDetail, index) => ( -
- -
- )) - } - { - CreditCustomer && ( -
- { - handleCreditCustomer('Cancel'); - }} - handleOk={() => { - handleCreditCustomer('Submit'); - }} - /> -
- ) - } - - { - creditCustomerOpen && ( - - ) - } - { - Splitpayment && ( - data?.TotalAmt + acc, 0) - - ((OverAllSales > 0 ? OverAllSales : 0) + - (OverAllEstimate > 0 ? OverAllEstimate : 0) + - (Discount > 0 ? Discount : 0)) - )} - // failedOrderData={failedOrderData} - /> - ) - } - - - { - dispatch(changeSalesPaymentoption(false)); - }} - footer={false} - children={ -
- -
- } - /> - -
- - ) -} - -export default StandardTablePayment \ No newline at end of file diff --git a/src/Pages/BookingScreen/Components/BSCombo/BSC1Payment.jsx b/src/Pages/BookingScreen/Components/BSCombo/BSC1Payment.jsx index b85a0a7..c9cf53f 100644 --- a/src/Pages/BookingScreen/Components/BSCombo/BSC1Payment.jsx +++ b/src/Pages/BookingScreen/Components/BSCombo/BSC1Payment.jsx @@ -269,6 +269,7 @@ import { } from '../../../../Features/Offer/Offernew/BookingOffernew.js'; import pozologoimg from '../../../../Images/pozologoimg.png'; import CustomerOrders from '../BookingFunctionality/CustomerOrders.jsx'; +import useCountUp from '../UtillComponents/useCountUp.jsx'; const PaymentGatewayEmbedded = lazy( () => import('../UtillComponents/PaymentGatewayEmbedded.jsx') ); @@ -3505,6 +3506,16 @@ const BSC1Payment = (props) => { ); }; + const CountUp = useCountUp( + safeRound( + OrderType === 'Failed' + ? FailedTotalAmt + : credit && overAllBal >= 0 + ? Math.max(0, TotalAmount - overAllBal) + : TotalAmount + ) + ); + return ( <>
{ )}` ) : (
- ₹ - { ? Math.max(0, TotalAmount - overAllBal) : TotalAmount )} - /> + /> */}
)} diff --git a/src/Pages/BookingScreen/Components/UtillComponents/BSComboNavBarPreOrder.jsx b/src/Pages/BookingScreen/Components/UtillComponents/BSComboNavBarPreOrder.jsx index 5aacd04..4b533bd 100644 --- a/src/Pages/BookingScreen/Components/UtillComponents/BSComboNavBarPreOrder.jsx +++ b/src/Pages/BookingScreen/Components/UtillComponents/BSComboNavBarPreOrder.jsx @@ -138,6 +138,7 @@ import { GlobalAddCustomerDetails } from '../../../../Features/BookingScreen/Cus import SplitPayment from '../BookingFunctionality/SplitPaymentPreorder.jsx'; import PaymentPdfBooking from '../../../paymentpdfPage/PaymentPdfBooking.jsx'; import { getCustomerDisplayWindow } from '../../../../Features/customerDisplayWindow/customerDisplayWindow.js'; +import useCountUp from './useCountUp.jsx'; const MainHomeUrl = import.meta.env.ENV_MAIN_BASE_URL; @@ -276,10 +277,10 @@ const BSComboNavBarPreOrder = () => { const [PrintOrderDetails, setPrintOrderDetails] = useState([]); - const [CancelModal, setCancelModal] = useState(false); - const [PreOrderData, setPreOrderData] = useState(); - const [PreOrderRefund, setPreOrderRefund] = useState(0); - const [CancelPaymentOption, setCancelPaymentOption] = useState(); + const [CancelModal, setCancelModal] = useState(false); + const [PreOrderData, setPreOrderData] = useState(); + const [PreOrderRefund, setPreOrderRefund] = useState(0); + const [CancelPaymentOption, setCancelPaymentOption] = useState(); const gatewayOptions = [ { option: 'Default', value: 'Default' }, { option: 'Payment Device', value: 'PaymentDevice' }, @@ -466,10 +467,10 @@ const BSComboNavBarPreOrder = () => { TotalCalculation(); }, [GlobalExtraCharge]); -const OnChangeCancelPaymentOption = async (params) => { + const OnChangeCancelPaymentOption = async (params) => { setCancelPaymentOption(params); cancelformRef?.current?.setFieldsValue({ CancelPayOptions: params }); - } + }; useEffect(() => { if (Array.isArray(PreOrderList)) { @@ -663,7 +664,9 @@ const OnChangeCancelPaymentOption = async (params) => { ), onFilter: (value, record) => { return ( - String(record.OrderId)?.toLowerCase().includes(value?.toLowerCase()) || + String(record.OrderId) + ?.toLowerCase() + .includes(value?.toLowerCase()) || String(record?.CustomerDetails?.[0]?.CustSuppName) ?.toLowerCase() .includes(value?.toLowerCase()) || @@ -673,7 +676,9 @@ const OnChangeCancelPaymentOption = async (params) => { String(formatDate(record?.DeliveryDate, record.DeliveryTime)) ?.toLowerCase() .includes(value?.toLowerCase()) || - String(record.PaidAmount)?.toLowerCase().includes(value?.toLowerCase()) + String(record.PaidAmount) + ?.toLowerCase() + .includes(value?.toLowerCase()) ); }, ellipsis: true, @@ -741,7 +746,6 @@ const OnChangeCancelPaymentOption = async (params) => { return match ? match[1] : null; }; - const handlerefundvalidator = (_, value) => { const paidAmount = parseFloat(PreOrderData?.PaidAmount ?? 0); const refundAmount = parseFloat(value ?? 0); @@ -754,7 +758,6 @@ const OnChangeCancelPaymentOption = async (params) => { const OnchangeRefund = async (e) => { setPreOrderRefund(e?.target?.value); - }; const TotalCalculation = async () => { let totalSum; @@ -2736,53 +2739,47 @@ const OnChangeCancelPaymentOption = async (params) => { }; const handlePreOrderDelete = async (params) => { - if (params?.PaidAmount > 0) { setCancelModal(true); - setPreOrderData(params) - + setPreOrderData(params); + } else { + PreOrderCancel(params); } - else { - PreOrderCancel(params) - } - }; - const PreOrderCancel = async (params) => { - - - const CancelDat = { - AppId: AppId, - CompId: CompId, - BranchId: BranchId, - OrderId: params?.OrderId, - ...(params?.PaidAmount > 0 && { - OrderPaymentDtl: [ - { - PaymentType: cancelformRef?.current?.getFieldsValue()?.CancelPayOptions, - Amount: cancelformRef?.current?.getFieldsValue()?.RefundAmount || 0, - PaymentStatus: "S" - } - ] - }), - CreatedBy: UserId + const PreOrderCancel = async (params) => { + const CancelDat = { + AppId: AppId, + CompId: CompId, + BranchId: BranchId, + OrderId: params?.OrderId, + ...(params?.PaidAmount > 0 && { + OrderPaymentDtl: [ + { + PaymentType: + cancelformRef?.current?.getFieldsValue()?.CancelPayOptions, + Amount: cancelformRef?.current?.getFieldsValue()?.RefundAmount || 0, + PaymentStatus: 'S', + }, + ], + }), + CreatedBy: UserId, }; - let DeleteResponse = await dispatch(PreOrderBookingDataCancel(CancelDat)); + let DeleteResponse = await dispatch(PreOrderBookingDataCancel(CancelDat)); if (DeleteResponse?.payload?.data?.statusCode === 1) { setMessageType('success'); setMessageData('OrderStatus Deleted Successfully'); PendingApiCall(); - cancelformRef?.current?.resetFields(); - setCancelModal(false); - setPreOrderData(); - setCancelPaymentOption(null); - setPreOrderRefund(null); + cancelformRef?.current?.resetFields(); + setCancelModal(false); + setPreOrderData(); + setCancelPaymentOption(null); + setPreOrderRefund(null); } else { setMessageType('error'); setMessageData(DeleteResponse?.payload?.data?.response); } - } - + }; const History_onSearch = (value) => { HistorysetSearchedText(value); @@ -3043,6 +3040,8 @@ const OnChangeCancelPaymentOption = async (params) => { await dispatch(ChangeSearchFocusPreOrder(true)); }; + const CountUp = useCountUp(Math.round(PreOrderAdvance)); + return ( <> { {PreOrderAdvance > 1 && PreOrderAdvance != null && @@ -4300,114 +4299,118 @@ const OnChangeCancelPaymentOption = async (params) => { )} {CancelModal && ( - Cancel Pre Booking} - open={CancelModal} - onCancel={() => setCancelModal(false)} - footer={false} - width={700} - > -
- - {/* Summary Block */} -
-
- Bill Amount: - ₹ {PreOrderData?.NetAmount ?? 0} -
-
- Advance Paid: - ₹ {PreOrderData?.PaidAmount ?? 0} -
-
- - {/* Refund Amount Input */} -
{ PreOrderCancel(PreOrderData) }}> - - Refund Amount} - maxLength={10} - fieldState={true} - value={PreOrderRefund} - fieldApi={true} - onChange={OnchangeRefund} - isOnChange={!!PreOrderRefund} - onKeyPress={(e) => { - const char = String.fromCharCode(e.charCode); - const isValid = /[0-9.]$/.test(char); - if (!isValid) e.preventDefault(); - if (char === '.' && e.currentTarget.value.includes('.')) { - e.preventDefault(); - } - }} - /> - - - - {/* Payment Method Dropdown */} - - option.ModeName !== 'Credit' && option.ModeName !== 'Card') - ?.map(option => ({ - value: option.ModeId, - label: option.ModeName, - })) - } - label={} - isOnchanges={!!CancelPaymentOption} - onChangeFunction={OnChangeCancelPaymentOption} - valueData={CancelPaymentOption} - /> - - -
- } - /> -
- - - -
- -
-
+ Cancel Pre Booking} + open={CancelModal} + onCancel={() => setCancelModal(false)} + footer={false} + width={700} + > +
+ {/* Summary Block */} +
+
+ Bill Amount: + + ₹ {PreOrderData?.NetAmount ?? 0} + +
+
+ Advance Paid: + + ₹ {PreOrderData?.PaidAmount ?? 0} + +
+
+ + {/* Refund Amount Input */} +
{ + PreOrderCancel(PreOrderData); + }} + > + + Refund Amount} + maxLength={10} + fieldState={true} + value={PreOrderRefund} + fieldApi={true} + onChange={OnchangeRefund} + isOnChange={!!PreOrderRefund} + onKeyPress={(e) => { + const char = String.fromCharCode(e.charCode); + const isValid = /[0-9.]$/.test(char); + if (!isValid) e.preventDefault(); + if (char === '.' && e.currentTarget.value.includes('.')) { + e.preventDefault(); + } + }} + /> + + + {/* Payment Method Dropdown */} + + + option.ModeName !== 'Credit' && + option.ModeName !== 'Card' + )?.map((option) => ({ + value: option.ModeId, + label: option.ModeName, + }))} + label={} + isOnchanges={!!CancelPaymentOption} + onChangeFunction={OnChangeCancelPaymentOption} + valueData={CancelPaymentOption} + /> + + +
+ } + /> +
+
+
+
)}
diff --git a/src/Pages/BookingScreen/Components/UtillComponents/BSNavBarPreOrder.jsx b/src/Pages/BookingScreen/Components/UtillComponents/BSNavBarPreOrder.jsx index e8e0f3f..49b4105 100644 --- a/src/Pages/BookingScreen/Components/UtillComponents/BSNavBarPreOrder.jsx +++ b/src/Pages/BookingScreen/Components/UtillComponents/BSNavBarPreOrder.jsx @@ -3952,8 +3952,7 @@ const BSNavBarPreOrder = ({ color: Color['lightColor'], }} > - {/* ₹ */} - ₹ {safeRound(PreOrderAdvance)} + ₹ {safeRound(PreOrderAdvance)} {PreOrderAdvance > 1 && PreOrderAdvance != null && diff --git a/src/Pages/BookingScreen/Components/UtillComponents/useCountUp.jsx b/src/Pages/BookingScreen/Components/UtillComponents/useCountUp.jsx new file mode 100644 index 0000000..90f6029 --- /dev/null +++ b/src/Pages/BookingScreen/Components/UtillComponents/useCountUp.jsx @@ -0,0 +1,27 @@ +import { useEffect, useState } from "react"; + +export const useCountUp = (end, duration = 400) => { + const [value, setValue] = useState(0); + + useEffect(() => { + let start = 0; + const increment = end / (duration / 16); + + const counter = setInterval(() => { + start += increment; + + if (start >= end) { + setValue(end); + clearInterval(counter); + } else { + setValue(Math.floor(start)); + } + }, 16); + + return () => clearInterval(counter); + }, [end, duration]); + + return value; +}; + +export default useCountUp; \ No newline at end of file