loader funtion change

This commit is contained in:
Srinath 2026-03-20 11:00:25 +05:30
parent 2b8bc2a1ca
commit 626b3b502a
1 changed files with 17 additions and 8 deletions

View File

@ -1158,10 +1158,10 @@ function BSReprint({ setOpenModel = () => { } }) {
}; };
const handleSendEmail = async (value) => { const handleSendEmail = async (value) => {
const toEmail = value.email;
setLoading(true);
try { try {
const toEmail = value.email;
if (selectedRows.length === 0) { if (selectedRows.length === 0) {
setLoading(true);
const result = await MobilePdfPrint({ const result = await MobilePdfPrint({
printerTemplateStyle, printerTemplateStyle,
printDatas, printDatas,
@ -1172,16 +1172,25 @@ function BSReprint({ setOpenModel = () => { } }) {
}); });
if (result?.data?.status === 1) { if (result?.data?.status === 1) {
setEmailModalOpen(false); // Close modal setMessage({ type: 'success', data: result?.data?.response || 'Email sent successfully' });
setEmailId(''); // Reset email input (optional) setEmailModalOpen(false);
setLoading(false); setEmailId('');
form.resetFields(); form.resetFields();
} else {
setMessage({ type: 'error', data: result?.data?.response || 'Email sending failed' });
} }
} else { } else {
mutiplePrint('email',toEmail); await mutiplePrint('email', toEmail);
} }
} catch (err) { } catch (err) {
console.error('❌ Email error:', 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 = () => { } }) {
/> />
</Modal> */} </Modal> */}
{(emailModalOpen || isProcessing) && ( {(emailModalOpen || loading) && (
<EmailModel <EmailModel
open={emailModalOpen} open={emailModalOpen}
emailSending={isProcessing} emailSending={loading}
handleCancel={() => setEmailModalOpen(false)} handleCancel={() => setEmailModalOpen(false)}
form={form} form={form}
handleSendEmailWithEnteredEmail={handleSendEmail} handleSendEmailWithEnteredEmail={handleSendEmail}