<?php

namespace App\Notifications;

use App\Models\IncomeTaxDeclaration;
use Illuminate\Support\Str;

class IncomeTaxDeclarationReviewedNotification extends HrmsNotification
{
    public function __construct(
        public IncomeTaxDeclaration $declaration,
        public string $outcome
    ) {}

    public function notificationCategory(): string
    {
        return 'income_tax';
    }

    public function notificationSubject(): string
    {
        return 'Your income tax declaration was ' . $this->outcome;
    }

    public function notificationLines(): array
    {
        $lines = [
            'Your declaration for FY ' . $this->declaration->financial_year . ' was ' . $this->outcome . '.',
            'Regime: ' . ucfirst($this->declaration->regime),
        ];

        if ($this->declaration->hr_remarks) {
            $lines[] = 'HR remarks: ' . Str::limit((string) $this->declaration->hr_remarks, 120);
        }

        return $lines;
    }

    public function actionUrl(): ?string
    {
        return route('payroll.index', ['tab' => 'my', 'my_sub' => 'income-tax']);
    }

    public function actionLabel(): string
    {
        return 'View declaration';
    }

    public function toArray(object $notifiable): array
    {
        return [
            'type' => 'income_tax_reviewed',
            'message' => 'Your FY ' . $this->declaration->financial_year . ' tax declaration was ' . $this->outcome . '.',
            'outcome' => $this->outcome,
            'declaration_id' => $this->declaration->id,
            'financial_year' => $this->declaration->financial_year,
            'url' => route('payroll.index', ['tab' => 'my', 'my_sub' => 'income-tax']),
        ];
    }
}
