<template>
    <div class="d-flex row m-b-10 align-items-center">
        <div class="col-auto">
            <div class="row align-items-end">
                <div class="col-auto">
                    <div class="row">
                        <div class="col">
                            <p class="no-margin small hint-text fs-10">Our Warehouse</p>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col">
                            <p class="no-margin bold">{{item.last_order.warehouse.name}}</p>
                        </div>
                    </div>
                </div>
                <div class="col-auto hide">
                    <div class="btn btn-xs btn-primary bg-primary-light btn-rounded fs-12 ">
                        <i class="fa fa-map-marker"></i>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-auto">
            <div class="row align-items-end">
                <div class="col-auto">
                    <div class="row">
                        <div class="col">
                            <p class="no-margin small hint-text fs-10">Your Delivery Address</p>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col">
                            <p class="no-margin bold">{{item.last_order.address.reference}} <i class="fa fa-info-circle m-l-5" v-tooltip:right="item.last_order.address.street_one+' '+(item.last_order.address.street_two ? item.last_order.address.street_two : '')+', '+ item.last_order.address.district.name+', '+item.last_order.address.post_code+' '+item.last_order.address.state.name+', '+item.last_order.address.country.name" ></i></p>
                        </div>
                    </div>
                </div>
                <div class="col-auto hide">
                    <div class="btn btn-xs btn-primary bg-primary-light btn-rounded fs-12 ">
                        <i class="fa fa-map-marker"></i>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-sm-12 col-md mt-3 mt-md-0">
            <div class="btn btn-sm btn-primary bg-primary-darker no-padding btn-rounded fs-12 no-border">
                <div class="row align-items-center no-margin" @click="createOrder()">
                    <div class="col-auto" v-show="$store.getters.isLoading('quickOrderSection')" style="width: 172px; height: 20px;">
                        <loading-component style="height: 20px; top: 0;" color="white"></loading-component>
                    </div>
                    <div class="col-auto no-padding">
                        <i class="fa fa-hand-o-up bg-primary-dark p-t-10 p-b-10 p-l-15 p-r-15 btn-rounded"></i>
                    </div>
                    <div class="col p-r-25" v-show="!$store.getters.isLoading('quickOrderSection')">
                        Place Order with 1-Click
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>
<script>
    import componentHandler from '../../../general/mixins/componentHandler';
    export default {
        data(){
          return {
              parameters: {
                  warehouse_id: this.data.last_order.warehouse.id,
                  address_id: this.data.last_order.address.id,
                  company_id: this.data.id,
              }
          }
        },
        methods: {
            createOrder(){
                this.submit(this.route('api.order.create'), 'post', 'quickOrderSection', true, true)
            },
            successHandler(){
                this.$store.dispatch('reloadList', {'name': 'orderListSection'});
                this.$store.dispatch('reloadList', {'name': 'pendingOrderListSection'});
                this.$store.dispatch('reloadList', {'name': 'activeOrderListSection'});
            }

        },
        mixins: [componentHandler]
    }
</script>