@php
    $breadcrumbs = [
        ['label' => __('common.home'), 'url' => route('dashboard.index')],
        ['label' => __('common.hr')],
        ['label' => __('leave.title'), 'url' => route('hr.leave.requests.index')],
        ['label' => __('leave.create_title')],
    ];
    $employeeOptions = $employees->mapWithKeys(fn ($e) => [$e->id => $e->full_name])->all();
    $typeOptions = $types->mapWithKeys(fn ($t) => [$t->id => $t->name])->all();
@endphp

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

    <div class="card">
        <div class="card-body">
            <form method="POST" action="{{ route('hr.leave.requests.store') }}" class="row g-3">
                @csrf
                <div class="col-md-6">
                    <x-ui.form.search-select
                        name="employee_id"
                        lookup="employees"
                        :label="__('leave.fields.employee')"
                        :options="$employeeOptions"
                        :selected="old('employee_id')"
                        :placeholder="__('common.select')"
                        required
                    />
                </div>
                <div class="col-md-6">
                    <x-ui.form.search-select
                        name="leave_type_id"
                        lookup="leave_types"
                        :label="__('leave.fields.leave_type')"
                        :options="$typeOptions"
                        :selected="old('leave_type_id')"
                        :placeholder="__('common.select')"
                        required
                    />
                </div>
                <div class="col-md-6">
                    <x-ui.form.input name="start_date" type="date" :label="__('leave.fields.start_date')" :value="old('start_date')" required />
                </div>
                <div class="col-md-6">
                    <x-ui.form.input name="end_date" type="date" :label="__('leave.fields.end_date')" :value="old('end_date')" required />
                </div>
                <div class="col-md-6">
                    <x-ui.form.select
                        name="is_half_day"
                        :label="__('leave.fields.is_half_day')"
                        :options="[0 => __('common.no'), 1 => __('common.yes')]"
                        :selected="old('is_half_day', 0)"
                    />
                </div>
                <div class="col-12">
                    <x-ui.form.input name="reason" :label="__('leave.fields.reason')" :value="old('reason')" />
                </div>
                <div class="col-12">
                    <x-ui.buttons.primary type="submit" icon="fe fe-send">
                        {{ __('leave.actions.submit') }}
                    </x-ui.buttons.primary>
                </div>
            </form>
        </div>
    </div>
</x-ui.layout.page>
