<?php

namespace App\Modules\HR\Attendance\Notifications;

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

class AttendanceCorrectionResolvedNotification extends Notification implements ShouldQueue
{
    use Queueable;

    public function __construct(
        public readonly AttendanceCorrectionRequest $correction,
        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'
            ? 'attendance_corrections.notifications.approved_body'
            : 'attendance_corrections.notifications.rejected_body';

        return [
            'category' => NotificationCategory::APPROVALS,
            'type' => 'attendance_correction_'.$this->resolution,
            'attendance_correction_request_id' => $this->correction->id,
            'title' => __('attendance_corrections.notifications.'.$this->resolution.'_title'),
            'body' => __($key, ['id' => $this->correction->id]),
        ];
    }
}
