From 02cc0f2a2fe1c2af05ab1507c06db79b473ab5bc Mon Sep 17 00:00:00 2001 From: Krishna Das Date: Mon, 18 May 2026 23:27:25 +0530 Subject: [PATCH] fix: resolve certificate sending bug and add partial success handling --- .../Admin/Form/CertificatesForm/SendCertificate.jsx | 10 +++++----- .../Form/CertificatesForm/tools/certificateTools.js | 2 ++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/sections/Profile/Admin/Form/CertificatesForm/SendCertificate.jsx b/src/sections/Profile/Admin/Form/CertificatesForm/SendCertificate.jsx index 2ed237e2..f1a936e5 100644 --- a/src/sections/Profile/Admin/Form/CertificatesForm/SendCertificate.jsx +++ b/src/sections/Profile/Admin/Form/CertificatesForm/SendCertificate.jsx @@ -248,15 +248,15 @@ const SendCertificate = () => { token: authCtx.token, }); - if (response?.status === 200) { + if (response?.status === 200 || response?.status === 207) { setAlert({ - type: "success", - message: "Certificates sent successfully!", + type: response.status === 200 ? "success" : "warning", + message: response.data?.message || "Certificates processed.", position: "top-right", - duration: 3000, + duration: 4000, }); } else { - throw new Error("Failed to send certificates"); + throw new Error(response?.data?.error || "Failed to send certificates"); } } catch (error) { console.error("Error in handleSendBatchMail:", error); diff --git a/src/sections/Profile/Admin/Form/CertificatesForm/tools/certificateTools.js b/src/sections/Profile/Admin/Form/CertificatesForm/tools/certificateTools.js index 7833f2cf..49614ce7 100644 --- a/src/sections/Profile/Admin/Form/CertificatesForm/tools/certificateTools.js +++ b/src/sections/Profile/Admin/Form/CertificatesForm/tools/certificateTools.js @@ -111,8 +111,10 @@ const generatedAndSendCertificate = async ({ } else { console.error("Error:", response.data); } + return response; } catch (error) { console.error("Failed to generate and send certificates:", error); + return error.response; } };