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'),
    BaseInputFile: () => import(/* webpackChunkName: "BaseInputFile" */ '@elements/BaseInputFile/index.vue'),
    BaseTabs: () => import(/* webpackChunkName: "BaseTabs" */ '@components/BaseTabs/index.vue'),
    AsideContent: () => import(/* webpackChunkName: "AsideContent" */ '@components/AsideContent/index.vue'),
    BaseTextarea: () => import(/* webpackChunkName: "BaseTextarea" */ '@elements/BaseTextarea/index.vue'),
    BaseManual: () => import(/* webpackChunkName: "BaseManual" */ "@elements/BaseManual/index.vue")
  },
  data() {
    return {
      configurations: {
        boughtalso_title: '',
        boughtalso_module: []
      },
      disableForm: false,
      loadingBtn: false,
    };
  },
  created(){

  },
  watch: {},
  computed: {},
  beforeMount() {},
  mounted() {},
  methods: {
    onAddModule() {
      const { configurations } = this;
      const boughtalsoModule = configurations.boughtalso_module;

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

      boughtalsoModule.push({
        layout_id: Type_IdLayout.Tp_IdProduct,
        limit: '24',
        sort_order: sortOrder,
      });

      this.configurations = {...configurations};
    },
    onRemoveModule(moduleIndex){
      const { configurations } = this;
      const boughtalsoModule = configurations.boughtalso_module;
      boughtalsoModule.splice(moduleIndex, 1);
      this.configurations = {...configurations};
    }
  }
});

initVue(vm);
