<x-admin.layout title="Dashboard">
    @if ($databaseError)
        <div class="errors">{{ $databaseError }}</div>
    @endif
    <div class="grid stats">
        @foreach ($counts as $label => $count)
            <div class="card">
                <div class="muted">{{ ucfirst($label) }}</div>
                <div class="stat">{{ $count }}</div>
            </div>
        @endforeach
    </div>
    <div class="grid two" style="margin-top:16px">
        <div class="card">
            <h2>Recent Products</h2>
            <div class="table-wrap">
            <table>
                <thead><tr><th>Name</th><th>Status</th></tr></thead>
                <tbody>
                @foreach ($products as $product)
                    <tr><td>{{ $product->name }}<br><span class="muted">{{ $product->slug }}</span></td><td>{{ $product->status }}</td></tr>
                @endforeach
                </tbody>
            </table>
            </div>
        </div>
        <div class="card">
            <h2>Recent API Logs</h2>
            <div class="table-wrap">
            <table>
                <thead><tr><th>Time</th><th>Request</th><th>Status</th></tr></thead>
                <tbody>
                @foreach ($logs as $log)
                    <tr><td>{{ $log->created_at?->format('Y-m-d H:i') }}</td><td>{{ $log->method }} {{ $log->path }}</td><td>{{ $log->status }}</td></tr>
                @endforeach
                </tbody>
            </table>
            </div>
        </div>
    </div>
</x-admin.layout>
