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) => {
try {
const toEmail = value.email;
if (selectedRows.length === 0) {
setLoading(true);
try {
if (selectedRows.length === 0) {
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 = () => { } }) {
/>
</Modal> */}
{(emailModalOpen || isProcessing) && (
{(emailModalOpen || loading) && (
<EmailModel
open={emailModalOpen}
emailSending={isProcessing}
emailSending={loading}
handleCancel={() => setEmailModalOpen(false)}
form={form}
handleSendEmailWithEnteredEmail={handleSendEmail}