<?php

namespace App\Domains\Notification\Listeners;

use App\Domains\Notification\Events\PasswordResetRequested;
use App\Domains\Notification\Services\NotificationMailService;
use Illuminate\Contracts\Queue\ShouldQueueAfterCommit;
use Illuminate\Queue\InteractsWithQueue;

class SendPasswordResetEmail implements ShouldQueueAfterCommit
{
    use InteractsWithQueue;

    public string $queue = 'emails';

    public int $tries = 3;

    /** @var array<int, int> */
    public array $backoff = [30, 120, 300];

    public function handle(PasswordResetRequested $event): void
    {
        app(NotificationMailService::class)->sendPasswordResetCode(
            $event->attemptId,
            $event->tenantCode,
            $event->channel,
        );
    }
}
