<?php

declare(strict_types=1);

namespace App\Notifications\Payments;

use App\Models\Transaction;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Notification;

final class DisputeResolved extends Notification implements ShouldQueue
{
    use Queueable;

    public function __construct(
        public Transaction $transaction,
        public string $recipient
    ) {}

    /**
     * Get the notification's delivery channels.
     *
     * @return array<int, string>
     */
    public function via(object $notifiable): array
    {
        return ['database'];
    }

    /**
     * Get the array representation of the notification.
     *
     * @return array<string, mixed>
     */
    public function toArray(object $notifiable): array
    {
        $outcome = match ($this->transaction->status) {
            'verified' => 'verified',
            'rejected' => 'rejected',
            'refunded' => 'refunded',
            default => 'resolved',
        };

        return [
            'title' => 'Dispute Resolved',
            'message' => 'The payment dispute for booking #'.$this->transaction->booking_id.' has been '.$outcome.' by admin.',
            'icon' => 'check-badge',
            'url' => route('guest.dashboard'),
            'transaction_id' => $this->transaction->id,
            'booking_id' => $this->transaction->booking_id,
        ];
    }
}
