export default {
  name: 'TheInterests',
  props: {
    info: {
      type: Object,
      required: true,
    },
  },
  data() {
    return this.info;
  },
  methods: {
    parentCheckbox(index) {
      const { checked } = this.categories[index];
      this.categories[index].children = this.categories[index].children.map(item => ({ ...item, checked: checked }));
      this.$emit('onchangecategories', JSON.parse(JSON.stringify(this.categories)));
    },
    childrenCheckbox(index) {
      const { children } = this.categories[index];
      this.categories[index].checked = children.reduce((acc, item) => item.checked && acc, true);
      this.$emit('onchangecategories', JSON.parse(JSON.stringify(this.categories)));
    },
  },
};
