From e3f9111484852c45eac3f86c0ecf9adb31615c86 Mon Sep 17 00:00:00 2001 From: Tola Leng Date: Tue, 17 Jun 2025 21:39:12 +0800 Subject: [PATCH] Refactor: Move test email button and dialog --- .../settings/general/MailSettingsTab.tsx | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/application/src/components/settings/general/MailSettingsTab.tsx b/application/src/components/settings/general/MailSettingsTab.tsx index 45f3ff7..1e02c95 100644 --- a/application/src/components/settings/general/MailSettingsTab.tsx +++ b/application/src/components/settings/general/MailSettingsTab.tsx @@ -1,5 +1,4 @@ - import React, { useState } from 'react'; import { Input } from "@/components/ui/input"; import { Switch } from "@/components/ui/switch"; @@ -27,18 +26,15 @@ const MailSettingsTab: React.FC = ({ setIsTestingEmail(true); console.log('Testing email with data:', data); - const response = await fetch('/api/settings', { + const response = await fetch('/api/settings/test/email', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ - action: 'sendTestEmail', - data: { - email: data.email, - template: data.template, - ...(data.collection && { collection: data.collection }) - } + email: data.email, + template: data.template, + ...(data.collection && { collection: data.collection }) }) }); @@ -257,10 +253,16 @@ const MailSettingsTab: React.FC = ({ )} /> - - {/* Only show Test Email button, removed Test Connection button */} - {isEditing && form.watch('smtp.enabled') && ( -
+
+ + {/* Test Email button - outside the form area and always visible when SMTP is enabled */} + {form.watch('smtp.enabled') && ( +
+
+
+

{t("testEmailSettings", "settings")}

+

{t("testEmailDescription", "settings")}

+
- )} -
+ + )} = ({ ); }; -export default MailSettingsTab; +export default MailSettingsTab; \ No newline at end of file