@props([
    'action',
    'method' => 'POST',
    'submitLabel',
    'parentOptions' => [],
])

@php
    $parentSelect = ['' => __('inventory.categories.no_parent')] + $parentOptions;
@endphp

<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-8">
                    <x-ui.form.input
                        name="name"
                        :label="__('inventory.categories.fields.name')"
                        :value="old('name')"
                        :placeholder="__('inventory.categories.placeholders.name')"
                        required
                    />
                </div>
                <div class="col-md-6">
                    <x-ui.form.search-select
                        name="parent_id"
                        lookup="categories"
                        :label="__('inventory.categories.fields.parent')"
                        :options="$parentOptions"
                        :selected="old('parent_id')"
                        :placeholder="__('inventory.categories.no_parent')"
                        optional
                    />
                </div>
                <div class="col-md-6">
                    <x-ui.form.input
                        name="sort_order"
                        type="number"
                        min="0"
                        :label="__('inventory.categories.fields.sort_order')"
                        :value="old('sort_order', 0)"
                    />
                </div>
            </div>
            <div class="d-flex justify-content-end gap-2 mt-4">
                <x-ui.buttons.secondary :href="route('inventory.categories.index')">
                    {{ __('common.cancel') }}
                </x-ui.buttons.secondary>
                <x-ui.buttons.primary type="submit">{{ $submitLabel }}</x-ui.buttons.primary>
            </div>
        </div>
    </div>
</form>
