<?php

namespace App\Notifications;

use App\Models\Promotion;

class PromotionRecordedNotification extends HrmsNotification
{
    public function __construct(
        public Promotion $promotion
    ) {}

    public function notificationCategory(): string
    {
        return 'hr_recognition';
    }

    public function notificationSubject(): string
    {
        return 'Your promotion has been recorded';
    }

    public function notificationLines(): array
    {
        $from = $this->promotion->fromDesignation?->name;
        $to = $this->promotion->toDesignation?->name;

        $lines = [
            'Congratulations — a promotion has been recorded for you.',
            'Effective date: ' . $this->promotion->promotion_date?->format('d M Y'),
        ];

        if ($from || $to) {
            $lines[] = 'Designation: ' . ($from ?: '—') . ' → ' . ($to ?: '—');
        }

        return $lines;
    }

    public function actionUrl(): ?string
    {
        return route('my-hr-records.index') . '#promotions';
    }

    public function actionLabel(): string
    {
        return 'View my records';
    }

    public function toArray(object $notifiable): array
    {
        return [
            'type' => 'promotion_recorded',
            'message' => 'Your promotion has been recorded.',
            'promotion_id' => $this->promotion->id,
            'url' => route('my-hr-records.index') . '#promotions',
        ];
    }
}
