@props(['action', 'method' => 'POST', 'asset' => null])
<form method="POST" action="{{ $action }}">
    @csrf
    @if ($method !== 'POST') @method($method) @endif
    <div class="card"><div class="card-body"><div class="row g-3">
        <div class="col-md-4"><x-ui.form.input name="asset_code" :label="__('assets.fields.asset_code')"
            :value="old('asset_code', $asset?->asset_code)" required /></div>
        <div class="col-md-4"><x-ui.form.input name="name" :label="__('assets.fields.name')"
            :value="old('name', $asset?->name)" required /></div>
        <div class="col-md-4"><x-ui.form.input name="category" :label="__('assets.fields.category')"
            :value="old('category', $asset?->category)" required /></div>
        <div class="col-md-4"><x-ui.form.input name="serial_number" :label="__('assets.fields.serial_number')"
            :value="old('serial_number', $asset?->serial_number)" /></div>
        <div class="col-md-4"><x-ui.form.input name="purchase_date" type="date" :label="__('assets.fields.purchase_date')"
            :value="old('purchase_date', $asset?->purchase_date?->format('Y-m-d'))" /></div>
        <div class="col-md-4"><x-ui.form.input name="warranty_until" type="date" :label="__('assets.fields.warranty_until')"
            :value="old('warranty_until', $asset?->warranty_until?->format('Y-m-d'))" /></div>
        <div class="col-md-6"><x-ui.form.input name="location" :label="__('assets.fields.location')"
            :value="old('location', $asset?->location)" /></div>
        @if ($asset && $asset->status !== 'assigned')
            <div class="col-md-6"><x-ui.form.select name="status" :label="__('assets.fields.status')"
                :options="collect(['available','maintenance','damaged','retired','lost'])->mapWithKeys(fn($s) => [$s => __('assets.statuses.'.$s)])->all()"
                :selected="old('status', $asset->status)" /></div>
        @endif
        <div class="col-12"><x-ui.form.input name="notes" :label="__('assets.fields.notes')"
            :value="old('notes', $asset?->notes)" /></div>
    </div></div><div class="card-footer text-end">
        <x-ui.buttons.primary type="submit">{{ __('common.save') }}</x-ui.buttons.primary>
    </div></div>
</form>
