@php use Illuminate\Support\Str;use Seka\Portal\Modul\Terminy\Entities\MoznostiUdalosti\StavMoznostiUdalostiEnum; @endphp
<form wire:submit.prevent="save">
    @include('flash::message')
    <div class="form-row">
        <div class="col col-md-8">
            <div class="form-group">
                <label for="nazov">Názov <span class="text-red">*</span></label>
                <input type="text"
                       id="nazov"
                       name="nazov"
                       autocomplete="off"
                       class="form-control"
                       placeholder="názov kategórie možností udalosti"
                       @if($this->trashed) disabled="disabled" @endif
                       wire:model.defer="nazov"
                >
                <small class="form-text text-muted">Názov kategórie možností udalosti, pre ktorú bude možné v prípade
                    jej zvolenia v rámci udalosti nadefinovať položky možností.</small>
                @error('nazov')
                <div class="invalid-feedback">{{ $message }}</div>@enderror
            </div>
        </div>

        <div class="col col-md-4">
            <div class="form-group" wire:ignore>
                <label for="stav">Stav <span class="text-red">*</span></label>
                <select class="custom-select form-control"
                        name="stav"
                        id="stav"
                        autocomplete="off"
                        @if($this->trashed) disabled="disabled" @endif
                        wire:model="stav"
                >
                    @foreach(StavMoznostiUdalostiEnum::cases() as $case)
                        <option wire:key="wk-stav-udalosti-{{ $case->name }}"
                                value="{{ $case->name }}"
                        >{{ Str::ucfirst($case->label()) }}</option>
                    @endforeach
                </select>
                @error('stav')
                <div class="invalid-feedback">{{ $message }}</div>@enderror
            </div>
        </div>
    </div>

    <div class="form-row">
        <div class="col d-flex justify-content-between">
            <div class="col-auto m-0 p-0">
                @can('terminy')
                    @if($this->trashed)
                        <button type="button" wire:click="restore()" class="btn btn-secondary">
                            <span wire:loading.remove wire:target="restore" class="icon-cw"></span>
                            <span wire:loading wire:target="restore" class="spinner-grow spinner-grow-sm"
                                  role="status"></span>
                            Obnoviť
                        </button>
                    @endif
                @endcan
                @if(!$this->trashed && $this->exists)
                    <button type="button" class="btn btn-danger" wire:click="trash()">
                        <span wire:loading.remove wire:target="trash" class="icon-cancel-circled"></span>
                        <span wire:loading wire:target="trash" class="spinner-grow spinner-grow-sm"
                              role="status"></span>
                        Zneplatniť
                    </button>
                @endif
            </div>

            <div class="col-auto m-0 p-0">
                <button type="button" class="btn btn-link" wire:click="cancel()">Zrušiť</button>
                @if(!$this->trashed)
                    <button type="button" wire:click="save()" class="btn btn-primary">
                        <span wire:loading.remove wire:target="save" class="icon-floppy"></span>
                        <span wire:loading wire:target="save" class="spinner-grow spinner-grow-sm" role="status"></span>
                        @if($this->exists)
                            Upraviť
                        @else
                            Vytvoriť
                        @endif
                    </button>
                @endif
            </div>
        </div>
    </div>
</form>
