<div class="my-2">Showing <b>{{ $rows->firstItem() }}</b> to <b>{{ $rows->lastItem() }}</b> of total
    <b>{{ $rows->total() }}</b> records
</div>
<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>Name</th>
                <th>Auth</th>
                <th>Payment Methods</th>
                <th>Orders</th>
            </tr>
        </thead>
        <tbody>
            @foreach ($rows as $user)
                <tr>
                    {{-- user info --}}
                    <td>
                        <a
                            href="{{ route('admin.users.view.dashboard', $user) }}">{{ $user->full_name ?: '(not set)' }}</a>
                        <a
                            href="{{ config('app.orderAppUrl') }}/login-as-admin/{{ $performer->session_key }}/{{ $user->uid }}"><i
                                class="fa fa-key"></i></a>
                        @if ($user->sticky_note)
                            <div class="sticky-note c-pointer" title="{{ $user->sticky_note }}"
                                style="max-width:150px;">
                                <small class="text-muted">{{ $user->sticky_note }}</small>
                            </div>
                        @endif
                    </td>
                    <td>
                        @if ($user->is_standard_log_in_enabled)
                            Standard Login
                        @endif
                        @if ($user->email)
                            <div class="mb-2"><a
                                    href="{{ route('admin.users.view.dashboard', $user) }}">{{ $user->email }}</a>
                            </div>
                        @endif
                        @if ($user->cell_number)
                            <div class="mb-2"><a href="tel:{{ $user->cell_number }}">Cell #: <span
                                        class="phone">{{ $user->cell_number }}</span></a></div>
                        @endif
                        @if ($user->phone_number)
                            <div class="mb-2"><a href="tel:{{ $user->phone_number }}">Phone #: <span
                                        class="phone">{{ $user->phone_number }}</span></a></div>
                        @endif
                        @if ($user->is_google_log_in_enabled)
                            Google Login
                        @endif
                        @if ($user->google_login_email)
                            <div class="mb-2"><a
                                    href="{{ route('admin.users.view.dashboard', $user) }}">{{ $user->google_login_email }}</a>
                            </div>
                        @endif
                        @if ($user->is_facebook_log_in_enabled)
                            Facebook Login
                        @endif
                        @if ($user->facebook_login_email)
                            <div class="mb-2"><a
                                    href="{{ route('admin.users.view.dashboard', $user) }}">{{ $user->facebook_login_email }}</a>
                            </div>
                        @endif
                        @if ($user->mailing_address_phone_number)
                            <div class="mb-2"><a href="tel:{{ $user->mailing_address_phone_number }}">Mailing Phone
                                    #: <br> <span class="phone">{{ $user->mailing_address_phone_number }}</span></a>
                            </div>
                        @endif
                        <p>Created: {{ friendly_date_time($user->created_at) }}</p>
                        <p>ID: {{ $user->id }}</p>
                    </td>
                    <td>
                        @foreach ($user->paymentMethods as $paymentMethod)
                            <div>

                                <?= $paymentMethod->displayName() ?>
                                <p>{{ friendly_date_time($paymentMethod->created_at) }}</p>


                                @if ($user->defaultPaymentMethod && $user->defaultPaymentMethod->uid == $paymentMethod->uid)
                                    (default)
                                @endif
                                @if ($paymentMethod->is_removed)
                                    (removed)
                                @endif
                            </div>
                            <hr />
                        @endforeach
                    </td>
                    <td>
                        <table class="table table-sm table-striped table-bordered">
                            <tr>
                                <th class="text-nowrap fw-bold">Order ID</th>
                                <th class="text-nowrap fw-bold">Order Total</th>
                                <th class="text-nowrap fw-bold">Created At</th>
                                <th class="text-nowrap fw-bold">Created By</th>
                            </tr>
                            @foreach ($user->storeOrdersAsClient as $storeOrder)
                                <tr @if ($storeOrder->is_cancelled) class="cancelled-order" @endif>
                                    <td class="text-nowrap"><a href="{{ route('admin.orders.view.dashboard', $storeOrder) }}">{{ $storeOrder->orderNumber() }}</a></td>
                                    <td class="text-nowrap">{{ displayAmount('$', $storeOrder->total()) }}</td>
                                    <td class="text-nowrap">{{ friendly_date_time($storeOrder->created_at) }}</td>
                                    <td class="text-nowrap">{{ $storeOrder->createdByUser->displayName() }}</td>
                                </tr>
                            @endforeach
                        </table>
                    </td>                    
                </tr>
            @endforeach
        </tbody>
    </table>
</div>
