@php
    $breadcrumbs = [
        ['label' => __('common.home'), 'url' => route('dashboard.index')],
        ['label' => __('common.hr')],
        ['label' => __('shifts.title'), 'url' => route('hr.shifts.index')],
        ['label' => __('shifts.assign_title')],
    ];
    $employeeOptions = $employees->mapWithKeys(fn ($e) => [$e->id => $e->full_name])->all();
    $shiftOptions = $shifts->mapWithKeys(fn ($s) => [$s->id => $s->name])->all();
@endphp

<x-ui.layout.page
    :title="__('shifts.assign_title')"
    :subtitle="__('shifts.assign_subtitle')"
    page-icon="fe fe-user-plus"
    :breadcrumbs="$breadcrumbs"
>
    <x-slot:actions>
        <x-ui.buttons.secondary :href="route('hr.shifts.index')" icon="fe fe-arrow-left">
            {{ __('shifts.actions.back') }}
        </x-ui.buttons.secondary>
    </x-slot:actions>

    <div class="card">
        <div class="card-body">
            <form method="POST" action="{{ route('hr.shifts.assignments.store') }}" class="row g-3">
                @csrf
                <div class="col-md-6">
                    <x-ui.form.search-select
                        name="employee_id"
                        lookup="employees"
                        :label="__('shifts.fields.employee')"
                        :options="$employeeOptions"
                        :selected="old('employee_id')"
                        :placeholder="__('common.select')"
                        required
                    />
                </div>
                <div class="col-md-6">
                    <x-ui.form.search-select
                        name="shift_id"
                        lookup="shifts"
                        :label="__('shifts.fields.shift')"
                        :options="$shiftOptions"
                        :selected="old('shift_id')"
                        :placeholder="__('common.select')"
                        required
                    />
                </div>
                <div class="col-md-6">
                    <x-ui.form.input
                        name="starts_at"
                        type="datetime-local"
                        :label="__('shifts.fields.starts_at')"
                        :value="old('starts_at')"
                    />
                </div>
                <div class="col-12">
                    <x-ui.buttons.primary type="submit" icon="fe fe-check">
                        {{ __('shifts.actions.assign_save') }}
                    </x-ui.buttons.primary>
                </div>
            </form>
        </div>
    </div>

    @push('scripts')
        @vite(['resources/js/modules/hr/shifts/main.js'])
    @endpush
</x-ui.layout.page>
