@extends('layouts.app')
@section('title', $typeLabel)
@section('content')
<div class="d-flex justify-content-between align-items-center mb-3">
    <h3>{{ $typeLabel }}</h3>
    <a href="{{ route('partner.requests.create', $type) }}" class="btn btn-primary">+ Nouvelle demande</a>
</div>

<div class="card p-3">
    <div class="table-responsive">
        <table class="table align-middle">
            <thead>
                <tr>
                    <th>#</th>
                    <th>Statut</th>
                    <th>Urgence</th>
                    <th>Qte demandee</th>
                    <th>Qte collectee</th>
                    <th>Cree le</th>
                </tr>
            </thead>
            <tbody>
                @forelse($requests as $r)
                <tr class="{{ $r->status === 'ecart' ? 'table-danger' : '' }}">
                    <td>{{ $r->id }}</td>
                    <td><span class="badge {{ $r->status === 'ecart' ? 'badge-ecart' : 'bg-secondary' }}">{{ \App\Models\ServiceRequest::statuses()[$r->status] }}</span></td>
                    <td>{{ $r->urgency === 'urgent' ? 'Urgent' : 'Normal' }}</td>
                    <td>{{ $r->requested_quantity ?? '-' }}</td>
                    <td>{{ $r->collected_quantity ?? '-' }}</td>
                    <td>{{ $r->created_at->format('d/m/Y H:i') }}</td>
                </tr>
                @empty
                <tr><td colspan="6" class="text-center text-muted">Aucune demande dans cette categorie.</td></tr>
                @endforelse
            </tbody>
        </table>
    </div>
    {{ $requests->links() }}
</div>
@endsection
