<?php

namespace App\Jobs;

use App\Mail\ApprovalDecisionMail;
use App\Models\TravelRequest;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Foundation\Queue\Queueable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Mail;

class SendApprovalDecisionEmail implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    public function __construct(
        public readonly TravelRequest $travelRequest,
    ) {}

    public function handle(): void
    {
        Mail::to($this->travelRequest->user->email)
            ->queue(new ApprovalDecisionMail($this->travelRequest));
    }
}
