<div class="m-0 p-0">
    <div class="card-header bg-secondary d-flex justify-content-between">
        <button class="btn btn-primary" type="button" data-target="#new-registration" data-toggle="collapse">+ Vytvoriť novú registráciu</button>
    </div>
    <div class="collapse" id="new-registration" wire:ignore.self>
        <div class="card-body">
            <div class="row justify-content-center text-center my-2">
                <div class="col-lg-4 col-md-5">
                    <h6>Zvoľte existujúceho používateľa</h6>
                </div>
            </div>

            <div class="form-group">
                <select wire:model="pouzivatel.hash_id"
                        class="custom-select form-control"
                        id="pouzivatel"
                        name="pouzivatel"
                        autocomplete="off"
                >
                    @if($pouzivatelia->isNotEmpty())
                    <option value="-1">Zvoľte používateľa...</option>
                    @else
                    <option value="-1">neexistuje žiadny používateľ</option>
                    @endif
                    @foreach($pouzivatelia as $_pouzivatel)
                    <option value="{{ $_pouzivatel->hash_id }}">{{ $_pouzivatel->pracovisko->kod }}, {{ $_pouzivatel->meno }}</option>
                    @endforeach
                </select>
                @error('pouzivatel.hash_id')<div class="invalid-feedback">{{ $message }}</div>@enderror
            </div>

            <div class="row justify-content-center text-center my-2">
                <div class="col-lg-4 col-md-5">
                    <h6>alebo zadajte celé meno a priezvisko</h6>
                </div>
            </div>

            <div class="form-row">
                <div class="col">
                    <div class="form-group">
                        <label for="meno">Meno</label>
                        <input wire:model="registracia.meno"
                               type="text"
                               id="meno"
                               class="form-control from-control-lg"
                               name="meno"
                               placeholder="Meno používateľa"
                               autocomplete="off"
                        >
                        @error('registracia.meno')<div class="invalid-feedback">{{ $message }}</div>@enderror
                    </div>
                </div>
                <div class="col">
                    <div class="form-group">
                        <label for="priezvisko">Priezvisko</label>
                        <input wire:model="registracia.priezvisko"
                               type="text"
                               id="priezvisko"
                               class="form-control from-control-lg"
                               name="priezvisko"
                               placeholder="Priezvisko používateľa"
                               autocomplete="off"
                        >
                        @error('registracia.priezvisko')<div class="invalid-feedback">{{ $message }}</div>@enderror
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label for="poznamka">Poznámka</label>
                <textarea wire:model.defer="registracia.poznamka"
                          id="poznamka"
                          name="poznamka"
                          rows="3"
                          class="form-control form-control-lg"
                          autocomplete="off"
                          maxlength="500"
                ></textarea>
                @error('registracia.poznamka')<div class="invalid-feedback">{{ $message }}</div>@enderror
            </div>
            <div class="d-flex align-items-center">
                <button type="submit" class="btn btn-success mr-3" wire:click="create()">
                    <span wire:loading.remove wire:target="create" class="icon-floppy"></span>
                    <span wire:loading wire:target="create" class="spinner-grow spinner-grow-sm" role="status"></span>
                    Vytvoriť
                </button>
                <a href="#new-registration" class="text-small text-muted" data-toggle="collapse">Zrušiť</a>
            </div>
        </div>
    </div>
</div>