@extends('backoffice.layouts.app')
@section('contents')
    <div class="container-fluid mt-4">
        <h4 class="mb-4">User Profiles</h4>
        @if (session('success'))
            <div class="alert alert-success">{{ session('success') }}</div>
        @endif
        <div class="table-responsive">
            <table class="table table-bordered table-striped">
                <thead class="table-dark">
                    <tr>
                        <th>Photo</th>
                        <th>Real Name</th>
                        <th>Nickname</th>
                        <th>Phone</th>
                        <th>Country</th>
                        <th>Status</th>
                        <th>Action</th>
                    </tr>
                </thead>
                <tbody>
                    @foreach ($profiles as $profile)
                        <tr>
                            <td>
                                @if ($profile->profile_photo)
                                    <img src="{{ asset('website/uploads/profile_images/' . $profile->profile_photo) }}"
                                        alt="Profile Photo" class="img-thumbnail"
                                        style="width: 60px; height: 60px; object-fit: cover;">
                                @else
                                    <span class="text-muted">Not Set</span>
                                @endif
                            </td>
                            <td>{{ $profile->real_name }}</td>
                            <td>{{ $profile->nickname }}</td>
                            <td>{{ $profile->phone_country_code }} {{ $profile->phone_number }}</td>
                            <td>{{ $profile->country }}</td>
                            <td>
                                @if ($profile->verification_status === 'verified')
                                    <span class="badge bg-success">Verified</span>
                                @else
                                    <span class="badge bg-warning text-dark">Unverified</span>
                                @endif
                            </td>
                            <td>
                                @if ($profile->verification_status === 'unverified')
                                    <form method="POST" action="{{ route('admin.verify.profile', $profile->id) }}">
                                        @csrf
                                        @method('PATCH')
                                        <button type="submit" class="btn btn-sm btn-success">Verify</button>
                                    </form>
                                @else
                                    <button class="btn btn-sm btn-secondary" disabled>Verified</button>
                                @endif
                            </td>
                        </tr>
                    @endforeach
                </tbody>
            </table>
        </div>
    </div>
@endsection

@section('scripts')
@endsection
