<x-app-layout title="Edit care unit">
    <div class="mx-auto max-w-lg">
        <h1 class="text-xl font-semibold text-slate-900">Edit care unit</h1>
        <form method="POST" action="{{ route('care.care-units.update', $unit) }}" class="mt-6 space-y-4 rounded-2xl border border-slate-200 bg-white p-6">
            @csrf @method('PUT')
            <div>
                <label class="block text-sm font-medium">Department</label>
                <select name="department_id" required class="mt-1 w-full rounded-lg border-slate-300 text-sm">
                    @foreach ($departments as $department)
                        <option value="{{ $department->id }}" @selected((int) old('department_id', $unit->department_id) === (int) $department->id)>
                            {{ $department->labelForSelect() }}
                        </option>
                    @endforeach
                </select>
            </div>
            <div>
                <label class="block text-sm font-medium">Name</label>
                <input type="text" name="name" value="{{ old('name', $unit->name) }}" required class="mt-1 w-full rounded-lg border-slate-300 text-sm">
            </div>
            <div>
                <label class="block text-sm font-medium">Code</label>
                <input type="text" name="code" value="{{ old('code', $unit->code) }}" class="mt-1 w-full rounded-lg border-slate-300 text-sm">
            </div>
            <div>
                <label class="block text-sm font-medium">Kind</label>
                <select name="kind" class="mt-1 w-full rounded-lg border-slate-300 text-sm">
                    @foreach ($kinds as $value => $label)
                        <option value="{{ $value }}" @selected(old('kind', $unit->kind) === $value)>{{ $label }}</option>
                    @endforeach
                </select>
            </div>
            <label class="flex items-center gap-2 text-sm"><input type="checkbox" name="is_active" value="1" @checked(old('is_active', $unit->is_active))> Active</label>
            <button type="submit" class="btn-primary w-full">Save changes</button>
        </form>
    </div>
</x-app-layout>
