@php
    $breadcrumbs = [
        ['label' => __('common.home'), 'url' => route('dashboard.index')],
        ['label' => __('me.attendance_title'), 'url' => route('me.attendance.index')],
        ['label' => __('attendance_corrections.employee_title')],
    ];
@endphp

<x-ui.layout.page
    :title="__('attendance_corrections.employee_title')"
    :subtitle="__('attendance_corrections.employee_subtitle')"
    page-icon="fe fe-edit-3"
    :breadcrumbs="$breadcrumbs"
>
    <x-slot:actions>
        @can('create', \App\Modules\HR\Attendance\Models\AttendanceCorrectionRequest::class)
            <x-ui.buttons.primary :href="route('me.attendance.corrections.create')" icon="fe fe-plus">
                {{ __('attendance_corrections.actions.new') }}
            </x-ui.buttons.primary>
        @endcan
        <x-ui.buttons.secondary :href="route('me.attendance.index')" icon="fe fe-arrow-left">
            {{ __('attendance_corrections.actions.back_attendance') }}
        </x-ui.buttons.secondary>
    </x-slot:actions>

    <x-ui.table.table :columns="[
        ['label' => '#'],
        ['label' => __('attendance_corrections.fields.date')],
        ['label' => __('attendance_corrections.fields.type')],
        ['label' => __('attendance_corrections.fields.status')],
        ['label' => __('attendance_corrections.fields.requested_check_in')],
        ['label' => __('attendance_corrections.fields.requested_check_out')],
    ]">
        @forelse ($paginator as $row)
            <x-ui.table.row>
                <td><code>{{ $row->id }}</code></td>
                <td>{{ $row->attendanceRecord?->attendance_date?->format('Y-m-d') ?? '—' }}</td>
                <td>{{ __('attendance_corrections.types.'.$row->type) }}</td>
                <td>
                    <span class="badge bg-secondary">{{ __('attendance_corrections.status.'.$row->status) }}</span>
                </td>
                <td>{{ $row->requested_check_in?->format('Y-m-d H:i') ?? '—' }}</td>
                <td>{{ $row->requested_check_out?->format('Y-m-d H:i') ?? '—' }}</td>
            </x-ui.table.row>
        @empty
            <x-ui.table.row>
                <td colspan="6" class="text-center text-muted py-4">{{ __('attendance_corrections.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>
