From 8ef45a7fb9b9aef61f92522e5a6799f3e8969ab4 Mon Sep 17 00:00:00 2001 From: mohadeseh safari Date: Fri, 16 May 2025 18:24:34 -0400 Subject: [PATCH] feat: Update email testing to use form values without saving - Update sendTestEmail method to use new /api/v1/settings/test-email endpoint - Send current form values directly to test endpoint without saving to DB - Format request body according to backend requirements --- client/src/Utils/NetworkService.js | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/client/src/Utils/NetworkService.js b/client/src/Utils/NetworkService.js index 4adf8ff8b..1a9732354 100644 --- a/client/src/Utils/NetworkService.js +++ b/client/src/Utils/NetworkService.js @@ -1154,10 +1154,27 @@ class NetworkService { } // ************************************ - // Send tes t email + // Send test email // ************************************ async sendTestEmail(config) { - const { to } = config; + // Extract recipient and email configuration + const { to, emailConfig } = config; + + // If emailConfig is provided, use the new endpoint with direct parameters + if (emailConfig) { + return this.axiosInstance.post(`/api/v1/settings/test-email`, { + to, + systemEmailHost: emailConfig.systemEmailHost, + systemEmailPort: emailConfig.systemEmailPort, + systemEmailAddress: emailConfig.systemEmailAddress, + systemEmailPassword: emailConfig.systemEmailPassword, + // Only include these if they are present + ...(emailConfig.systemEmailConnectionHost && { systemEmailConnectionHost: emailConfig.systemEmailConnectionHost }), + ...(emailConfig.systemEmailUser && { systemEmailUser: emailConfig.systemEmailUser }) + }); + } + + // Fallback to original behavior for backward compatibility return this.axiosInstance.post(`/monitors/test-email`, { to }); } }