@extends($activeTemplate.'layouts.users')

@section('content')

<body>
    <div class="top">
        <div class="topTit">{{ $pageTitle }}</div>
    </div>
    <div class="team-main">
        <div class="team-main-top">
            <div class="team-main-top-img">
                <div class="team-main-top-link">
                    <div class="team-main-top-title">Invitation code</div>
                    <div class="team-main-top-ipt">
                        {{--  <div class="team-code-img">
                            <img src="https://files.ukbensonfarm.com/20231223/703d326a68a11c5faa5d3ddffa97919b.png" alt>
                        </div>  --}}
                        <input style="opacity:0;" type="text"
                            value="{{ route('home') }}?code={{ auth()->user()->ref_code }}" id="referralLink">
                        <div class="team-main-top-ipt"
                            data-clipboard-text="{{ route('home') }}?code={{ auth()->user()->ref_code }}">
                            <div class="team-code-input" style=" color: #9e9aa8">
                                {{ route('home') }}?code={{ auth()->user()->ref_code }}</div>
                            <button style="border: none;" onclick="copyToClipboard()" class="copy">Copy</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="team-inner">

            <div class="inline-tab team-tab">
                <a href="{{ route('user.referrals.lv1') }}">Team 1 <i></i></a>
                <a href="{{ route('user.referrals.lv2') }}">Team 2 <i></i></a>
                <a href="{{ route('user.referrals.lv3') }}">Team 3 <i></i></a>
            </div>
            {{--  <div class="team-inner-profit">
                <ul>
                    <li>
                        <h5>{{ $referrals->count() }}</h5>
                        <p>Total Member</p>
                    </li>
                    <li>
                        <h5>
                            {{ $level1_bonus }}
                            <small>NGN</small>
                        </h5>
                        <p>Team Income</p>
                    </li>
                    <li>
                        <h5>{{ $bonus_per }}%</h5>
                        <p>Team Profit</p>
                    </li>
                </ul>
            </div>  --}}
            <div class="team-inner-table">
                <div class="team-inner-table-hd">
                    <div class="team-inner-table-bd">
                        <span>Account</span>
                        <span>Created at</span>
                    </div>
                </div>
                @forelse($referrals as $user)
                    <div class="team-inner-table-bd">
                        <span>{{$user->mobile}}</span>
                        <span>{{ $user->created_at }}</span>
                    </div>
                @empty
                    <tr>
                        <td colspan="100%"> @lang('No results found')!</td>
                    </tr>
                @endforelse
            </div>
        </div>
    </div>
    <script type="text/javascript">
        function copyToClipboard() {
            // Select the text field
            var referralLink = document.getElementById("referralLink");
            referralLink.select();
            referralLink.setSelectionRange(0, 99999); // For mobile devices

            // Copy the text inside the text field
            document.execCommand("copy");

            // Alert the copied text
            alert("Referral link copied to clipboard: " + referralLink.value);
        }
    </script>
</body>

@endsection




