diff --git a/frontend/src/pages/SettingsPage.tsx b/frontend/src/pages/SettingsPage.tsx index c54a745..4306b8b 100644 --- a/frontend/src/pages/SettingsPage.tsx +++ b/frontend/src/pages/SettingsPage.tsx @@ -117,6 +117,16 @@ export default function SettingsPage() { setTestingSmtp(true) setSmtpTestResult(null) try { + // Save settings first so the test uses current form values + await settingsApi.update({ + azure_sso: { ...azureSso }, + smtp: { ...smtp }, + polling, + ip_whitelist: ipWhitelist, + web_tls_strategy: webTlsStrategy, + notification, + }) + // Then test SMTP const { data } = await settingsApi.testSmtp() setSmtpTestResult(data) } catch (err: unknown) { @@ -204,8 +214,11 @@ export default function SettingsPage() { setSmtp({ ...smtp, enabled: e.target.checked })} />} - label="Enable Email Notifications" + label="Enable SMTP Server" /> + + Enable the SMTP server connection for sending emails + setSmtp({ ...smtp, host: e.target.value })} /> @@ -233,7 +246,7 @@ export default function SettingsPage() { setSmtp({ ...smtp, from: e.target.value })} helperText="noreply@example.com" /> - {smtpTestResult && ( @@ -312,10 +325,14 @@ export default function SettingsPage() { setNotification({ ...notification, email_enabled: e.target.checked })} />} label="Enable Email Notifications" + disabled={!smtp.enabled} /> + + Requires SMTP server to be enabled + - setNotification({ ...notification, email_from: e.target.value })} helperText="Sender address for notifications" /> + setNotification({ ...notification, email_from: e.target.value })} helperText="Sender address for notifications" disabled={!smtp.enabled} /> Recipients @@ -325,7 +342,7 @@ export default function SettingsPage() { const updated = [...notification.recipients] updated[idx] = e.target.value setNotification({ ...notification, recipients: updated }) - }} placeholder="admin@example.com" sx={{ flexGrow: 1 }} /> + }} placeholder="admin@example.com" sx={{ flexGrow: 1 }} disabled={!smtp.enabled} /> { setNotification({ ...notification, recipients: notification.recipients.filter((_, i) => i !== idx) }) }}>