<?php

namespace App\Notifications;

use App\Models\User;

class LeaveBalanceLowNotification extends HrmsNotification
{
    public function __construct(
        protected User $employee,
        protected string $leaveType,
        protected float $available
    ) {}

    public function notificationCategory(): string
    {
        return 'leave';
    }

    public function notificationSubject(): string
    {
        return 'Low leave balance';
    }

    public function notificationLines(): array
    {
        return [
            'Your ' . $this->leaveType . ' balance is low: ' . $this->available . ' day(s) remaining.',
        ];
    }

    public function actionUrl(): ?string
    {
        return route('leaves.dashboard');
    }

    public function actionLabel(): string
    {
        return 'View leave';
    }

    public function toArray(object $notifiable): array
    {
        return [
            'type' => 'leave_balance_low',
            'message' => 'Your ' . $this->leaveType . ' balance is low: ' . $this->available . ' day(s) remaining.',
            'leave_type' => $this->leaveType,
            'available' => $this->available,
            'url' => route('leaves.dashboard'),
        ];
    }

    protected function fcmType(): string
    {
        return 'leave_balance_low';
    }

    protected function fcmRoute(): string
    {
        return '/leave';
    }
}
