@extends('layout')

@section('contenu')
    @if (auth()->user()->administrateur == 1)
        <!-- Modal Creation compte ============================================= -->
        @include('/partials/modalCreationCompte')
        <!-- end creation compte =========================================================== -->
        <section
            style="background-image: url('/img/board.png'); background-attachment: fixed; background-repeat: no-repeat; background-size: cover; min-height: 93.2vh;"
            class="section p-3 mt-0 mb-0 mx-2-touch columns mx-0 is-centered is-flex-desktop is-flex-direction-column is-justify-content-center">
            <nav class="panel mx-auto is-info column is-two-thirds p-0">
                <p class="panel-heading">
                    Les Comptes des utilisateurs
                </p>
                <p class="panel-tabs has-background-white">
                    <a id="default" class="tab" onclick="openContent(event, 'tout')">Tout</a>
                    <a class="tab" onclick="openContent(event, 'administration')">Administration</a>
                    <a class="tab" onclick="openContent(event, 'surveillants')">Surveillants</a>
                    <a class="tab" onclick="openContent(event, 'administrateurs')">Administrateurs</a>
                </p>
                <div class="mb-5" style="background: #E4E9F2; height: 25rem; overflow-y: auto">
                    <p class="has-text-centered p-3">
                        <a onclick="openForm('modalCreationCompte')" class="button is-info is-rounded">
                            <strong>Créer un compte</strong>
                        </a>
                    </p>
                    <div id="tout" class="contenu-block columns mx-0">
                        <div class="column m-2">
                            @foreach ($comptes->sortBy('nom') as $compte)
                                @if ($compte->role == 'administration' || $compte->role == 'surveillant')
                                    <a href="/accueil/comptes/compte/{{ $compte->slug }}" class="panel-block">
                                        <span class="panel-icon">
                                            <i class="fas fa-user" aria-hidden="true"></i>
                                        </span>
                                        {{ $compte->prenom }} {{ $compte->nom }}
                                    </a>
                                @endif
                            @endforeach
                        </div>
                    </div>
                    <div id="administration" class="contenu-block columns mx-0">
                        <div class="column m-2">
                            @foreach ($comptes->sortBy('nom') as $compte)
                                @if ($compte->administrateur == 0 && $compte->role == 'administration')
                                    <a href="/accueil/comptes/compte/{{ $compte->slug }}" class="panel-block">
                                        <span class="panel-icon">
                                            <i class="fas fa-user" aria-hidden="true"></i>
                                        </span>
                                        {{ $compte->prenom }} {{ $compte->nom }}
                                    </a>
                                @endif
                            @endforeach
                        </div>
                    </div>
                    <div id="surveillants" class="contenu-block columns mx-0">
                        <div class="column m-2">
                            @foreach ($comptes->sortBy('nom') as $compte)
                                @if ($compte->administrateur == 0 && $compte->role == 'surveillant')
                                    <a href="/accueil/comptes/compte/{{ $compte->slug }}" class="panel-block">
                                        <span class="panel-icon">
                                            <i class="fas fa-user" aria-hidden="true"></i>
                                        </span>
                                        {{ $compte->prenom }} {{ $compte->nom }}
                                    </a>
                                @endif
                            @endforeach
                        </div>
                    </div>
                    <div id="administrateurs" class="contenu-block columns mx-0">
                        <div class="column m-2">
                            @foreach ($comptes->sortBy('nom') as $compte)
                                @if ($compte->administrateur == 1 && $compte->role == 'administration')
                                    <a href="/accueil/comptes/compte/{{ $compte->slug }}" class="panel-block">
                                        <span class="panel-icon">
                                            <i class="fas fa-user" aria-hidden="true"></i>
                                        </span>
                                        {{ $compte->prenom }} {{ $compte->nom }}
                                    </a>
                                @endif
                            @endforeach
                        </div>
                    </div>
                </div>
                <div class="columns"></div>
                <div style="position: relative;" class="is-flex is-justify-content-center">
                    <img src="/img/upschool.svg" width="200" alt="">
                </div>
            </nav>
        </section>
        @include('/partials/creationCompteJs')
    @else
        <script>
            window.location.replace('/accueil');
        </script>
    @endif
@endsection
