From dffa45d41093e482694b2fbaa0df0c6ef7588af9 Mon Sep 17 00:00:00 2001 From: Srinath Date: Tue, 17 Mar 2026 18:29:57 +0530 Subject: [PATCH] Added common Email loader modal component --- .../OtherConponents/Reprint/BSReprint.jsx | 33 +- .../Reprint/CreditCustomerReprint.jsx | 29 +- .../Components/UtillComponents/EmailModel.jsx | 65 ++++ src/Pages/DeliveryChallan/Deliverychallan.jsx | 18 +- .../DeliveryChallan/DeliverychallanList.jsx | 21 +- .../DeliveryChallanToInvoiceForm.jsx | 48 +-- .../DeliveryChallanToInvoiceList.jsx | 49 +-- .../ProductCatlogue/CatalogueTemplate1.jsx | 2 +- .../ProductCatlogue/CatalogueTemplate2.jsx | 2 +- .../ProductCatlogue/CatalogueTemplate3.jsx | 2 +- .../ProductCatlogue/CatalogueTemplate4.jsx | 2 +- .../ProductCatlogue/CatalogueTemplate5.jsx | 2 +- .../ProductCatlogue/Productcatalogue.jsx | 36 ++- src/Pages/PurchaseOrder/PurchaseOrder.jsx | 113 ++++--- src/Pages/PurchaseOrder/PurchaseOrderList.jsx | 28 +- .../PurchaseQuotationForm.jsx | 304 +----------------- .../PurchaseQuotationList.jsx | 19 +- .../PublicQrCodeShare/PublicQrCodeShare.jsx | 46 ++- 18 files changed, 364 insertions(+), 455 deletions(-) create mode 100644 src/Pages/BookingScreen/Components/UtillComponents/EmailModel.jsx diff --git a/src/Pages/BookingScreen/Components/OtherConponents/Reprint/BSReprint.jsx b/src/Pages/BookingScreen/Components/OtherConponents/Reprint/BSReprint.jsx index 90856a4..df2594e 100644 --- a/src/Pages/BookingScreen/Components/OtherConponents/Reprint/BSReprint.jsx +++ b/src/Pages/BookingScreen/Components/OtherConponents/Reprint/BSReprint.jsx @@ -94,10 +94,12 @@ import { ChangeTotalAmount } from '../../../../../Features/ExteraCharges/ExtraCh import { Radio } from 'antd'; import ReprintPDFDataShare from './ReprintPDFDataShare.jsx'; import { ImShare } from 'react-icons/im'; +import EmailModel from '../../UtillComponents/EmailModel.jsx'; const RetailApiurl = import.meta.env.ENV_API_URL; function BSReprint({ setOpenModel = () => { } }) { + const [form] = Form.useForm(); const dispatch = useDispatch(); const queryClient = useQueryClient(); const appPreferences = useSelector(ApplicationPreferences); @@ -1155,17 +1157,17 @@ function BSReprint({ setOpenModel = () => { } }) { setEmailModalOpen(true); }; - const handleSendEmail = async () => { + const handleSendEmail = async (value) => { try { + const toEmail = value.email; if (selectedRows.length === 0) { setLoading(true); - const result = await MobilePdfPrint({ printerTemplateStyle, printDatas, PrintOrderDetails: reprintData, PrintComing: 'email', - emailId: EmailId, + emailId: toEmail, dispatch, }); @@ -1173,9 +1175,10 @@ function BSReprint({ setOpenModel = () => { } }) { setEmailModalOpen(false); // ✅ Close modal setEmailId(''); // ✅ Reset email input (optional) setLoading(false); + form.resetFields(); } } else { - mutiplePrint('email'); + mutiplePrint('email',toEmail); } } catch (err) { console.error('❌ Email error:', err); @@ -1196,7 +1199,7 @@ function BSReprint({ setOpenModel = () => { } }) { const [processingProgress, setProcessingProgress] = useState(0); const [isProcessing, setIsProcessing] = useState(false); - const mutiplePrint = async (printType) => { + const mutiplePrint = async (printType,toEmail) => { setIsProcessing(true); setProcessingProgress(0); @@ -1206,25 +1209,27 @@ function BSReprint({ setOpenModel = () => { } }) { PrintOrderDetails: selectedRows, setPrintOrderDetails: setReprintData, PrintComing: printType, - emailId: EmailId, + emailId: EmailId || toEmail, UserId: UserId, dispatch, onProgress: (progress) => setProcessingProgress(progress), }); setIsProcessing(false); - if (printType === 'email') { if (result?.data?.status === 1) { + setMessage({ type: 'success', data: result?.data?.response }); setEmailModalOpen(false); setEmailId(''); setSelectedRows([]); setSelectAll(false); setBulkMode(false); + form.resetFields(); } else { setSelectedRows([]); setSelectAll(false); setBulkMode(false); + form.resetFields(); } } else { setSelectedRows([]); @@ -1811,7 +1816,7 @@ function BSReprint({ setOpenModel = () => { } }) { handleCancel={ReprintCancel} /> - setEmailModalOpen(false)} @@ -1837,7 +1842,17 @@ function BSReprint({ setOpenModel = () => { } }) { progress={processingProgress} isProcessing={isProcessing} /> - + */} + + {(emailModalOpen || isProcessing) && ( + setEmailModalOpen(false)} + form={form} + handleSendEmailWithEnteredEmail={handleSendEmail} + />)} + {!emailModalOpen && ( { const reprintReasonRef = useRef(null); const dispatch = useDispatch(); - + const [form] = Form.useForm(); const AppId = getSession("AppId"); const CompId = getSession("CompId"); const BranchId = getSession("BranchId"); @@ -444,7 +445,7 @@ const CreditCustomerReprint = () => { - const mutiplePrint = async (printType) => { + const mutiplePrint = async (printType,toEmail) => { setIsProcessing(true); setProcessingProgress(0); @@ -453,7 +454,7 @@ const CreditCustomerReprint = () => { BSCreditCustomerPrint: BSCreditCustomerPrint, PrintOrderDetails: selectedRows, PrintComing: printType, - emailId: EmailId, + emailId: EmailId || toEmail, UserId: UserId, dispatch, onProgress: (progress) => setProcessingProgress(progress) @@ -484,8 +485,9 @@ const CreditCustomerReprint = () => { } }; - const handleSendEmail = async () => { + const handleSendEmail = async (value) => { try { + const toEmail = value.email; if (selectedRows.length === 0) { setLoading(true); @@ -494,7 +496,7 @@ const CreditCustomerReprint = () => { printDatas, PrintOrderDetails: reprintData, PrintComing: "email", - emailId: EmailId, + emailId: toEmail, dispatch, }); @@ -507,7 +509,7 @@ const CreditCustomerReprint = () => { } } else { - mutiplePrint('email'); + mutiplePrint('email',toEmail); } } catch (err) { @@ -664,7 +666,7 @@ const CreditCustomerReprint = () => { } /> - setEmailModalOpen(false)} @@ -691,7 +693,16 @@ const CreditCustomerReprint = () => { progress={processingProgress} isProcessing={isProcessing} /> - + */} + + {(emailModalOpen || isProcessing) && ( + setEmailModalOpen(false)} + form={form} + handleSendEmailWithEnteredEmail={handleSendEmail} + />)} {!emailModalOpen && { + + return ( + !emailSending && handleCancel()} + footer={false} + closable={!emailSending} + maskClosable={!emailSending} + children={ + emailSending ? ( + // 👇 Loader view +
+ +

+ Sending email, please wait... +

+
+ ) : + (
+
+ + + + + +
+
) + } + /> + ); +}; + +export default EmailModel; \ No newline at end of file diff --git a/src/Pages/DeliveryChallan/Deliverychallan.jsx b/src/Pages/DeliveryChallan/Deliverychallan.jsx index e851d21..cfed990 100644 --- a/src/Pages/DeliveryChallan/Deliverychallan.jsx +++ b/src/Pages/DeliveryChallan/Deliverychallan.jsx @@ -61,6 +61,7 @@ import { useSelector } from 'react-redux'; import { getPrintSelectionComponentData } from '../../Features/ThemeChange/ThemeChange.js'; import { DCPDFMobilePrint } from './DCPDFMobilePrint.js'; import { isMobile } from 'react-device-detect'; +import EmailModel from '../BookingScreen/Components/UtillComponents/EmailModel.jsx'; const DeliveryChellanForm = () => { @@ -114,6 +115,7 @@ const DeliveryChellanForm = () => { const [segmentValue, setSegmentValue] = useState("N") const [selectedOrder, setSelectedOrder] = useState(); const [orderTableData, setOrderTableData] = useState([]); + const [emailSending, setEmailSending] = useState(false); const items = [ { @@ -1217,6 +1219,7 @@ const DeliveryChellanForm = () => { // setPrintData(record); if (orderData?.CustMail) { + setEmailSending(true); setTimeout(async () => { try { const blob = await pdfDiv('DC-Default-Print', PurchaseOrderStyle); @@ -1239,6 +1242,9 @@ const DeliveryChellanForm = () => { setMessageData('Email failed to send'); setMessageType('error'); } + finally{ + setEmailSending(false); + } }, 300); } else { setPendingOrderDetails(ProductDetails); @@ -1683,7 +1689,7 @@ const DeliveryChellanForm = () => { - { } - /> + /> */} + {(iSEmail || emailSending )&& ( + setiSEmail(false)} + form={form} + handleSendEmailWithEnteredEmail={handleSendEmailWithEnteredEmail} + />)} {PrintingData?.length > 0 &&
{ const [iSEmail, setiSEmail] = useState(false); const [enteredEmail, setEnteredEmail] = useState(''); const [pendingOrderDetails, setPendingOrderDetails] = useState(null); + const [emailSending, setEmailSending] = useState(false); const [pendingRecord, setPendingRecord] = useState(null); console.log(ProductDetails, 'ProductDetails'); const PurchaseOrderStyle = ``; - // const QuotationStyle = ``; - const PurchaseOrderStyle = `