@extends('layouts.admin')

@section('title', 'Orders')

@section('content')
    <section class="dashboard-head">
        <div>
            <span class="eyebrow">Fulfillment</span>
            <h1>Orders</h1>
        </div>
    </section>

    @if (session('status'))
        <p class="form-status">{{ session('status') }}</p>
    @endif

    <section class="panel">
        <div class="table-wrap">
            <table>
                <thead>
                    <tr>
                        <th>Order</th>
                        <th>Customer</th>
                        <th>Status</th>
                        <th>Total</th>
                        <th>Action</th>
                    </tr>
                </thead>
                <tbody>
                    @forelse ($orders as $order)
                        <tr>
                            <td><strong>{{ $order->order_number }}</strong></td>
                            <td>{{ $order->customer->name }}</td>
                            <td><span class="status pending">{{ $order->statusLabel() }}</span></td>
                            <td>{{ \App\Models\SiteSetting::formatPrice($order->total) }}</td>
                            <td><a class="text-button" href="{{ route('admin.orders.show', $order) }}">Manage</a></td>
                        </tr>
                    @empty
                        <tr><td colspan="5">No orders yet.</td></tr>
                    @endforelse
                </tbody>
            </table>
        </div>
        {{ $orders->links() }}
    </section>
@endsection
