@view('header', [ 'title' => 'Users - Admin' ])

<div class="breadcrumb">
    <ul>
        <li><a href="/">Banq</a></li>
        <li><a href="/admin">Admin</a></li>
        <li class="is-active"><a href="/admin/users">Users</a></li>
    </ul>
</div>

<h1 class="title">Users</h1>

<div class="columns">
    <div class="column">
        <div class="buttons">
            <a class="button is-link" href="/admin/users/create">Create</a>
        </div>
    </div>
    <form class="column" method="get">
        <div class="field has-addons">
            <div class="control" style="width: 100%;">
                <input class="input" type="text" id="q" name="q" placeholder="Search..." value="{{ request('q') }}">
            </div>
            <div class="control">
                <button class="button is-link" type="submit">Search</button>
            </div>
        </div>
    </form>
</div>

@if (count($users) > 0):
    @view('pagination', [ 'page' => $page, 'last_page' => $last_page ])

    <div class="columns is-multiline">
        @foreach ($users as $user):
            <div class="column is-one-third">
                <div class="box" style="height: 100%;">
                    <h2 class="title is-4">
                        <a href="/admin/users/{{ $user->id }}">{{ $user->firstname }} {{ $user->lastname }}</a>
                        @if ($user->role == Users::ROLE_NORMAL):
                            <span class="tag is-pulled-right is-success">NORMAL</span>
                        @endif
                        @if ($user->role == Users::ROLE_ADMIN):
                            <span class="tag is-pulled-right is-danger">ADMIN</span>
                        @endif
                    </h2>
                    <p><span class="tag" style="margin-right: 16px;">{{ $user->username }}</span><a class="tag" href="mailto:{{ $user->email }}">{{ $user->email }}</a></p>
                </div>
            </div>
        @endforeach
    </div>

    @view('pagination', [ 'page' => $page, 'last_page' => $last_page ])
@else:
    <p><i>There are no users found</i></p>
@endif

@view('footer')
