<?php

namespace App\Modules\HR\Recruitment\Notifications;

use App\Modules\HR\Recruitment\Models\RecruitmentApplication;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;

class CareerApplicationReceivedNotification extends Notification implements ShouldQueue
{
    use Queueable;

    public function __construct(
        public readonly RecruitmentApplication $application,
        public readonly string $tenantSlug,
    ) {}

    /** @return list<string> */
    public function via(object $notifiable): array
    {
        return ['mail'];
    }

    public function toMail(object $notifiable): MailMessage
    {
        $url = route('careers.track.show', [
            'tenant' => $this->tenantSlug,
            'token' => $this->application->tracking_token,
        ]);

        return (new MailMessage)
            ->subject(__('recruitment.career_portal.mail.received_subject', [
                'ref' => $this->application->reference_code,
            ]))
            ->line(__('recruitment.career_portal.mail.received_line', [
                'ref' => $this->application->reference_code,
            ]))
            ->action(__('recruitment.career_portal.mail.track_action'), $url);
    }
}
