<?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 CareerApplicationSubmittedStaffNotification extends Notification implements ShouldQueue
{
    use Queueable;

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

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

    public function toMail(object $notifiable): MailMessage
    {
        return (new MailMessage)
            ->subject(__('recruitment.career_portal.mail.staff_subject', [
                'ref' => $this->application->reference_code,
            ]))
            ->line(__('recruitment.career_portal.mail.staff_line', [
                'ref' => $this->application->reference_code,
                'candidate' => $this->application->candidate?->full_name ?? '',
            ]));
    }

    /** @return array<string, mixed> */
    public function toArray(object $notifiable): array
    {
        return [
            'category' => 'recruitment',
            'action' => 'career_application_submitted',
            'application_id' => $this->application->id,
            'reference' => $this->application->reference_code,
            'message' => __('recruitment.career_portal.mail.staff_line', [
                'ref' => $this->application->reference_code,
                'candidate' => $this->application->candidate?->full_name ?? '',
            ]),
        ];
    }
}
