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

/*
* Builds category select modal
* -----------------------------------------------------------
* self object needs to contain the following reactive keys:
*  - motto
*  - description
*  - forumPostDescriptionCreateModal
*/

export default (self, { backButtonClicked, doneButtonClicked }) => {
	return self.$ionic.modalController.create({
      component: RecoCreateForumPostDescription,
      componentProps: {
        propsData: {
          description: self.description,
          visibility: {
            gender: self.gender,
            age: self.age,
            distance: self.distance,
          },
          backButtonClicked: backButtonClicked ? backButtonClicked : () => { return },
          withBackButton: backButtonClicked ? true : false,
          doneButtonClicked
        },
        mounted() {
          setTimeout(() => { this.$refs.descriptionInput.setFocus(); }, 300);
        },
        methods: {
          onDescriptionChange(description) {
            self.description = description;
          },
          onVisibilityChange(key, value) {
            self[key] = value;
            console.log({key, value});
          },
        }
      },
    })
    .then(m => {
      self.forumPostDescriptionCreateModal = m;
      self.forumPostDescriptionCreateModal.present();
    })
}