<?php

namespace App\Notifications;

use App\Models\Applicant;

class ExternalApplicationNotification extends HrmsNotification
{
    public function __construct(public Applicant $applicant) {}

    public function notificationCategory(): string
    {
        return 'recruitment';
    }

    public function notificationSubject(): string
    {
        return 'New careers page application — '.$this->applicant->name;
    }

    public function notificationLines(): array
    {
        return [
            $this->applicant->name.' applied via the public careers page.',
            'Role: '.($this->applicant->jobPosting?->title ?? '—'),
            'Email: '.($this->applicant->email ?: '—'),
        ];
    }

    public function actionUrl(): ?string
    {
        return route('applicants.show', $this->applicant);
    }

    public function actionLabel(): string
    {
        return 'Review application';
    }

    public function toArray(object $notifiable): array
    {
        return [
            'type' => 'external_application',
            'message' => 'New application from careers page: '.$this->applicant->name,
            'applicant_id' => $this->applicant->id,
            'url' => $this->actionUrl(),
        ];
    }
}
