@extends('layouts.master')

@section('title', __('My Wallets'))

@push('styles')
@endpush

@section("content")
    <div id="featured-services" class="featured-services main_section">
        <div class="row">
            <div class="col-12 col-md-6 col-lg-6 col-sm-12">
                <div class="card mb-4">
                    <div class="card-body">
                        <div class="d-flex justify-content-between align-items-center w-100">
                            <div class="card-title text-center">
                                <h3 class="p-0 m-0 text-center">{{ optional($ocaWallet->first()->wallet_list)->name ?? '' }}</h3>
                            </div>
                            <div class="card-title text-center">
                                <p class="mb-1 fs-6">{{__('Main Balance')}}</p>
                                <b>{{ formatDisplayNumber($ocaWallet->sum('balance') ?? 0) }} €</b>
                            </div>
                            <div class="card-title text-center">
                                <p class="mb-1 fs-6">{{__('Block Balance')}}</p>
                                <b>{{ formatDisplayNumber($withdrawalAmount ?? 0) }} €</b>
                            </div>
                            <div class="card-title text-center">
                                <p class="mb-1 fs-6">{{__('Current Balance')}}</p>
                                <b>{{ formatDisplayNumber(($ocaWallet->sum('balance') ?? 0) -  ($withdrawalAmount ?? 0)) }} €</b>
                            </div>
                        </div>
                        <hr class="border border-dark border-1 mt-0">
                        <div class="row">
                            @if (!in_array((Auth::user()->userAddress[0]->country_id ?? ''),(json_decode(getSiteSettings('transfer_restricted_countries'),true) ?? [])))
                            <div class="col-lg-6 col-md-12 mb-4">
                                <?php
                                $SendFundsBtnUrl = url('member/dashboard?send-funds=yes');
                                $SendFundsBtnDisabledTitle='';
                                if (!in_array('transfer', Auth::user()->setting->fa_setting ?? []) && !in_array('transfer', Auth::user()->setting->fa3_setting ?? [])){
                                    $SendFundsBtnUrl = '';
                                    $SendFundsBtnDisabledTitle = __('Enable 2FA authenticator to send funds.');
                                }
                                if ((($ocaWallet->sum('balance') ?? 0) -  ($withdrawalAmount ?? 0)) <= 0){
                                    $SendFundsBtnUrl = '';
                                    $SendFundsBtnDisabledTitle = __('OCA wallet current balance is 0.');
                                }
                                ?>
                                <a @if(!empty($SendFundsBtnUrl)) href="{{ $SendFundsBtnUrl }}" @else href="javascript:void(0)" style="opacity: 0.8;" @endif>
                                    <div class="p-4 rounded d-flex align-items-center bg-primary text-white justify-content-between">
                                        <div class="d-flex align-items-center">
                                            <i class="bi bi-cash text-32 me-3"></i>
                                            <h4 class="text-18 mb-1 text-white">{{ __('Send Funds') }}</h4>
                                        </div>
                                        @if(isset($SendFundsBtnDisabledTitle) && !empty($SendFundsBtnDisabledTitle))
                                        <i class="bi bi-info-circle fs-5" data-html="true" data-toggle="tooltip" data-placement="top" title="{{ $SendFundsBtnDisabledTitle }}"></i>
                                        @endif
                                    </div>
                                </a>
                            </div>
                            @endif
                            <div class="col-lg-6 col-md-12 mb-4">
                                <a href="{{ url('member/deposit/create') }}">
                                    <div class="p-4 rounded d-flex align-items-center bg-primary text-white">
                                        <i class="bi bi-wallet2 text-32 me-3"></i>
                                        <div>
                                            <h4 class="text-18 mb-1 text-white">{{ __('Deposit') }}</h4>
                                        </div>
                                    </div>
                                </a>
                            </div>
                            <div class="col-lg-6 col-md-12 mb-4">
                                <a href="{{ url('member/withdrawal/create') }}">
                                    <div class="p-4 rounded d-flex align-items-center bg-primary text-white">
                                        <i class="bi bi-wallet text-32 me-3"></i>
                                        <div>
                                            <h4 class="text-18 mb-1 text-white">{{ __('Withdraw') }}</h4>
                                        </div>
                                    </div>
                                </a>
                            </div>
                            <div class="col-lg-6 col-md-12 mb-4">
                                <a href="{{ url('member/transactions?list=').(optional($ocaWallet->first()->wallet_list)->id ?? '') }}">
                                    <div class="p-4 rounded d-flex align-items-center bg-primary text-white">
                                        <i class="bi bi-card-text text-32 me-3"></i>
                                        <div>
                                            <h4 class="text-18 mb-1 text-white">{{ __('History') }}</h4>
                                        </div>
                                    </div>
                                </a>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-12 col-md-6 col-lg-6 col-sm-12">
                <div class="card mb-4">
                    <div class="card-body">
                        <div class="d-flex justify-content-between align-items-center w-100">
                            <div class="card-title text-center">
                                <h3 class="p-0 m-0 text-center">{{ optional($bonusWallet->first()->wallet_list)->name ?? '' }}</h3>
                            </div>
                            <div class="card-title text-center">
                                <p class="mb-1 fs-6">{{ __('Current Balance')}}</p>
                                <b>{{ formatDisplayNumber($bonusWallet->sum('balance') ?? 0) }} €</b>
                            </div>
                        </div>
                        <hr class="border border-dark border-1 mt-0">

                        <div class="row">
                            <div class="col-lg-6 col-md-12 mb-4">
                                <a href="{{ url('member/shop') }}">
                                    <div class="p-4 rounded d-flex align-items-center bg-primary text-white">
                                        <i class="bi bi-cart-check text-32 me-3"></i>
                                        <div>
                                            <h4 class="text-18 mb-1 text-white">{{ __('Buy Products') }}</h4>
                                        </div>
                                    </div>
                                </a>
                            </div>
                            <div class="col-lg-6 col-md-12 mb-4">
                                <a href="{{ url('member/transactions?list=').(optional($bonusWallet->first()->wallet_list)->id ?? '') }}">
                                    <div class="p-4 rounded d-flex align-items-center bg-primary text-white">
                                        <i class="bi bi-card-text text-32 me-3"></i>
                                        <div>
                                            <h4 class="text-18 mb-1 text-white">{{ __('History') }}</h4>
                                        </div>
                                    </div>
                                </a>
                            </div>
                            <div class="col-lg-7 col-md-12 mx-auto mb-4">
                                <?php
                                $purchasePoolBtnUrl = url('/member/bonus-purchase-pool');
                                $purchasePoolBtnDisabledTitle='';
                                if (!in_array('bonus_purchase_pool', Auth::user()->setting->fa_setting ?? []) && !in_array('bonus_purchase_pool', Auth::user()->setting->fa3_setting ?? [])){
                                    $purchasePoolBtnUrl = '';
                                    $purchasePoolBtnDisabledTitle = __('Enable 2FA authenticator to send funds.');
                                }
                                if (Auth::user()->member->kyc_status != 'active'){
                                    $purchasePoolBtnUrl = '';
                                    $purchasePoolBtnDisabledTitle = __('Please complete your KYC/KYB to enable bonus purchase pool.');
                                }
                                if ((($ocaWallet->sum('balance') ?? 0) -  ($withdrawalAmount ?? 0)) <= 0){
                                    $purchasePoolBtnUrl = '';
                                    $purchasePoolBtnDisabledTitle = __('OCA wallet current balance is 0.');
                                }
                                ?>
                                <a @if(!empty($purchasePoolBtnUrl)) href="{{ $purchasePoolBtnUrl }}" @else href="javascript:void(0)" style="opacity: 0.8;" @endif>
                                    <div class="p-4 rounded d-flex align-items-center bg-primary text-white justify-content-between">
                                        <div class="d-flex align-items-center">
                                            <i class="bi bi-basket text-32 me-3"></i>
                                            <h4 class="text-18 mb-1 text-white">{{ __('Bonus Purchase Pool Application') }}</h4>
                                        </div>
                                        @if(isset($purchasePoolBtnDisabledTitle) && !empty($purchasePoolBtnDisabledTitle))
                                            <i class="bi bi-info-circle fs-5 ml-2" data-html="true" data-toggle="tooltip" data-placement="top" title="{{ $purchasePoolBtnDisabledTitle }}"></i>
                                        @endif
                                    </div>
                                </a>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

@endsection


@push('scripts')
@endpush

