<template>
    <div class="row m-b-10 parentContainer">
        <div class="col">
            <loading-component style="height: 200px; top: 0;" key="1" color="success" v-show="isLoading"></loading-component>
            <div class="row p-b-5 b-b b-grey" v-show="!isLoading">
                <div class="col">
                    <div class="row">
                        <div class="col">
                            <div class="row m-b-10">
                                <div class="col-auto">
                                    <div class="font-heading fs-10 muted all-caps">Date</div>
                                    <div class="font-heading fs-10">
                                        {{ data.booking.created_at_with_time }}
                                    </div>
                                </div>
                                <div class="col-auto">
                                    <div class="font-heading fs-10 muted all-caps">reference</div>
                                    <div class="font-heading fs-10">
                                        <a :href="route('booking.details', item.booking.marking)">{{item.booking.marking}}</a>
                                    </div>
                                </div>
                                <div class="col-auto">
                                    <div class="font-heading fs-10 muted all-caps">Marking</div>
                                    <div class="font-heading fs-10">
                                        <a :href="route('customer.profile', data.booking.company.reference)">{{data.booking.company.reference}}</a>
                                    </div>
                                </div>
                                <div class="col text-right">
                                    <div class="font-heading fs-10 muted all-caps">Amount</div>
                                    <div class="font-heading fs-14 text-success bold">
                                        {{(Math.round((data.original_amount + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}}
                                    </div>
                                </div>
                            </div>
                            <div class="row m-b-10">
                                <div class="col">
                                    <div class="text-right">
                                        <button class="btn btn-xs btn-outline-danger b-rad-none m-r-5 requestModal" data-type="rejectRefund">
                                            <i class="fa fa-times fa-fw"></i>
                                        </button>
                                        <button class="btn btn-xs btn-success b-rad-none requestModal" data-type="approveRefund">
                                            <i class="fa fa-check fa-fw"></i>
                                        </button>
                                        <modal-component small type="rejectRefund">
                                            <div class="row">
                                                <div class="col text-center">
                                                    <div class="row">
                                                        <div class="col text-center">
                                                            <div class="row m-b-20">
                                                                <div class="col">
                                                                    <h5 class="all-caps">Reject Refund</h5>
                                                                    <div class="fs-11">Are you sure you want to reject this refund?</div>
                                                                </div>
                                                            </div>
                                                            <div class="row">
                                                                <div class="col p-r-5">
                                                                    <div data-dismiss="modal" class="btn btn-sm btn-default bg-master-lighter btn-block b-rad-none">Cancel</div>
                                                                </div>
                                                                <div class="col p-l-5">
                                                                    <div data-dismiss="modal" class="btn btn-sm btn-danger btn-block b-rad-none" @click="approveRefund(4)">Reject</div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </modal-component>
                                        <modal-component small type="approveRefund">
                                            <div class="row">
                                                <div class="col text-center">
                                                    <div class="row">
                                                        <div class="col text-center">
                                                            <div class="row m-b-20">
                                                                <div class="col">
                                                                    <h5 class="all-caps">Approve Refund</h5>
                                                                    <div class="fs-11">Are you sure you want to approve this refund?</div>
                                                                </div>
                                                            </div>
                                                            <div class="row">
                                                                <div class="col p-r-5">
                                                                    <div data-dismiss="modal" class="btn btn-sm btn-default bg-master-lighter btn-block b-rad-none">Cancel</div>
                                                                </div>
                                                                <div class="col p-l-5">
                                                                    <div data-dismiss="modal" class="btn btn-sm btn-success btn-block b-rad-none" @click="approveRefund(2)">Approve</div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </modal-component>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
    import componentHandler from '../../../general/mixins/componentHandler';
    import staticFormHandler from '../../../general/mixins/staticFormHandler'
    export default {
        data() {
            return {
                parameters: {
                    status: null,
                }
            }
        },
        methods: {
            approveRefund(status){
                this.isLoading = true;
                this.parameters.status = status;
                this.submit(this.route('api.transaction.refund.status.update', this.data.id, status), 'put', 'listRefundTransactionSection', true, true);
            },
        },
        mixins: [componentHandler, staticFormHandler]
    }
</script>
