import AdmVue from '@assets/js/adm-vue';
import initVue from "@assets/js/initVue";

const vm = new AdmVue({
  components: {
    BaseCard: () => import(/* webpackChunkName: "BaseCard" */ '@elements/BaseCard/index.vue'),
    BaseTabs: () => import(/* webpackChunkName: "BaseTabs" */ '@components/BaseTabs/index.vue'),
  },
  data() {
    return {
      configurations: {
        product_who_saw_title: '',
        product_who_saw_module: [],
      },
      disableForm: false,
      loadingBtn: false,
    };
  },
  methods:{
    onAddModule(){

      const { configurations } = this;
      const productWhoSawModule = configurations.product_who_saw_module;

      let sortOrder = 0;
      if (productWhoSawModule[productWhoSawModule.length - 1]) {
        const { sort_order } = productWhoSawModule[productWhoSawModule.length - 1];
        sortOrder = Number(sort_order) + 1;
      }

      this.configurations.product_who_saw_module.push({
        limit: '24',
      });

      this.configurations = {...configurations};
    },
    onRemoveModule(moduleIndex){
      const { configurations } = this;
      const productWhoSawModule = configurations.product_who_saw_module;
      productWhoSawModule.splice(moduleIndex, 1);
      this.configurations = {...configurations};
    }
  },
});

initVue(vm);
