{"version":3,"sources":["webpack:///./src/views/admin/ExchangeRateUpdate.vue?72e4","webpack:///./src/views/admin/ExchangeRateUpdate.vue","webpack:///./src/views/admin/ExchangeRateUpdate.vue?8dc2","webpack:///./src/views/admin/ExchangeRateUpdate.vue?dc95","webpack:///./src/views/admin/ExchangeRateUpdate.vue?c559","webpack:///./src/views/admin/ExchangeRateUpdate.vue?0a8a","webpack:///./src/services/modules/exchangeRate.ts","webpack:///./src/composition/exchangeRate.ts","webpack:///./src/composition/service.ts"],"names":["render","_vm","this","_h","$createElement","_c","_self","attrs","scopedSlots","_u","key","fn","ref","handleSubmit","reset","class","isLoading","on","$event","preventDefault","submit","apply","arguments","staticClass","retry","_e","amountLabel","required","min_value","errors","amountDescription","model","value","callback","$$v","amount","expression","isSubmitting","proxy","staticRenderFns","name","components","ValidationObserver","ValidationProvider","exchangeId","i18n","t","data","error","exchangeKey","newValue","pesosExchangeRate","immediate","async","Error","update","dispatch","variant","message","component","module","exports","Component","options","__i18n","push","_Ctor","controller","createExchangeRateService","client","params","get","action","post","exchangeRateService","base","PESOS_EXCHANGE_KEY","useExchangeRate","request","useService","getKey","fetcher","getFn","response","Array","isArray","e","deep"],"mappings":"iIAAA,IAAIA,EAAS,WAAa,IAAIC,EAAIC,KAASC,EAAGF,EAAIG,eAAmBC,EAAGJ,EAAIK,MAAMD,IAAIF,EAAG,OAAOE,EAAG,qBAAqB,CAACE,MAAM,CAAC,MAAO,GAAMC,YAAYP,EAAIQ,GAAG,CAAC,CAACC,IAAI,UAAUC,GAAG,SAASC,GAC5L,IAAIC,EAAeD,EAAIC,aACnBC,EAAQF,EAAIE,MAChB,MAAO,CAACT,EAAG,OAAO,CAACO,IAAI,OAAOG,MAAM,CAC9B,wEACAd,EAAIe,UAAY,qBAAuB,WAAYT,MAAM,CAAC,WAAa,IAAIU,GAAG,CAAC,OAAS,SAASC,GAAgC,OAAxBA,EAAOC,iBAAwBN,EAAaZ,EAAImB,SAAS,MAAQ,SAASF,GAAgC,OA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41678479.js","sourcesContent":["var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('ValidationObserver',{attrs:{\"slim\":true},scopedSlots:_vm._u([{key:\"default\",fn:function(ref){\nvar handleSubmit = ref.handleSubmit;\nvar reset = ref.reset;\nreturn [_c('form',{ref:\"form\",class:[\n 'grid gap-6 sm:rounded-md sm:overflow-hidden px-4 py-5 sm:p-6 bg-white',\n _vm.isLoading ? 'animate-pulse h-64' : 'shadow ' ],attrs:{\"novalidate\":\"\"},on:{\"submit\":function($event){$event.preventDefault();return handleSubmit(_vm.submit)},\"reset\":function($event){$event.preventDefault();return reset.apply(null, arguments)}}},[(_vm.error)?_c('BaseBox',[_c('BaseBox',{staticClass:\"grid gap-8\"},[_c('BaseBox',{staticClass:\"grid gap-4\"},[_c('BaseAlert',{attrs:{\"tone\":\"caution\"}},[_c('BaseText',[_c('i18n',{attrs:{\"tag\":false,\"path\":\"error.copy\"}})],1)],1)],1),_c('BaseBox',{staticClass:\"\\n flex flex-col\\n space-y-4\\n lg:flex-row lg:space-y-0 lg:space-x-4\\n \"},[_c('BaseButton',{attrs:{\"variant\":\"solid\",\"tone\":\"tertiary\"},on:{\"click\":_vm.retry}},[_c('i18n',{attrs:{\"tag\":false,\"path\":\"error.cta.tryAgain\"}})],1)],1)],1)],1):(!_vm.isLoading)?[_c('ValidationProvider',{attrs:{\"name\":_vm.amountLabel,\"rules\":{ required: true, min_value: 0 },\"tag\":\"div\"},scopedSlots:_vm._u([{key:\"default\",fn:function(ref){\n var errors = ref.errors;\nreturn [_c('BaseFieldLabel',{attrs:{\"label\":_vm.amountLabel,\"description\":_vm.amountDescription,\"description-id\":\"amount-description\",\"html-for\":\"amount\"}}),_c('BaseInputText',{attrs:{\"id\":\"amount\",\"type\":\"number\",\"min\":\"0\"},model:{value:(_vm.amount),callback:function ($$v) {_vm.amount=$$v},expression:\"amount\"}}),_c('BaseFieldMessage',{attrs:{\"id\":\"amount-message\",\"message\":errors[0],\"tone\":\"critical\"}})]}}],null,true)}),_c('BaseBox',{staticClass:\"hidden sm:block\",attrs:{\"aria-hidden\":\"true\"}},[_c('BaseBox',{staticClass:\"border-t border-gray-300\"})],1),_c('BaseBox',{staticClass:\"text-right\"},[_c('BaseButton',{attrs:{\"loading\":_vm.isSubmitting,\"tone\":\"tertiary\",\"type\":\"submit\"},scopedSlots:_vm._u([{key:\"default\",fn:function(){return [_c('i18n',{attrs:{\"tag\":false,\"path\":\"submit\"}})]},proxy:true},{key:\"loading-text\",fn:function(){return [_c('i18n',{attrs:{\"tag\":false,\"path\":\"submitLoading\"}})]},proxy:true}],null,true)})],1)]:_vm._e()],2)]}}])})}\nvar staticRenderFns = []\n\nexport { render, staticRenderFns }","\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nimport { useExchangeRate } from '@/composition/exchangeRate'\nimport {\n exchangeRateService,\n PESOS_EXCHANGE_KEY,\n} from '@/services/modules/exchangeRate'\nimport i18n from '@/setup/i18n'\nimport communique from '@/notification'\nimport { ValidationObserver, ValidationProvider } from 'vee-validate'\nimport { computed, defineComponent, ref, watch } from '@vue/composition-api'\n\nexport default defineComponent({\n name: 'ExchangeRateUpdate',\n\n components: {\n ValidationObserver,\n ValidationProvider,\n },\n\n setup() {\n const exchangeId = ref('')\n const amount = ref(0)\n\n const amountLabel = computed(() => i18n.t('exchangeRate') as string)\n const amountDescription = computed(\n () => i18n.t('exchangeRateDescription') as string\n )\n\n const { data, isLoading, error, retry } = useExchangeRate({\n exchangeKey: PESOS_EXCHANGE_KEY,\n })\n\n watch(\n () => data.value,\n (newValue) => {\n const [pesosExchangeRate] = newValue\n\n if (!pesosExchangeRate) return\n\n exchangeId.value = pesosExchangeRate.exchangeId\n amount.value = pesosExchangeRate.amount\n },\n {\n immediate: true,\n }\n )\n\n const isSubmitting = ref(false)\n\n async function submit() {\n try {\n if (!exchangeId.value) {\n throw new Error('Exchange id error')\n }\n\n isSubmitting.value = true\n\n await exchangeRateService.update({\n exchangeId: exchangeId.value,\n amount: amount.value,\n })\n\n communique.dispatch({\n variant: 'success',\n message: i18n.t('exchangeRateUpdateSuccess') as string,\n })\n } catch (error) {\n communique.dispatch({\n variant: 'error',\n message: i18n.t('exchangeRateUpdateError') as string,\n })\n } finally {\n isSubmitting.value = false\n }\n }\n\n return {\n amount,\n amountLabel,\n amountDescription,\n isLoading,\n error,\n submit,\n isSubmitting,\n retry,\n }\n },\n})\n","import mod from \"-!../../../node_modules/cache-loader/dist/cjs.js??ref--14-0!../../../node_modules/thread-loader/dist/cjs.js!../../../node_modules/babel-loader/lib/index.js!../../../node_modules/ts-loader/index.js??ref--14-3!../../../node_modules/cache-loader/dist/cjs.js??ref--0-0!../../../node_modules/vue-loader/lib/index.js??vue-loader-options!./ExchangeRateUpdate.vue?vue&type=script&lang=ts&\"; export default mod; export * from \"-!../../../node_modules/cache-loader/dist/cjs.js??ref--14-0!../../../node_modules/thread-loader/dist/cjs.js!../../../node_modules/babel-loader/lib/index.js!../../../node_modules/ts-loader/index.js??ref--14-3!../../../node_modules/cache-loader/dist/cjs.js??ref--0-0!../../../node_modules/vue-loader/lib/index.js??vue-loader-options!./ExchangeRateUpdate.vue?vue&type=script&lang=ts&\"","import { render, staticRenderFns } from \"./ExchangeRateUpdate.vue?vue&type=template&id=00104840&\"\nimport script from \"./ExchangeRateUpdate.vue?vue&type=script&lang=ts&\"\nexport * from \"./ExchangeRateUpdate.vue?vue&type=script&lang=ts&\"\n\n\n/* normalize component */\nimport normalizer from \"!../../../node_modules/vue-loader/lib/runtime/componentNormalizer.js\"\nvar component = normalizer(\n script,\n render,\n staticRenderFns,\n false,\n null,\n null,\n null\n \n)\n\n/* custom blocks */\nimport block0 from \"./ExchangeRateUpdate.vue?vue&type=custom&index=0&blockType=i18n&lang=json\"\nif (typeof block0 === 'function') block0(component)\n\nexport default component.exports","import mod from \"-!../../../node_modules/@intlify/vue-i18n-loader/lib/index.js!../../../node_modules/cache-loader/dist/cjs.js??ref--0-0!../../../node_modules/vue-loader/lib/index.js??vue-loader-options!./ExchangeRateUpdate.vue?vue&type=custom&index=0&blockType=i18n&lang=json\"; export default mod; export * from \"-!../../../node_modules/@intlify/vue-i18n-loader/lib/index.js!../../../node_modules/cache-loader/dist/cjs.js??ref--0-0!../../../node_modules/vue-loader/lib/index.js??vue-loader-options!./ExchangeRateUpdate.vue?vue&type=custom&index=0&blockType=i18n&lang=json\"","module.exports = function (Component) {\n Component.options.__i18n = Component.options.__i18n || []\n Component.options.__i18n.push('{\"en-US\":{\"submit\":\"Update exchange rate\",\"submitLoading\":\"Updating exchange rate\",\"error\":{\"copy\":\"There was an error trying to load the exchange rate. Try loading the exchange rate again.\",\"cta\":{\"tryAgain\":\"Try again\"}}},\"es-MX\":{\"submit\":\"Actualizar tipo de cambio\",\"submitLoading\":\"Actualizando tipo de cambio\",\"error\":{\"copy\":\"Se produjo un error al intentar cargar el tipo de cambio. Intenta cargar el tipo de cambio nuevamente.\",\"cta\":{\"tryAgain\":\"Intentar de nuevo\"}}}}')\n delete Component.options._Ctor\n}\n","import { AxiosInstance } from 'axios'\nimport { api } from '../client'\nimport { Audit, serviceUrl } from '../utils'\n\nconst controller = serviceUrl('exchange')\n\nfunction createExchangeRateService(client: AxiosInstance) {\n return {\n get(params: ExchangeModel) {\n return client.get<ExchangeViewModel[]>(controller.action('get'), {\n params,\n })\n },\n\n update(model: ExchangeUpdateModel) {\n return client.post<boolean>(controller.action('update'), model)\n },\n }\n}\n\nexport const exchangeRateService = createExchangeRateService(api.base)\n\nexport interface ExchangeModel {\n exchangeKey?: number\n}\n\nexport interface ExchangeUpdateModel {\n exchangeId: string\n amount: number\n}\n\nexport interface ExchangeViewModel extends Audit {\n exchangeId: string\n exchangeKey: number\n name: string\n abbreviation: string\n amount: number\n isDeleted: boolean\n}\n\nexport const PESOS_EXCHANGE_KEY = 1\n","import {\n ExchangeModel,\n exchangeRateService,\n} from '@/services/modules/exchangeRate'\nimport { computed } from '@vue/composition-api'\nimport { useService } from './service'\n\nexport function useExchangeRate(model?: ExchangeModel) {\n const request = computed<ExchangeModel>(() => ({\n ...model,\n }))\n\n return useService(request, () => exchangeRateService.get(request.value))\n}\n","import { Ref, ref, watch, WatchSource } from '@vue/composition-api'\nimport { AxiosResponse } from 'axios'\n\nexport function useService<T, K>(\n getKey: WatchSource<T>,\n fetcher: (...args: any) => Promise<AxiosResponse<K | K[]>>\n) {\n const data = ref([]) as Ref<K[]>\n const isLoading = ref(false)\n const error = ref<unknown | null>(null)\n\n watch(getKey, getFn, {\n deep: true,\n immediate: true,\n })\n\n async function getFn() {\n try {\n isLoading.value = true\n const response = await fetcher()\n data.value = Array.isArray(response.data)\n ? response.data\n : [response.data]\n } catch (e) {\n error.value = e\n } finally {\n isLoading.value = false\n }\n }\n\n async function retry() {\n await getFn()\n }\n\n return {\n data,\n isLoading,\n error,\n retry,\n }\n}\n"],"sourceRoot":""}