@extends($activeTemplate . 'layouts.master')
@section('content')
    @php
        $kycInfo = getContent('kyc_info.content', true);
    @endphp
    <div class="dashboard-section padding-top padding-bottom">
        <div class="container">

            @if (auth()->user()->dummy_person)
                <div class="alert alert-danger text-center" role="alert">

                    <h3 class="alert-heading">
                        <i class="las la-exclamation-circle"></i>@lang('This is a company generated user. Do not do any activity here')
                    </h3>
                </div>
            @endif

            <h2 class="text-center text-decoration-underline" style="margin-bottom: 5rem">Welcome <span class="text--success">
                    {{ $user->fullname }}</span></h2>

            <div class="row">
                <div class="col-12 @if($notice->status == Status::ENABLE) col-lg-6 @endif">
                    @if (auth()->user()->kv == 0)
                        <div class="alert alert-info" role="alert">
                            <h5 class="alert-heading">@lang('KYC Verification required')</h5>
                            <hr>
                            <p class="mb-0">{{ __($kycInfo->data_values->verification_content) }} <a
                                    href="{{ route('user.kyc.form') }}">@lang('Click Here to Verify')</a></p>
                        </div>
                    @elseif(auth()->user()->kv == 2)
                        <div class="alert alert-warning" role="alert">
                            <h5 class="alert-heading">@lang('KYC Verification pending')</h5>
                            <hr>
                            <p class="mb-0">{{ __($kycInfo->data_values->pending_content) }} <a
                                    href="{{ route('user.kyc.data') }}">@lang('See KYC Data')</a></p>
                        </div>
                    @endif

                    <div class="table-responsive">
                        <table class="table table-striped table-bordered">
                            <thead class="d-none">
                                <th>@lang('Key')</th>
                                <th>@lang('Value')</th>
                            </thead>
                            <tbody>
                                <tr>
                                    <th>@lang('User Id')</th>
                                    <td><span
                                            style="color: orange; font-weight: 600">{{ substr($user->system_id, 0, 2) }}</span>{{ substr($user->system_id, 2) }}
                                    </td>
                                </tr>
                                <tr>
                                    <th>@lang('Username')</th>
                                    <td><span>{{ $user->username }}</span></td>
                                </tr>
                                <tr>
                                    <th>@lang('Mobile')</th>
                                    <td>+{{ $user->mobile }}</td>
                                </tr>
                                <tr>
                                    <th>@lang('Email')</th>
                                    <td>{{ $user->email }}</td>
                                </tr>
                                <tr>
                                    <th>@lang('Date Of Activation')</th>
                                    <td>{{ $user->created_at->format('d M Y') }}</td>
                                </tr>
                            </tbody>
                        </table>
                    </div>

                    @if ($user->network_status == Status::NetworkFullActivated)
                        <div class="row">
                            <div class="col-md-12">
                                <div class="input-group contact-form-group">
                                    <input type="text" name="key"
                                        value="{{ route('home') }}?reference={{ $username }}"
                                        class="form-control referralURL referral-input" readonly>
                                    <button type="button"
                                        class="input-group-text copytext bg--base border--base text-white" id="copyBoard">
                                        <i class="fa fa-copy"></i> </button>
                                </div>
                            </div>
                        </div>
                    @endif
                </div>
                @if ($notice->status == Status::ENABLE)
                    <div class="col-12 col-lg-6">
                        @include($activeTemplate . 'partials.dashboard.notice-board')
                    </div>
                @endif
            </div>

            <section class="mb-30 mt-5" id="dashboard-cards">
                <div class="row justify-content-center ">
                    <div class="col-md-6 col-lg-4">
                        <div class="dashboard-item">
                            <div class="dashboard-thumb">
                                <i class="fas fa-users"></i>
                            </div>
                            <div class="dashboard-content">
                                <h5 class="title">@lang('Network Size')</h5>
                                <h4 class="amount">{{ $user->network_size ?? 0 }}</h4>
                                {{-- <h4 class="amount">{{ $general->cur_sym }}{{ showAmount($balance) }}</h4> --}}
                            </div>
                        </div>
                    </div>
                    <div class="col-md-6 col-lg-4">
                        <div class="dashboard-item">
                            <div class="dashboard-thumb">
                                <i class="fas fa-users"></i>
                            </div>
                            <div class="dashboard-content">
                                <h5 class="title">@lang('Active Member')</h5>
                                <h4 class="amount">{{ $user->active_network_size ?? 0 }}</h4>
                                {{-- <h4 class="amount">{{ $general->cur_sym }}{{ showAmount($balance) }}</h4> --}}
                            </div>
                        </div>
                    </div>
                    <div class="col-md-6 col-lg-4">
                        <div class="dashboard-item">
                            <div class="dashboard-thumb">
                                <i class="fas fa-money-bill"></i>
                            </div>
                            <div class="dashboard-content">
                                <h5 class="title">@lang('Given Donation')</h5>
                                <h4 class="amount">{{ $general->cur_sym }} {{ $paidDonation }}</h4>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-6 col-lg-4">
                        <div class="dashboard-item">
                            <div class="dashboard-thumb">
                                <i class="fas fa-money-bill"></i>
                            </div>
                            <div class="dashboard-content">
                                <h5 class="title">@lang('Received Donation')</h5>
                                <h4 class="amount">{{ $general->cur_sym }} {{ $receivedDonation }}</h4>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-6 col-lg-4">
                        <div class="dashboard-item">
                            <div class="dashboard-thumb">
                                <i class="fas fa-money-bill"></i>
                            </div>
                            <div class="dashboard-content">
                                <h5 class="title">@lang('Reward Income')</h5>
                                <h4 class="amount">{{ $general->cur_sym }}{{ round($totalReward) }}</h4>
                                {{-- <h4 class="amount">{{ $general->cur_sym }}{{ showAmount($balance) }}</h4> --}}
                            </div>
                        </div>
                    </div>
                    <div class="col-md-6 col-lg-4">
                        <div class="dashboard-item">
                            <div class="dashboard-thumb">
                                <i class="fas fa-toggle-on"></i>
                            </div>
                            <div class="dashboard-content">
                                <h5 class="title">@lang('Status')</h5>
                                @if ($user->network_status == Status::NetworkFullActivated)
                                    <h4 class="amount">Active</h4>
                                @elseif($user->network_status == Status::NetworkPlanPurchased)
                                    <h4 class="amount">Partially Active</h4>
                                @else
                                    <h4 class="amount">Inactive</h4>
                                @endif
                                {{-- <h4 class="amount">{{ $general->cur_sym }}{{ showAmount($balance) }}</h4> --}}
                            </div>
                        </div>
                    </div>
                    <div class="col-md-6 col-lg-4">
                        <div class="dashboard-item">
                            <div class="dashboard-thumb">
                                <i class="far fa-star"></i>
                            </div>
                            <div class="dashboard-content">
                                <h5 class="title">@lang('Rank')</h5>
                                <h4 class="amount">
                                    {{ $user->rank }}</h4>
                            </div>
                        </div>
                    </div>
                </div>
            </section>

            @include($activeTemplate . 'partials.dashboard.product')
            {{-- @include($activeTemplate . 'partials.dashboard.donations') --}}
            @if (in_array($user->network_status, [Status::NetworkFullActivated, Status::NetworkPlanPurchased]))
                @include($activeTemplate . 'partials.dashboard.donations-2')
                @include($activeTemplate . 'partials.dashboard.reward')
            @endif
        </div>

    </div>
@endsection

@push('script')
    <script>
        $(document).on('click', '.deleteConfirmationBtn', function() {
            var modal = $('#deleteConfirmationModal');
            var action = $(this).data('action');
            // console.log({action})
            var userId = $(this).data('userid');
            console.log($(this).data('userid'));
            modal.find('input[name="id"]').val($(this).data('id'));
            modal.find('input[name="receiver_user_id"]').val($(this).data('userid'));
            modal.find('form').attr('action', $(this).data('action'));
        });
    </script>
    <script>
        (function($) {
            "use strict";
            $('#copyBoard').click(function() {
                var copyText = document.getElementsByClassName("referralURL");
                copyText = copyText[0];
                copyText.select();
                copyText.setSelectionRange(0, 99999);
                /*For mobile devices*/
                document.execCommand("copy");
                copyText.blur();
                this.classList.add('copied');
                setTimeout(() => this.classList.remove('copied'), 1500);
            });
        })(jQuery);
    </script>


    <script>
        function copyToClipboard(elementId) {
            var textToCopy = document.getElementById(elementId).textContent.trim();
            var input = document.createElement("input");
            input.setAttribute('value', textToCopy);
            document.body.appendChild(input);
            input.select();
            document.execCommand("copy");
            document.body.removeChild(input);
            notify('success', 'UPI ID copied to clipboard');
        }
    </script>


    <script>
        $(document).ready(function() {
            $('#uploadBtn').click(function() {
                $('#verifyModal').modal('show');
            });

            $('.uploadScreenshotModalBtn').click(function() {
                var modal = $('#uploadScreenshotModal');
                console.log($(this).data('userid'))
                modal.find('input[name="receiver_user_id"]').val($(this).data('userid'));
                modal.find('form').attr('action', $(this).data('action'));

                modal.modal('show');
            });

            $('.showDetailsModalBtn').click(function() {
                var modal = $('#showDetailsModal');
                var payment = $(this).data('payment');
                var img = payment.screen_short;
                var utr_no = payment.utr_no;
                modal.find('.modal-body img').attr('src', img);
                modal.find('.modal-body #utr_no').text(utr_no);
                modal.find('.modal-body #payment_mode').text(payment.payment_mode);

                modal.modal('show');
            });
        });
    </script>
@endpush

@push('style')
    <style>
        .copied::after {
            background-color: #{{ $general->base_color }};
        }
    </style>
@endpush
