import Vue from "vue";
import initVue from "@assets/js/initVue";

const vm = new Vue({
    data(){
        return{
            heading: 'Histórico de Devoluções',
            returns: [],
            openContent: [],
        }
    },
    components:{
        BaseCard: () => import(/* webpackChunkName: "BaseCard" */ '@elements/BaseCard/index.vue'),
        BaseListing: () => import(/* webpackChunkName: "BaseListing" */ '@elements/BaseListing/index.vue'),
    },
    methods:{
        setData({returns}){
            this.returns = returns;
            this.returns.map((item, index) => {
                this.openContent.push({
                    show: false
                })
            });
        },
        handleCardClick(index){
            this.openContent[index].show = this.openContent[index].show == true ? false : true;
        },
        handleProductName(productName, maxLength){
            if(productName.length > maxLength){
                return productName.substring(0, maxLength) + '...'
            }

            return productName;
        }
    }
});

initVue(vm);