@extends($activeTemplate.'layouts.master')
@section('content')

   
       
                



<body class="page-bg">
<div class="navbar">
    <a href="{{route ('user.home')}}" class="navbar-left">
        <i class="icon iconfont icon-angleleft"></i>
    </a>
    <div class="navbar-title">Recharge</div>
    <a href="{{route ('user.deposit.history')}}" class="navbar-right">record</a>
</div>
<div class="information-navbar navbar-head">
    <div class="recharge-con">
        <div class="balance-total">
            <div class="balance-info">
                            <span>
                   {{ showAmount(auth()->user()->deposit_wallet) }} {{ $general->cur_text }}
                    <font></font>
                </span>
                <span>Recharged Balance</span>
            </div>
            <dl>
                <dd>
       
                    
                    <span><span class="min fw-bold">0</span>{{__($general->cur_text)}}</span>
                    <span>Minmum Recharge</span>
                </dd>
                <dd>
                    <span><span class="max fw-bold">0</span>{{__($general->cur_text)}}</span>
                    <span>Maxmium Recharge</span>
                </dd>
            </dl>
        </div>
             <form action="{{route('user.deposit.insert')}}" method="post">
                @csrf
                <input type="hidden" name="method_code">
                <input type="hidden" name="currency">
        
        
        <div class="inline-tab">
            <a href="" class="on">All In One Banks </a>
            >
        </div>
        <div class="recharge-info">
            <div class="recharge-tit">Recharge Amount</div>
            <div class="recharge-amount">
    
                
                <input type="number" step="any"  placeholder="please enter recharge amount..."     name="amount"  value="{{ old('amount') }}" autocomplete="off" required>
                
                
                
                <span>{{__($general->cur_text)}}</span>
            </div>
            <div class="space-10"></div>
            <div class="recharge-tit">Recharge Method</div>
                  <div class="recharge-amount">
                      
                      
                      
                               <select  style="width: 100%; height: 50px;" class="login-input-input"    name="gateway" required>
                                        <option value="">@lang('Select One')</option>
                                        @foreach($gatewayCurrency as $data)
                                        <option value="{{$data->method_code}}" @selected(old('gateway') == $data->method_code) data-gateway="{{ $data }}">{{$data->name}}</option>
                                        @endforeach
                                    </select>
        
                <span></span>
            </div>
        </div>
        </div>
        <div class="space-14"></div>
        <div class="recharge-btn">
            <button type="submit">Recharge</button>
        
        </div>
      
        <div class="space-1500"></div>
        <div class="information-text">
            
            
                    </div>
    </div>
</div>

    <h1>‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ </h1>


<div class="hide recharging"></div>

</body>
</html>
                
                
                
           
        

@endsection

@push('script')
    <script>
        (function ($) {
            "use strict";
            $('select[name=gateway]').change(function(){
                if(!$('select[name=gateway]').val()){
                    $('.preview-details').addClass('d-none');
                    return false;
                }
                var resource = $('select[name=gateway] option:selected').data('gateway');
                var fixed_charge = parseFloat(resource.fixed_charge);
                var percent_charge = parseFloat(resource.percent_charge);
                var rate = parseFloat(resource.rate)
                if(resource.method.crypto == 1){
                    var toFixedDigit = 8;
                    $('.crypto_currency').removeClass('d-none');
                }else{
                    var toFixedDigit = 2;
                    $('.crypto_currency').addClass('d-none');
                }
                $('.min').text(parseFloat(resource.min_amount).toFixed(2));
                $('.max').text(parseFloat(resource.max_amount).toFixed(2));
                var amount = parseFloat($('input[name=amount]').val());
                if (!amount) {
                    amount = 0;
                }
                if(amount <= 0){
                    $('.preview-details').addClass('d-none');
                    return false;
                }
                $('.preview-details').removeClass('d-none');
                var charge = parseFloat(fixed_charge + (amount * percent_charge / 100)).toFixed(2);
                $('.charge').text(charge);
                var payable = parseFloat((parseFloat(amount) + parseFloat(charge))).toFixed(2);
                $('.payable').text(payable);
                var final_amo = (parseFloat((parseFloat(amount) + parseFloat(charge)))*rate).toFixed(toFixedDigit);
                $('.final_amo').text(final_amo);
                if (resource.currency != '{{ $general->cur_text }}') {
                    var rateElement = `<span class="fw-bold">@lang('Conversion Rate')</span> <span><span  class="fw-bold">1 {{__($general->cur_text)}} = <span class="rate">${rate}</span>  <span class="method_currency">${resource.currency}</span></span></span>`;
                    $('.rate-element').html(rateElement)
                    $('.rate-element').removeClass('d-none');
                    $('.in-site-cur').removeClass('d-none');
                    $('.rate-element').addClass('d-flex');
                    $('.in-site-cur').addClass('d-flex');
                }else{
                    $('.rate-element').html('')
                    $('.rate-element').addClass('d-none');
                    $('.in-site-cur').addClass('d-none');
                    $('.rate-element').removeClass('d-flex');
                    $('.in-site-cur').removeClass('d-flex');
                }
                $('.method_currency').text(resource.currency);
                $('input[name=currency]').val(resource.currency);
                $('input[name=method_code]').val(resource.method_code);
                $('input[name=amount]').on('input');
            });
            $('input[name=amount]').on('input',function(){
                $('select[name=gateway]').change();
                $('.amount').text(parseFloat($(this).val()).toFixed(2));
            });
        })(jQuery);
    </script>
@endpush
