<?php

declare(strict_types=1);

namespace App\Listeners;

use App\Contracts\Repositories\BookingRepositoryInterface;
use App\Events\PaymentProofSubmitted;

final class UpdateBookingStatusOnPaymentProofSubmitted
{
    public function __construct(
        private readonly BookingRepositoryInterface $bookingRepository
    ) {}

    public function handle(PaymentProofSubmitted $event): void
    {
        $transaction = $event->transaction;

        // Update booking status to 'pending_verification' (awaiting admin verification)
        $this->bookingRepository->update($transaction->booking_id, [
            'status' => 'pending_verification',
        ]);
    }
}
