fix send test email

This commit is contained in:
peaklabs-dev
2024-11-21 15:48:47 +01:00
parent 131a3920f0
commit 19ce01f7d8
2 changed files with 8 additions and 5 deletions

View File

@@ -73,6 +73,9 @@ class Email extends Component
#[Validate(['nullable', 'string'])] #[Validate(['nullable', 'string'])]
public ?string $resendApiKey = null; public ?string $resendApiKey = null;
#[Validate(['required', 'email'])]
public string $testEmailAddress = '';
public function mount() public function mount()
{ {
try { try {
@@ -132,14 +135,14 @@ class Email extends Component
} }
} }
public function sendTestNotification() public function sendTestEmail()
{ {
try { try {
$executed = RateLimiter::attempt( $executed = RateLimiter::attempt(
'test-email:'.$this->team->id, 'test-email:'.$this->team->id,
$perMinute = 0, $perMinute = 0,
function () { function () {
$this->team?->notify(new Test($this->emails)); $this->team?->notify(new Test($this->testEmailAddress));
$this->dispatch('success', 'Test Email sent.'); $this->dispatch('success', 'Test Email sent.');
}, },
$decaySeconds = 10, $decaySeconds = 10,

View File

@@ -16,9 +16,9 @@
@endif @endif
@if (isEmailEnabled($team) && auth()->user()->isAdminFromSession() && isTestEmailEnabled($team)) @if (isEmailEnabled($team) && auth()->user()->isAdminFromSession() && isTestEmailEnabled($team))
<x-modal-input buttonTitle="Send Test Email" title="Send Test Email"> <x-modal-input buttonTitle="Send Test Email" title="Send Test Email">
<form wire:submit='submit' class="flex flex-col w-full gap-2"> <form wire:submit.prevent="sendTestEmail" class="flex flex-col w-full gap-2">
<x-forms.input placeholder="test@example.com" id="emails" label="Recipients" required /> <x-forms.input wire:model="testEmailAddress" placeholder="test@example.com" id="testEmailAddress" label="Recipients" required />
<x-forms.button wire:click="sendTestNotification" @click="modalOpen=false"> <x-forms.button type="submit" @click="modalOpen=false">
Send Email Send Email
</x-forms.button> </x-forms.button>
</form> </form>