import RecoSelectAudience from '@/components/complex/RecoSelectAudience.vue';

/*
* Builds category select modal
* -----------------------------------------------------------
* self object needs to contain the following reactive keys:
*  - gender
*  - age
*  - audienceSelectModal
*/

export default (self, title, description) => {
  let propsData = {
    selectedGender: self.gender,
    age: self.age,
    doneButtonClicked: () => { self.audienceSelectModal.dismiss() },
  }
  if (title) {
    propsData.title = title;
  }
  if (description) {
    propsData.description = description;
  }
  return self.$ionic.modalController.create({
    component: RecoSelectAudience,
    componentProps: {
      propsData: propsData,
      methods: {
        onSelectGender(val) {
          self.gender = this.genders.find(gender => gender.value === val);
        },
        onChangeAge(val) {
          self.age = val;
          this.locAge = self.age;
        },
      },
    },
  })
  .then(m => {
    self.audienceSelectModal = m;
    self.audienceSelectModal.present();
  })
}