<template>
    <div class="row">
        <div class="col">
            <div class="row m-b-20 parentContainer" v-if="data.id === 9">
                <div class="col-auto">
                    <img src="/images/first_topup_badge.png" class="pointer requestModal" data-type="badgeModal" style="width: 50px;">
                </div>
                <modal-component class="animate__animated animate__fast animate__fadeIn" styleType="fill-in" type="badgeModal" size="extra-large">
                    <div class="row">
                        <div class="col text-center">
                            <div class="row m-b-50">
                                <div class="col bg-white padding-15">
                                    <h5 class="text-center text-success bold">Congratulation! You've earned an achievement</h5>
                                </div>
                            </div>
                            <div class="row justify-content-center">
                                <div class="col-8">
                                    <img src="/images/first_topup_badge.png" class="animate__animated animate__infinite animate__tada w-100">
                                </div>
                            </div>
                        </div>
                    </div>
                </modal-component>
            </div>
            <div class="row m-l-0 m-r-0 m-b-15">
                <div class="col bg-white padding-15">
                    <div class="row">
                        <div class="col">
                            <div class="bold d-flex align-items-center m-b-10">
                                <span class="rounded badge-success m-r-10 padding-5 p-l-15 p-r-15">New</span> March 1, 2020
                            </div>
                            <h5 class="bold fs-18">Try out our wallet to get a better rate now.</h5>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col">
                            <img class="m-b-10 w-100" src="/images/10107.jpg" />
                        </div>
                    </div>
                    <div class="row" :class="[{'h-25': !expanded}, {'overflow-hidden': !expanded}]">
                        <div class="col position-relative">
                            <div class="row">
                                <div class="col">
                                    <p>Transferring your payments by using the wallet just got a lot easier.</p>
                                    <div class="row">
                                        <div class="col" v-if="expanded">
                                            <p class="no-margin">This release you can:</p>
                                            <p class="no-margin">1. Top up once, pay for multiple transfers</p>
                                            <p class="no-margin">2. Get your refund back to your wallet</p>
                                            <p class="no-margin">3. Get a better exchange rate.</p>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="row position-absolute top-0 w-100 gradient-white p-t-15 p-b-15" v-if="!expanded">
                                <div class="col">
                                    <div class="m-b-0 m-t-5 d-flex justify-content-center cursor" @click="expanded = !expanded">Show more <i class="fa fa-angle-down fs-20 bold m-l-10"></i></div>
                                </div>
                            </div>
                            <div class="row" v-if="expanded">
                                <div class="col">
                                    <div class="m-b-0 m-t-5 d-flex justify-content-center cursor" @click="expanded = !expanded">Show less <i class="fa fa-angle-up fs-20 bold m-l-10"></i></div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row" v-if="!reload">
                <div class="col">
                    <div class="bg-complete" :class="[{'padding-25': !mini}, {'padding-15': mini}]">
                        <div class="row align-items-end">
                            <div class="col-auto">
                                <div class="text-primary-lighter fs-10 text-uppercase">Wallet Balance</div>
                                <h5 class="text-white no-margin bold">MYR {{ data.wallet ? (Math.round((data.wallet.amount + Number.EPSILON) * 100) / 100).toFixed(2) : '0.00'}}</h5>
                            </div>
                        </div>
                        <div class="row m-t-10 d-flex align-items-center">
                            <div class="col-auto">
                                <div class="btn btn-xs p-l-15 p-r-20 b-rad-none font-heading btn-rounded bg-white" @click="reload = true"><i class="fa fa-plus fs-8 m-r-5"></i> Reload</div>
                            </div>
                            <div class="col-auto p-l-0" v-if="!mini">
                                <a class="text-white fs-10" :href="route('wallet.details', data.reference)" target="_blank">Transaction History<i class="fa fa-angle-right p-l-5"></i></a>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row no-margin" v-if="reload">
                <div class="col rounded bg-white p-b-15">
                    <div class="row m-b-15">
                        <div class="col p-t-15 p-b-15 bg-complete">
                            <label class="fs-10 text-white m-b-0 text-uppercase cursor" @click="reload = false"><i class="fa fa-angle-left p-r-15"></i>Top Up Wallet</label>
                        </div>
                    </div>
                    <wallet-top-up-form-component :data="data" :amount="(!data.wallet ? amount : (Math.round((((amount - data.wallet.amount) < '0.00' ? '0.00' : (amount - data.wallet.amount))  + Number.EPSILON) * 100) / 100).toFixed(2))" :creditable="creditable"></wallet-top-up-form-component>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
    import componentHandler from '../../../general/mixins/componentHandler';

    export default {
        props: {
            mini : {
                type: Boolean,
                default: false
            },
            amount: {
                type: String,
                default: '0.00'
            },
            creditable: {
                type: Boolean,
                default: false
            }
        },
        data(){
            return {
                reload: false,
                expanded: false
            }
        },
        mixins: [componentHandler],
    }
</script>