fix: make sure resend is false if SMTP is true and vice versa

This commit is contained in:
peaklabs-dev
2024-12-09 15:19:59 +01:00
parent 2aacb1dc28
commit 67438e28ca

View File

@@ -126,8 +126,9 @@ class SettingsEmail extends Component
} }
} }
public function submitSmtp(): void public function submitSmtp()
{ {
try {
$this->validate([ $this->validate([
'smtpEnabled' => 'boolean', 'smtpEnabled' => 'boolean',
'smtpFromAddress' => 'required|email', 'smtpFromAddress' => 'required|email',
@@ -149,6 +150,7 @@ class SettingsEmail extends Component
]); ]);
$this->resendEnabled = false; $this->resendEnabled = false;
$this->settings->resend_enabled = false;
$this->settings->smtp_enabled = $this->smtpEnabled; $this->settings->smtp_enabled = $this->smtpEnabled;
$this->settings->smtp_host = $this->smtpHost; $this->settings->smtp_host = $this->smtpHost;
@@ -159,14 +161,20 @@ class SettingsEmail extends Component
$this->settings->smtp_timeout = $this->smtpTimeout; $this->settings->smtp_timeout = $this->smtpTimeout;
$this->settings->smtp_from_address = $this->smtpFromAddress; $this->settings->smtp_from_address = $this->smtpFromAddress;
$this->settings->smtp_from_name = $this->smtpFromName; $this->settings->smtp_from_name = $this->smtpFromName;
$this->settings->resend_enabled = false;
$this->settings->save(); $this->settings->save();
$this->dispatch('success', 'SMTP settings updated.'); $this->dispatch('success', 'SMTP settings updated.');
} catch (\Throwable $e) {
$this->smtpEnabled = false;
return handleError($e);
}
} }
public function submitResend(): void public function submitResend()
{ {
try {
$this->validate([ $this->validate([
'resendEnabled' => 'boolean', 'resendEnabled' => 'boolean',
'resendApiKey' => 'required|string', 'resendApiKey' => 'required|string',
@@ -180,15 +188,21 @@ class SettingsEmail extends Component
]); ]);
$this->smtpEnabled = false; $this->smtpEnabled = false;
$this->settings->smtp_enabled = false;
$this->settings->resend_enabled = $this->resendEnabled; $this->settings->resend_enabled = $this->resendEnabled;
$this->settings->resend_api_key = $this->resendApiKey; $this->settings->resend_api_key = $this->resendApiKey;
$this->settings->smtp_from_address = $this->smtpFromAddress; $this->settings->smtp_from_address = $this->smtpFromAddress;
$this->settings->smtp_from_name = $this->smtpFromName; $this->settings->smtp_from_name = $this->smtpFromName;
$this->settings->smtp_enabled = false;
$this->settings->save(); $this->settings->save();
$this->dispatch('success', 'Resend settings updated.'); $this->dispatch('success', 'Resend settings updated.');
} catch (\Throwable $e) {
$this->resendEnabled = false;
return handleError($e, $this);
}
} }
public function sendTestEmail() public function sendTestEmail()