<?php

namespace App\Domains\Notification\Listeners;

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

class SendWelcomeEmail 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(UserRegistered $event): void
    {
        app(NotificationMailService::class)->sendWelcome($event->user->getKey(), $event->tenantCode);
    }
}
