<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->trashMode()) disabled="disabled" @endif
                       wire:model.defer="moznostUdalosti.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('moznostUdalosti.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->trashMode()) disabled="disabled" @endif
                        wire:model="moznostUdalosti.stav"
                >
                    @foreach(\Seka\Portal\Modul\Terminy\Entities\MoznostiUdalosti\StavMoznostiUdalostiEnum::toArray() as $hodnota => $label)
                        <option
                                value="{{ $hodnota }}"
                                @if(\Seka\Portal\Modul\Terminy\Entities\MoznostiUdalosti\StavMoznostiUdalostiEnum::make($hodnota)->equals($moznostUdalosti->stav)) selected="selected" @endif
                        >{{ \Illuminate\Support\Str::ucfirst($label) }}</option>
                    @endforeach
                </select>
                @error('moznostUdalosti.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->trashMode())
                        <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->trashMode() && $this->editMode())
                    <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->trashMode())
                    <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->editMode())
                            Upraviť
                        @else
                            Vytvoriť
                        @endif
                    </button>
                @endif
            </div>
        </div>
    </div>

</form>
