@php
    use App\Modules\HR\PermissionRequests\Models\PermissionRequest;
    $breadcrumbs = [
        ['label' => __('common.home'), 'url' => route('dashboard.index')],
        ['label' => __('me.permission_requests_title')],
    ];
@endphp

<x-ui.layout.page
    :title="__('me.permission_requests_title')"
    :subtitle="__('me.permission_requests_subtitle')"
    page-icon="fe fe-shield"
    :breadcrumbs="$breadcrumbs"
>
    <x-slot:actions>
        @can('create', PermissionRequest::class)
            <x-ui.buttons.primary :href="route('me.permission-requests.create')" icon="fe fe-plus">
                {{ __('me.permission_requests.new') }}
            </x-ui.buttons.primary>
        @endcan
    </x-slot:actions>

    <x-ui.table.table :columns="[
        ['label' => '#'],
        ['label' => __('permission_requests.fields.type')],
        ['label' => __('permission_requests.fields.request_date')],
        ['label' => __('permission_requests.fields.status')],
    ]">
        @forelse ($paginator as $req)
            <x-ui.table.row>
                <td><code>{{ $req->id }}</code></td>
                <td>{{ __('permission_requests.types.'.$req->type) }}</td>
                <td>{{ $req->request_date?->format('Y-m-d') }}</td>
                <td><span class="badge bg-secondary">{{ __('permission_requests.status.'.$req->status) }}</span></td>
            </x-ui.table.row>
        @empty
            <x-ui.table.row>
                <td colspan="4" class="text-center text-muted py-4">{{ __('permission_requests.empty') }}</td>
            </x-ui.table.row>
        @endforelse
    </x-ui.table.table>

    @if ($paginator->hasPages())
        <div class="mt-3 d-flex justify-content-center">{{ $paginator->links() }}</div>
    @endif
</x-ui.layout.page>
