<?php $user = auth()->user(); ?>
@extends($activeTemplate.'layouts.home')

@push('style')
<link rel="stylesheet" href="{{ asset('users/jasper/css/details.css') }}{{$catch}}" >
<link rel="stylesheet" href="{{ asset('users/jasper/css/recharge.css') }}{{$catch}}" >
<style>.rgkf[data-v-98c026]{display:block !important; }</style>
@endpush


@php
    $buyLimit = (config('settings')->buy_limit && $plan->escape_buy_limit != 1) ? config('settings')->buy_limit :$plan->buy_limit;
    $limiBuy = (config('settings')->buy_limit && $plan->escape_buy_limit != 1) ? config('settings')->limit_buy : $plan->limit_buy;
    
    $statusLink = 0;
    if($plan['p_status'] == 'coming') {
		$statusClass = 'bg-secondary';
		$statusName = 'UPCOMING';
    }elseif($boughtCount >= $limiBuy && $buyLimit || $plan['p_status'] == 'solid_out' || $plan['purchased'] >= $plan['all_limit_buy']) {
		$statusClass = 'bg-danger';
		$statusName = ($plan['p_status'] == 'trial') ? 'Activate' : 'SOLD OUT';
    }else {
		$statusClass = 'bg-primary-blue';
		$statusName = ($plan['p_status'] == 'trial') ? 'Activate' : 'BUY NOW';
		$statusLink = 1;
    }
@endphp

@section('content')
<div class="wrapper">
<div data-v-af01384a="">
	<div id="home" data-v-c35495fc="" data-v-af01384a="" style="background:#f3f4f6;border-radius:0 0 8px 8px">
		<div class="bg" data-v-c35495fc="" style="height:18vmin"></div>
		<div class="main" data-v-c35495fc="">
			<div class="titleBar" data-v-c35495fc="">
				<div class="left" data-v-c35495fc="">
					<a data-href="{{ route('user.investment')}}" data-v-c35495fc="" class="linkBTN text-white"><img class="van-badge__wrapper van-icon van-icon-arrow-left van-nav-bar__arrow" src="{{ asset('users/assets/trade/img/arrow-left-thin.svg') }}" style="width:38px" ></a>
				</div>
				<div class="right" data-v-c35495fc="" style="margin-top: -15px;margin-right: -.75rem;">
					<a data-href="{{ route('user.profile')}}" class="linkBTN right" data-v-c35495fc="" style=""><img src="{{getImage(imagePath()['logoIcon']['path'] .'/logo.png')}}{{$catch}}" alt="" data-v-c35495fc="" style="height:36px;height: 37px; border-radius:5px 0 0px 5px;width: auto;" /></a>
				</div>
			</div>
			<div data-v-af01384a="">
				<div id="team" data-v-c6f9d966="" data-v-af01384a="" class="">
					<div class="containerh" data-v-c6f9d966="">
						<div class="part2" data-v-385ac480="" data-v-c6f9d966="" style="margin-left:0px;margin-right: 4px;">
							<div class="top_lv_VIEw" data-v-385ac480=""><i class="left_icon" data-v-385ac480=""></i><span data-v-385ac480="">{{ $plan->name }} product</span></div>
							<div class="m" data-v-385ac480="" style="background: #FFF;margin-bottom: -10px;">
								<div class="item" data-v-385ac480=""><span data-v-385ac480="">Deposit balance</span><span data-v-385ac480="">{{ config('settings')->cur_sym }}{{ getAmount($user->balance) }}</span></div>
								<div href="" class="item rightItme" data-v-385ac480=""><span data-v-385ac480="">Earning balance</span><span data-v-385ac480="">{{ config('settings')->cur_sym }}{{ getAmount($user->income) }}</span></div>
							</div>
						</div>
					</div>
				</div>
			</div>

			
            <div class="flex flex-col flex-1 relative">
                <div class="py-1 flex items-center justify-center flex-shrink-0"><img src="{{ asset('assets/'.$plan->img) }}" alt="{{ $plan->name }}" width="100%" style="border-radius:8px;"></div>
				
                <div class="flex flex-shrink-0 w-full mb-8">
                    <div class="flex flex-col pr-4 flex-1" style="align-items: flex-start;"><span class="font-display text-lg font-bold">{{ strtoupper( $plan->name )}}</span><span style="padding:2px 10px;" class="rounded-t font-body text-white badge bg-primary">{{ $plan->identifier }}</span></div>
                    <div class="flex flex-col text-right"><span class="font-display text-lg font-bold text-green-600">{{ $plan->cur_sym }}{{ showAmount($plan->min_amount) }}</span><span class="font-body text-gray-600 font-bold fkqYfq"> / Per Minimum buy</span></div>
				</div>

				<div class="my-4 pt-4">
					@if($statusLink)
					<a id="btn-pay" class="sc-kjoXOD fcoOgC text-center whitespace-no-wrap rounded-t rounded-br w-full justify-center pt-4 py-3 px-10 font-display uppercase font-bold text-white">BUY PRODUCT</a>
					@else 
					<a class="sc-kjoXOD fcoOgC text-center whitespace-no-wrap rounded-t rounded-br w-full justify-center pt-4 py-3 px-10 font-display uppercase font-bold text-white" style="background: red;">{{$statusName}}</a>
					@endif
				</div>

				<div class="flex flex-col flex-shrink-0 items-center">
					<span class="font-body text-gray-600 text-center mb-2">{!! $plan->summary !!}</span>
				</div>

                <!--div class="flex flex-shrink-0 w-full py-1 mb-8 pb-6 border-b">
					<span><span style="padding:2px 10px;" class="rounded-t font-body text-white badge bg-secondary">{{ config('settings')->cur_sym }}{{showAmount($plan->capital,2)}}</span><br/>Market Cap</span>
					@if( 0 > @$plan->growth )
					<span><span class="rounded-t font-body text-white badge bg-warning text-small danger text-warning" style="display:inline-flex"><svg class="danger dark:text-white" height="20px" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 19V5m0 14-4-4m4 4 4-4"></path></svg> {{ @$plan->growth }}%</span><br/>growth</span>
					@else
					<span><span class="rounded-t font-body text-white badge bg-success text-small text-white" style="display:inline-flex"><svg class="text-blue-200 dark:text-white" height="20px" style="margin-top: 1px;" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6v13m0-13 4 4m-4-4-4 4"/></svg> {{ @$plan->growth}}%</span><br/>growth</span>
					@endif
				</div-->
			
				<div class="mb-8 flex flex-shrink-0" style="width:96%;min-height: 76px;">
					<ul class="flex w-full flex-wrap justify-between">
						<li class="" ><button type="button" class="btnClick flex flex-col items-center text-center mb-4" data-action="Follow()"><div class="w-8 h-8 rounded-t rounded-br flex items-center justify-center mb-1 relative" style="background-color: rgb(214, 188, 250);"><svg class="w-6 h-6 text-white" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 12h4m-2 2v-4M4 18v-1a3 3 0 0 1 3-3h4a3 3 0 0 1 3 3v1c0 .6-.4 1-1 1H5a1 1 0 0 1-1-1Zm8-10a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z"></path></svg></div><span class="font-body font-semibold">Follow</span></button></li>
						<li class="" ><button type="button" class="btnClick flex flex-col items-center text-center mb-4" data-action="Bookmark()"><div class="w-8 h-8 rounded-t rounded-br flex items-center justify-center mb-1 relative" style="background-color: rgb(214, 188, 250);"><svg class="w-6 h-6 text-white" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m17 21-5-4-5 4V3.9c0-.2 0-.5.2-.6l.6-.3h8.4c.2 0 .4 0 .6.3l.2.6V21Z"></path></svg></div><span class="font-body font-semibold">Bookmark</span></button></li>
						<li class="" >
							<a class="share_link flex flex-col items-center text-center mb-4" data-image="https://equityedge.pro/assets/images/shares/65dd7294916f01709011604.jpg" data-more="Visit this page now to get complete details on Custom made shoes shares @https://equityedge.pro/investable-shares/view/MIN65dd729490dc7" data-ajax="0" data-ajaxurl="https://equityedge.pro/investable-shares/view/MIN65dd729490dc7" data-title="Custom made shoes" data-link="https://equityedge.pro/investable-shares/view/MIN65dd729490dc7">
								<div class="w-8 h-8 rounded-t rounded-br flex items-center justify-center mb-1 relative" style="background-color: rgb(214, 188, 250);"><svg class="w-6 h-6 text-white" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="m8 10.9 7-3.2m-7 5.4 7 3.2M8 12a2.5 2.5 0 1 1-5 0 2.5 2.5 0 0 1 5 0Zm12 5.5a2.5 2.5 0 1 1-5 0 2.5 2.5 0 0 1 5 0Zm0-11a2.5 2.5 0 1 1-5 0 2.5 2.5 0 0 1 5 0Z"></path></svg></div>
								<span class="font-body font-semibold">Share</span>
							</a>
						</li>
					</ul>
				</div>
				<input type="hidden" id="coupon" value="">
				<input type="hidden" id="pay_with" value="{{ $plan->cur_text }}">
			
				<div class="flex flex-wrap justify-between flex-shrink-0 mb-4 w-full">
					<div class="flex flex-shrink-0 items-center rounded-t rounded-br border w-1/2-2 p-2 mb-4">
						<div class="flex flex-col mr-2 w-full">
							<p class="font-body text-gray-500 whitespace-pre-wrap">Daily Returns</p>
							<p class="font-body text-gray-800 whitespace-pre-wrap"><span class=""> {{ $plan->cur_sym }}{{ showAmount($plan->interest_amount) }}</span></p>
						</div>
						<div class="flex flex-col flex-1 self-start"></div>
					</div>
					<div class="flex flex-shrink-0 items-center rounded-t rounded-br border w-1/2-2 p-2 mb-4">
						<div class="flex flex-col mr-2 w-full">
							<p class="font-body text-gray-500 whitespace-pre-wrap">Interest Returns</p>
							<p class="font-body text-gray-800 whitespace-pre-wrap"><span class="">{{ $plan->cur_sym }}{{ showAmount($plan->interest_amount * $plan->total_return) }}</span></p>
						</div>
						<div class="flex flex-col flex-1 self-start"></div>
					</div>
					<div class="flex flex-shrink-0 items-center rounded-t rounded-br border w-1/2-2 p-2 mb-4">
						<div class="flex flex-col mr-2 w-full">
							<p class="font-body text-gray-500 whitespace-pre-wrap">Product Duration</p>
							<p class="font-body text-gray-800 whitespace-pre-wrap"><span class="">{{ $plan->total_return }} Days</span></p>
						</div>
						<div class="flex flex-col flex-1 self-start"></div>
					</div>

					@if($buyLimit)
					<div class="flex flex-shrink-0 items-center rounded-t rounded-br border w-1/2-2 p-2 mb-4">
						<div class="flex flex-col mr-2 w-full">
							<p class="font-body text-gray-500 whitespace-pre-wrap">Recruit limit</p>
							<p class="font-body text-gray-800 whitespace-pre-wrap"><span class="">{{ $boughtCount }} of {{ $limiBuy }}</span></p>
						</div>
						<div class="flex flex-col flex-1 self-start"></div>
					</div>
					@endif

					<div class="flex flex-shrink-0 items-center rounded-t rounded-br border w-1/2-2 p-2 mb-4">
						<div class="flex flex-col mr-2 w-full">
							<p class="font-body text-gray-500 whitespace-pre-wrap">Product</p>
							<p class="font-body text-gray-800 whitespace-pre-wrap"><span class="">Flexible.</span></p>
						</div>
						<div class="flex flex-col flex-1 self-start"></div>
					</div>
					<div class="flex flex-shrink-0 items-center rounded-t rounded-br border w-1/2-2 p-2 mb-4">
						<div class="flex flex-col mr-2 w-full">
							<p class="font-body text-gray-500 whitespace-pre-wrap">Type </p>
							<p class="font-body text-gray-800 whitespace-pre-wrap"><span class="">Open source</span></p>
						</div>
						<div class="flex flex-col flex-1 self-start"></div>
					</div>
				</div>
			
				<div class="flex flex-wrap justify-between flex-shrink-0 mb-4 w-full">
					<h3 class="font-body uppercase text-gray-600 mb-2 w-full">Extra Information</h3>
					<div class="flex flex-shrink-0 items-center rounded-t rounded-br border w-full p-2 mb-4">
						<div class="flex flex-col mr-2 w-full">
							<p class="font-body text-gray-500 whitespace-pre-wrap">{!! $plan->notes !!}</p>
						</div>
						<div class="flex flex-col flex-1 self-start"></div>
					</div>
				</div>
			</div>

		</div>
	</div>
	
</div>
</div>

@include($activeTemplate.'partials.recharge')

@endsection

@push('script')
<script>
    $('#btn-pay').on('click', function() {
        
        // Data
        var coupon = $('#coupon').val();
        var pay_with = $('#pay_with').val();

        $.ajax({
            url: "{{ route('user.investment.post') }}",
            type: 'POST',
            data: {
                'id': "{{ $plan->id }}",
                'coupon': coupon,
                'pay_with': pay_with
            },
             beforeSend: function() {
				loading.showLoading({type: 2,tip: "Please wait..."});
            },
            success: function(data) {
                // Redirect
                if(data.link) {
					modalMessage(data.message, 200, data.link);
                    return true;
                }
                loading.hideLoading();
                modalMessage(data.message);
            },
            error: function(xhr, status, error) {
                var data = JSON.parse(xhr.responseText);
                var responseMessage = data.message

                // Validator message
                if (data.errors) {
                    var errorMessages = [];
                    for (var key in data.errors) {
                        if (data.errors.hasOwnProperty(key)) {
                            errorMessages.push(data.errors[key][0]);
                        }
                    }

                    responseMessage = errorMessages.join(", ")
                }
				
                loading.hideLoading();
                modalMessage(responseMessage);

                // Redirect
                if(data.link) {
					recharge();
                    return true;
                }

            }
        });
    })

    $('#coupon').on('keyup input', function() {
        
        // Data
        var coupon = $(this).val();

        if(coupon == "") {
            $(".error-coupon, .success-coupon").addClass("d-none");
            getRate();
            return true;
        }

        $.ajax({
            url: "{{ route('user.coupon.use') }}",
            type: 'POST',
            data: {
                'code': coupon,
                'amount': "{{ showAmount($plan->min_amount) }}",
                'package': '{{ $plan->id }}'
            },
             beforeSend: function() {
				//loading.showLoading({type: 2,tip: "Please wait..."});
                
                $(".error-coupon, .success-coupon").html('');
                $(".error-coupon, .success-coupon").addClass("d-none");
            },
            success: function(data) {
                
                //loading.hideLoading();
                
                //$("#final").text("{{ Session::get('currency_sym') }}" + data.data.charge);
                //$("#coupon_amount").val(data.data.charge);
                $(".success-coupon").html("Discount of {{ $plan->cur_text }} "+ data.data.discount +" Will be added to your earning balance as a bonus you received");
                $(".success-coupon").removeClass("d-none");

                getRate();
            },
            error: function(xhr, status, error) {
                var data = JSON.parse(xhr.responseText);
                var responseMessage = data.message

                // Validator message
                if (data.errors) {
                    var errorMessages = [];
                    for (var key in data.errors) {
                        if (data.errors.hasOwnProperty(key)) {
                            errorMessages.push(data.errors[key][0]);
                        }
                    }

                    responseMessage = errorMessages.join(", ")
                }

                //loading.hideLoading();
                $(".error-coupon").html(responseMessage);
                $(".error-coupon").removeClass("d-none");
                $("#final").text("{{ Session::get('currency_sym') }}{{ showAmount($plan->min_amount) }}");
            }
        });
    })

    $('#pay_with').on('change', function() {
        getRate();
    })

    function getRate() {

        var exchange_summary = $('.exchange-summary');
        var currency = "{{ $plan->cur_text }}";
        var pay_wallet = $('#pay_with').val();

        if(currency == pay_wallet || pay_wallet == "") {
            exchange_summary.html('');
            exchange_summary.addClass('d-none');
            return true;
        }

        $.ajax({
            url: "{{ route('user.transaction.rate') }}",
            type: 'POST',
            data: {
                'amount': $('#coupon_amount').val(),
                'from_currency': currency,
                'to_currency': pay_wallet
            },
            success: function(response) {
                exchange_rate = (response.data.rate_text) ? response.data.rate_text : '';
                exchange_fee = response.data.currency.sym + response.data.fees;
                exchange_summary.html("Exchange Rate " + exchange_rate + " </br>Throng " + pay_wallet +" recharge wallet, you will be charged " + response.data.currency.sym + response.data.amount_with_fees);
                exchange_summary.removeClass('d-none');
            },

            error: function(err) {
                exchange_summary.html('');
                exchange_summary.addClass('d-none');
            }
        });
    }
</script>
@endpush