<template>
    <div class="row align-items-center m-b-15 parentContainer p-t-10 p-b-10">
        <div class="col-2">
            <div class="font-heading fs-10 muted all-caps">Marking</div>
            <div class="font-heading fs-12">
                CIEF/{{this.company.marking}}
            </div>
        </div>
        <div class="col">
            <div class="font-heading fs-10 muted all-caps">Company Name</div>
            <div class="font-heading fs-12">
                {{this.company.name}}
            </div>
        </div>
        <div class="col-auto">
            <div class="font-heading fs-10 muted all-caps">Email Address</div>
            <div class="font-heading fs-12">
                {{this.company.email}}
            </div>
        </div>
        <div class="col-auto">
            <div class="font-heading fs-10 muted all-caps">Contact No.</div>
            <div class="font-heading fs-12">
                {{this.company.contact.phone}}
            </div>
        </div>
        <div class="col-auto">
            <div class="font-heading fs-10 muted all-caps">WeChat Id</div>
            <div class="font-heading fs-12">
                {{this.company.contact.wechat_id}}
            </div>
        </div>
        <div class="col" v-if="company.status === 1">
            <div class="row m-b-5">
                <div class="col">
                    <div class="fs-8 all-caps muted">{{ this.company.type === 0 ? 'IC' : 'SSM Registration' }} Document</div>
                </div>
            </div>
            <div class="row no-margin">
                <div v-for="file in this.company.identification.files" v-bind:key="file.id"  class="col-auto no-padding m-r-5">
                    <document-file-viewr-component :file="file">
                        <template slot="button">
                            <div class="icon-thumbnail fs-11 text-white icon-25 bg-primary btn-rounded float-left m-r-5">
                                <i class="fa fa-file-image-o fs-10"></i>
                            </div>
                        </template>
                    </document-file-viewr-component>
                </div>
            </div>
        </div>
        <div class="col-2">
            <div class="row align-items-center parentContainer">
                <div class="col-auto ml-auto">
                    <button class="btn btn-xs btn-danger b-rad-none p-t-10 p-b-10 requestModal" v-if="company.status === 1" data-type="rejectDocument">
                        <i class="fa fa-times"></i>
                    </button>
                    <button class="btn btn-xs btn-success b-rad-none p-t-10 p-b-10 requestModal" v-if="company.status === 1" data-type="approveDocument">
                        <i class="fa fa-check"></i>
                    </button>
                    <a class="btn btn-xs btn-info b-rad-none" :href="route('dashboard.importer', company.id)" v-if="company.status === 2">
                        <i class="fa fa-angle-right fa-fw"></i>
                    </a>
                    <modal-component small type="rejectDocument" v-if="company.status === 1">
                        <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 Document</h5>
                                                <div class="fs-11">Are you sure you want to reject this customer's identification?</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="approveDocument('reject')">Reject</div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </modal-component>
                    <modal-component small type="approveDocument" v-if="company.status === 1">
                        <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 Document</h5>
                                                <div class="fs-11">Are you sure you want to approve this customer's identification?</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="approveDocument('approve')">Approve</div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </modal-component>
                </div>
            </div>
        </div>
    </div>
</template>
<script>
    export default {
        props: {
            'data': {
                type: Object,
                required: true
            }
        },
        data() {
            return {
                company: this.data
            }
        },
        watch: {
            'data': function() {
                this.company = this.data;
            }
        },
        methods: {
            approveDocument(status){
                this.isLoading = true;
                this.submit(this.route('api.company.identification.approval', this.company.id, this.company.identification.id, status), 'put', 'identificationVerificationSection', true, true);
            },
            successHandler(){
                location.reload();
            }
        },
    }
</script>