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

/*
* Builds category select modal
* -----------------------------------------------------------
* self object needs to contain the following reactive keys:
*  - maxResponses
*  - chatType
*  - automaticResponse 
*  - expirationSelectModal
*/

export default (self) => {
  return self.$ionic.modalController.create({
    component: RecoSelectResponseType,
    componentProps: {
      propsData: {
        maxResponses: self.maxResponses,
        selectedChatType: self.chatType,
        automaticResponse: self.automaticResponse,
        doneButtonClicked: () => { self.expirationSelectModal.dismiss() },
      },
      methods: {
        onSelectChatType(val) {
          self.chatType = this.chatTypes.find(chatType => chatType.value === val);
          this.selectedChatType = self.chatType;
        },
        onMaxResponsesChange(val) {
          self.maxResponses = val;
          this.locMaxResponses = self.maxResponses;
        },
        onAutomaticResponseChange(val) {
          self.automaticResponse = val;
        },
      },
    },
  })
  .then(m => {
    self.expirationSelectModal = m;
    self.expirationSelectModal.present();
  });
}