<?php

namespace App\Modules\HR\Overtime\Notifications;

use App\Modules\HR\Overtime\Models\OvertimeRequest;
use App\Support\NotificationCategory;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Notification;

class OvertimeRequestResolvedNotification extends Notification implements ShouldQueue
{
    use Queueable;

    public function __construct(
        public readonly OvertimeRequest $overtimeRequest,
        public readonly string $resolution,
    ) {}

    /**
     * @return list<string>
     */
    public function via(object $notifiable): array
    {
        return ['database'];
    }

    /**
     * @return array<string, mixed>
     */
    public function toArray(object $notifiable): array
    {
        $key = $this->resolution === 'approved'
            ? 'overtime.notifications.approved_body'
            : 'overtime.notifications.rejected_body';

        return [
            'category' => NotificationCategory::APPROVALS,
            'type' => 'overtime_'.$this->resolution,
            'overtime_request_id' => $this->overtimeRequest->id,
            'title' => __('overtime.notifications.'.$this->resolution.'_title'),
            'body' => __($key, ['id' => $this->overtimeRequest->id]),
        ];
    }
}
