@extends('app.my-account.layout-lite')
@section('page')
    <div class="px-3">
        @include('app.my-account.admin.sessions.filters')
        <div class="table-responsive">
            <table class="table table-sm table-hover table-striped table-bordered mb-0">
                <thead class="fw-bold text-secondary bg-light">
                    <tr>
                        <th colspan="2">User</th>
                        <th class="table-column-sep"></th>
                    </tr>
                    <tr>
                        {{-- User --}}
                        <th>Email</th>
                        <th>Category</th>

                        <th class="table-column-sep">Status</th>
                        <th>Started At</th>
                        <th>Ended At</th>
                        <th>IP Address</th>
                        <th>Device Type</th>
                        <th>Last Activity</th>
                    </tr>
                </thead>
                <tbody>
                    @foreach ($sessions as $session)
                        <tr>
                            <td>{{ $session->user ? $session->user->getEmail() : '--' }}</td>
                            <td>
                                @if ($session->user)
                                    @if ($session->user->is_super_admin)
                                        Admin
                                    @elseif($session->user->is_agreed_as_manager)
                                        Manager
                                    @elseif($session->user->is_agreed_as_rep)
                                        Reseller
                                    @else
                                        Client
                                    @endif
                                @else
                                    --
                                @endif
                            </td>
                            <td class="table-column-sep">{{ $session->is_active ? 'Active' : 'Inactive' }}</td>
                            <td>{{ friendly_date($session->started_at ?? $session->created_at) }}</td>
                            <td>{{ friendly_date($session->ended_at) }}</td>
                            <td>{{ $session->ip_address }}</td>
                            <td>{{ $session->user_agent }}</td>
                            <td>{{ friendly_date($session->last_activity_at) }}</td>
                        </tr>
                    @endforeach
                </tbody>
            </table>
        </div>
        <div class="mt-3">
            {{ $sessions->appends(request()->input())->links() }}
        </div>
    </div>
@endsection
