@php use Illuminate\Support\Str; @endphp
@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">
                        <div class="list-group list-group-flush">
                            @forelse($registracie as $registracia)
                                <div class="list-group-item position-relative">
                                    <a href="{{ route('modul.terminy.frontend.udalosti.udalost.show', $registracia->udalost) }}"
                                       class="stretched-link"></a>
                                    <div class="media item-align-center">
                                        <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">{{ 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 position-relative">
                                                        <button class="btn btn-sm btn-outline-primary dropdown-toggle dropdown-toggle-no-arrow"
                                                                id="dropdownMenuButton-1"
                                                                type="button"
                                                                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 class="card-footer bg-secondary d-flex justify-content-between align-items-center">
                                {{ $registracie->onEachSide(5)->links() }}
                                {{ $registracie->links('partials.pagination.pagination-summary') }}
                            </div>
                        </div>
                    </div>
                </div>
            </div>
    </section>
@endsection
