@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 @error('nazov') is-invalid @enderror"
                       placeholder="názov kategórie možností udalosti"
                       @disabled($this->trashed)
                       wire:model.blur.live="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">
                <label for="stav">Stav <span class="text-red">*</span></label>
                <select class="custom-select form-control @error('stav') is-invalid @enderror"
                        name="stav"
                        id="stav"
                        autocomplete="off"
                        @disabled($this->trashed)
                        wire:model.change="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>

    <hr>

    <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()">Zavrieť</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>
