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MAAM,KAAK,sBAEzB,CAAa,EAGG,KAAK,gBAAkB,KACzB,KAAK,aAAY,EACjB,KAAK,aAAa,CAAE,IAAK,SAAU,MAAO,EAAK,CAAE,IAKrD,KAAK,eAAeD,EAAY,MAAOA,EAAY,KAAMA,EAAY,IAAI,CAGnF,CAAK,EAAE,MAAMK,GAAK,CACRL,IACH,KAAK,eAAeA,EAAY,MAAOA,EAAY,KAAMA,EAAY,IAAI,EACtE,KAAK,iBAAiBK,CAAC,GAE3B,KAAK,aAAa,CAAE,IAAK,SAAU,MAAO,EAAK,CAAE,CACvD,CAAK,CACF,EACD,eAAeC,EAAM,KAAMC,EAAK,KAAMC,EAAK,KAAM,CAC3C,KAAK,gBAAkB,IACzB,KAAK,MAAM,KAAK,CAAE,MAAAF,EAAO,KAAAC,EAAM,KAAAC,EAAM,CAExC,CACD,CACF,EC1EeC,EAAA,CACb,OAAQ,CAAC,UAAU,EAEnB,SAAU,CACR,GAAGhC,EAAUC,CAAgB,EAC7B,GAAGC,EAASD,EAAkB,CAAC,cAAc,CAAC,CAE/C,EAED,SAAU,CACR,KAAK,kBAAmB,CACzB,EAED,QAAS,CACP,GAAGY,EAAWZ,EAAkB,CAAC,cAAc,CAAC,EAEhD,mBAAoB,CACd,KAAK,UAAY,KAAK,cACxB,OAAO,KAAK,KAAK,QAAQ,EAAE,QAAQgC,GAAO,CACxC,KAAK,aAAa,CAAC,IAAAA,EAAK,MAAO,KAAK,SAASA,CAAG,CAAC,CAAC,CAC5D,CAAS,CAEJ,CACF,CACH","names":["_sfc_main","mapStores","dynamicFormStore","mapState","_b","_a","_d","_c","defineAsyncComponent","__variableDynamicImportRuntimeHelper","__vitePreload","n","Loading","newValue","mapActions","_openBlock","_createBlock","_resolveDynamicComponent","$options","$event","$props","redirectToThankYouPageForms","ApiMethods","url","errorConfig","successConfig","_f","_e","response","e","title","text","icon","LayoutMethods","key"],"ignoreList":[],"sources":["../../../app/javascript/mints-components/cali-dynamic-form/components/Layouts/Field.vue","../../../app/javascript/mints-components/cali-dynamic-form/mixins/api_methods.js","../../../app/javascript/mints-components/cali-dynamic-form/mixins/layout_methods.js"],"sourcesContent":["\r\n\r\n\r\n","// Store\r\nimport { dynamicFormStore } from \"../stores/store\";\r\nimport { mapStores, mapState, mapActions } from 'pinia'\r\n\r\nconst redirectToThankYouPageForms = [\r\n 'home-conversation-contact-register-es',\r\n 'home-conversation-contact-register-en',\r\n 'promos-contact-register-es',\r\n 'promos-contact-register-en'\r\n];\r\n\r\nexport default {\r\n inject: ['onSubmit','handleKnownError'],\r\n computed: {\r\n ...mapStores(dynamicFormStore),\r\n ...mapState(dynamicFormStore, ['answers', 'submitField', 'defaultApi', 'slug', 'displayAlerts']),\r\n },\r\n methods: {\r\n ...mapActions(dynamicFormStore, ['resetStep', 'changeStatus', 'resetAnswers']),\r\n callApi() {\r\n this.changeStatus({ key: 'submit', value: true });\r\n \r\n const url = this.submitField?.extra_parameters?.api || this.defaultApi\r\n\r\n const errorConfig = this.submitField?.extra_parameters?.error_message;\r\n const successConfig = this.submitField?.extra_parameters?.success_message;\r\n\r\n this.$axios.post(url, { data: this.answers }).then((response) => {\r\n // Handle known errors\r\n if (response.data.hasOwnProperty('error')) {\r\n if (response.data.error === 'weekpass_error') {\r\n this.handleKnownError(response.data);\r\n this.$emit('resetVErrors');\r\n this.changeStatus({ key: 'submit', value: false });\r\n }\r\n } else {\r\n if (response.data.data?.success === true) {\r\n // Redirect to thank you page if form slug exists in constant\r\n if (redirectToThankYouPageForms.includes(this.slug)) {\r\n window.location.href = '/' + locale + \"/tp-general\";\r\n } else {\r\n this.callSweetAlert(successConfig?.title, successConfig?.text, successConfig?.icon)\r\n this.onSubmit(this.answers);\r\n this.resetStep();\r\n this.$emit('resetVErrors');\r\n \r\n setTimeout(async () => {\r\n await this.initializeContact();\r\n if (typeof this.updateStepByAutofill === 'function') {\r\n await this.updateStepByAutofill();\r\n }\r\n });\r\n \r\n // Display alert if option is enabled, otherwise, do nothing and keep submit status loading\r\n if (this.displayAlerts === true) {\r\n this.resetAnswers();\r\n this.changeStatus({ key: 'submit', value: false });\r\n }\r\n }\r\n } else {\r\n // If error exists\r\n this.callSweetAlert(errorConfig.title, errorConfig.text, errorConfig.icon)\r\n }\r\n }\r\n }).catch(e => {\r\n if (errorConfig) {\r\n this.callSweetAlert(errorConfig.title, errorConfig.text, errorConfig.icon)\r\n this.handleKnownError(e);\r\n }\r\n this.changeStatus({ key: 'submit', value: false });\r\n })\r\n },\r\n callSweetAlert(title=null, text=null, icon=null) {\r\n if (this.displayAlerts === true) {\r\n this.$swal.fire({ title, text, icon })\r\n }\r\n }\r\n }\r\n}","// Store\r\nimport { dynamicFormStore } from \"../stores/store\";\r\nimport {mapStores, mapActions, mapState} from 'pinia'\r\n\r\nexport default {\r\n inject: ['$contact'],\r\n \r\n computed: {\r\n ...mapStores(dynamicFormStore),\r\n ...mapState(dynamicFormStore, ['allowPreFill']),\r\n \r\n },\r\n \r\n created() {\r\n this.initializeContact()\r\n },\r\n \r\n methods: {\r\n ...mapActions(dynamicFormStore, ['updateAnswer']),\r\n \r\n initializeContact() {\r\n if (this.$contact && this.allowPreFill) {\r\n Object.keys(this.$contact).forEach(key => {\r\n this.updateAnswer({key, value: this.$contact[key]});\r\n })\r\n }\r\n }\r\n }\r\n}"],"file":"assets/layout_methods-CoHFsqhG.js"}