<?php

namespace App\Livewire\Merchant;

use App\Models\Order;
use Livewire\Attributes\Layout;
use Livewire\Attributes\Title;
use Livewire\Component;

#[Layout('layouts.merchant')]
#[Title('تفاصيل الطلب - تاجر بلس')]
class OrderDetailPage extends Component
{
    public Order $order;

    public function mount(Order $order): void
    {
        abort_unless($order->user_id === auth()->id(), 403);

        $this->order = $order->load(['items.variant.product', 'loyaltyTransactions']);
    }

    public function render()
    {
        $statusLabels = Order::getStatusLabels();

        return view('livewire.merchant.order-detail-page', compact('statusLabels'));
    }
}
