@extends('Terminy::layouts.integrated')

@section('content')
    @parent
    <section class="bg-white space-sm">
        <div class="container">
            <div class="row justify-content-center">
                <div class="col">
                    <h1 class="h2 mb-2">Moje registrácie na udalosti</h1>
                    <span>Zoznam všetkých mojich registrácií na vytvorené udalosti</span>
                    @include('flash::message')
                </div>
            </div>
        </div>
    </section>

    <section>
        <div class="container">
            <div class="row justify-content-between">
                <div class="col">
                    <div class="card card-sm shadow">
                        @if($registracie->isNotEmpty())
                        <div class="card-header bg-secondary d-flex justify-content-between align-items-center">
                            <div>
                                <span class="text-muted text-small">Počet položiek {{ ($registracie->currentPage() * $registracie->perPage()) - $registracie->perPage() + 1 }} - @if($registracie->total() > ($registracie->currentPage() * $registracie->perPage())) {{ $registracie->currentPage() * $registracie->perPage() }} @else {{ $registracie->total() }} @endif z {{ $registracie->total() }}</span>
                            </div>
                        </div>
                        @endif

                        <div class="list-group list-group-flush">
                            @forelse($registracie as $registracia)
                            <div class="list-group-item list-group-item-action" href="{{ route('modul.terminy.frontend.udalosti.udalost.show', $registracia->udalost) }}">
                                <div class="media">
                                    <div class="media-body">
                                        <div class="d-flex justify-content-between">
                                            <div>
                                                <h3 class="h4 mb-0 text-truncate">{{ $registracia->udalost->nazov }}</h3>
                                                <h4 class="text-muted lead mb-2">{{ \Illuminate\Support\Str::ucfirst($registracia->udalost->druh->label) }}</h4>
                                                <h3 class="h4 text-truncate">
                                                    <div class="d-flex justify-content-between">
                                                        <div class="text-small">
                                                            <ul class="list-inline text-muted">
                                                                <li class="list-inline-item">
                                                                    <span class="icon-calendar"></span>
                                                                    Začiatok: {{ $registracia->udalost->datum_od->format('d.m.Y H:i') }}
                                                                </li>
                                                                <li class="list-inline-item">
                                                                    <span class="icon-calendar"></span>
                                                                    Koniec: {{ $registracia->udalost->datum_do->format('d.m.Y H:i') }}
                                                                </li>
                                                            </ul>
                                                        </div>
                                                    </div>
                                                </h3>
                                            </div>
                                            <div class="d-flex align-items-center">
                                                <div class="dropdown">
                                                    <button class="btn btn-sm btn-outline-primary dropdown-toggle dropdown-toggle-no-arrow" type="button" id="dropdownMenuButton-1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                                                        <i class="icon-dot-3"></i>
                                                    </button>
                                                    <div class="dropdown-menu dropdown-menu-sm">
                                                        <a class="dropdown-item" href="#" onclick="event.preventDefault();(confirm('Chystáte sa odstrániť registráciu, prajete si pokračovať?')) ? document.getElementById('delete-registracia-{{ $registracia->hashId() }}-form').submit() : null;">
                                                            <i class="fa fa-trash mr-1"></i>
                                                            Zrušiť registráciu
                                                        </a>

                                                        <form id="delete-registracia-{{ $registracia->hashId() }}-form" action="{{ route('modul.terminy.frontend.registracie.pouzivatel.delete', [$registracia->udalost, $registracia]) }}" method="POST" style="display: none;">
                                                            @csrf
                                                            @method('DELETE')
                                                        </form>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            @empty
                            <div class="list-group-item bg-light d-flex justify-content-center disabled py-4">
                                <span class="text-muted h5">Žiadne registrácie na udalosti sa nenašli...</span>
                            </div>
                            @endforelse
                        </div>
                    </div>

                @if($registracie->isNotEmpty() && $registracie->hasPages())
                    <div class="d-flex justify-content-center">
                        {{ $registracie->links() }}
                    </div>
                @endif
                </div>
            </div>
        </div>
    </section>
@endsection
