<?php

namespace App\Notifications;

use App\Models\Termination;
use Illuminate\Support\Str;

class TerminationNoticeToEmployeeNotification extends HrmsNotification
{
    public function __construct(
        public Termination $termination
    ) {}

    public function notificationCategory(): string
    {
        return 'resignation';
    }

    public function notificationSubject(): string
    {
        return 'Termination recorded on your employment file';
    }

    public function notificationLines(): array
    {
        return [
            'A termination has been recorded for your employment.',
            'Date: ' . $this->termination->termination_date?->format('d M Y'),
            'Type: ' . ($this->termination->reason_type ?? '—'),
            'Reason: ' . Str::limit((string) ($this->termination->reason ?? '—'), 120),
        ];
    }

    public function actionUrl(): ?string
    {
        return route('my-hr-records.index') . '#terminations';
    }

    public function actionLabel(): string
    {
        return 'View my records';
    }

    public function toArray(object $notifiable): array
    {
        return [
            'type' => 'termination_notice',
            'message' => 'A termination has been recorded for your employment.',
            'termination_id' => $this->termination->id,
            'url' => route('my-hr-records.index') . '#terminations',
        ];
    }
}
