@extends('layouts.admin')

@section('title', 'Manage Orders')
@section('heading', 'Orders')

@section('content')
    <section class="card">
        <table>
            <thead>
                <tr>
                    <th>Order</th>
                    <th>Customer</th>
                    <th>Email</th>
                    <th>Status</th>
                    <th>Total</th>
                    <th>Placed</th>
                    <th></th>
                </tr>
            </thead>
            <tbody>
                @foreach ($orders as $order)
                    <tr>
                        <td>{{ $order->order_number }}</td>
                        <td>{{ $order->customer_name }}</td>
                        <td>{{ $order->email }}</td>
                        <td><span class="pill">{{ ucfirst($order->status) }}</span></td>
                        <td>${{ number_format((float) $order->total_amount, 2) }}</td>
                        <td>{{ $order->created_at->format('M d, Y') }}</td>
                        <td><a class="ghost-button button" href="{{ route('admin.orders.show', $order) }}">View</a></td>
                    </tr>
                @endforeach
            </tbody>
        </table>
        <div style="padding: 20px;">{{ $orders->links() }}</div>
    </section>
@endsection
