@props([
    'action',
    'method' => 'POST',
    'interview' => null,
    'modeOptions',
    'submitLabel',
])

<form method="POST" action="{{ $action }}" novalidate>
    @csrf
    @if (strtoupper($method) !== 'POST')
        @method($method)
    @endif
    <div class="card">
        <div class="card-body">
            <div class="row g-3">
                <div class="col-md-6">
                    <x-ui.form.search-select
                        name="application_id"
                        lookup="applications"
                        :label="__('recruitment.interviews.fields.application')"
                        :options="$interview?->application
                            ? [$interview->application_id => $interview->application->reference_code]
                            : []"
                        :selected="old('application_id', $interview?->application_id)"
                        :placeholder="__('common.select')"
                        required
                    />
                </div>
                <div class="col-md-3">
                    <x-ui.form.input
                        name="scheduled_at"
                        type="datetime-local"
                        :label="__('recruitment.interviews.fields.scheduled_at')"
                        :value="old('scheduled_at', $interview?->scheduled_at?->format('Y-m-d\TH:i'))"
                        required
                    />
                </div>
                <div class="col-md-3">
                    <x-ui.form.select
                        name="mode"
                        :label="__('recruitment.interviews.fields.mode')"
                        :options="$modeOptions"
                        :selected="old('mode', $interview?->mode ?? 'in_person')"
                        required
                    />
                </div>
                <div class="col-md-6">
                    <x-ui.form.input
                        name="location"
                        :label="__('recruitment.interviews.fields.location')"
                        :value="old('location', $interview?->location)"
                    />
                </div>
                <div class="col-md-6">
                    <x-ui.form.search-select
                        name="interviewer_user_id"
                        lookup="users"
                        :label="__('recruitment.interviews.fields.interviewer')"
                        :options="$interview?->interviewer
                            ? [$interview->interviewer_user_id => $interview->interviewer->name]
                            : []"
                        :selected="old('interviewer_user_id', $interview?->interviewer_user_id)"
                        :placeholder="__('common.select')"
                    />
                </div>
                <div class="col-12">
                    <x-ui.form.input
                        name="notes"
                        :label="__('recruitment.interviews.fields.notes')"
                        :value="old('notes', $interview?->notes)"
                    />
                </div>
            </div>
        </div>
        <div class="card-footer d-flex justify-content-end gap-2 bg-white">
            <x-ui.buttons.secondary :href="route('hr.recruitment.interviews.index')">{{ __('common.cancel') }}</x-ui.buttons.secondary>
            <x-ui.buttons.primary type="submit">{{ $submitLabel }}</x-ui.buttons.primary>
        </div>
    </div>
</form>
