diff --git a/src/Pages/BookingScreen/Components/OtherConponents/Reprint/BSReprint.jsx b/src/Pages/BookingScreen/Components/OtherConponents/Reprint/BSReprint.jsx index df2594e..344c815 100644 --- a/src/Pages/BookingScreen/Components/OtherConponents/Reprint/BSReprint.jsx +++ b/src/Pages/BookingScreen/Components/OtherConponents/Reprint/BSReprint.jsx @@ -1158,10 +1158,10 @@ function BSReprint({ setOpenModel = () => { } }) { }; const handleSendEmail = async (value) => { + const toEmail = value.email; + setLoading(true); try { - const toEmail = value.email; if (selectedRows.length === 0) { - setLoading(true); const result = await MobilePdfPrint({ printerTemplateStyle, printDatas, @@ -1172,16 +1172,25 @@ function BSReprint({ setOpenModel = () => { } }) { }); if (result?.data?.status === 1) { - setEmailModalOpen(false); // ✅ Close modal - setEmailId(''); // ✅ Reset email input (optional) - setLoading(false); + setMessage({ type: 'success', data: result?.data?.response || 'Email sent successfully' }); + setEmailModalOpen(false); + setEmailId(''); form.resetFields(); + } else { + setMessage({ type: 'error', data: result?.data?.response || 'Email sending failed' }); } } else { - mutiplePrint('email',toEmail); + await mutiplePrint('email', toEmail); } } catch (err) { console.error('❌ Email error:', err); + setMessage({ type: 'error', data: err?.message || 'Something went wrong while sending email' }); + } finally { + setLoading(false); + if (selectedRows.length === 0) { + // for single row, form already reset on success; for failure, still reset to clear bad input + form.resetFields(); + } } }; @@ -1844,10 +1853,10 @@ function BSReprint({ setOpenModel = () => { } }) { /> */} - {(emailModalOpen || isProcessing) && ( + {(emailModalOpen || loading) && ( setEmailModalOpen(false)} form={form} handleSendEmailWithEnteredEmail={handleSendEmail}