{"version":3,"sources":["webpack:///./src/views/admin/Typologies.vue?0ba5","webpack:///./src/composition/servicePaginated.ts","webpack:///./src/composition/typologies.ts","webpack:///./src/services/modules/typology.ts","webpack:///./src/composition/currency.ts","webpack:///./src/services/modules/exchangeRate.ts","webpack:///./src/views/admin/Typologies.vue?8863","webpack:///./src/views/admin/Typologies.vue","webpack:///./src/views/admin/Typologies.vue?0c23","webpack:///./src/views/admin/Typologies.vue?f89c","webpack:///./src/composition/exchangeRate.ts","webpack:///./src/composition/service.ts","webpack:///./src/views/admin/Typologies.vue?a3d3"],"names":["module","exports","Component","options","__i18n","push","_Ctor","defaultSettings","onSuccess","onError","onCancel","watchOptions","deep","immediate","useServicePaginated","getKey","fetcher","settings","serviceSettings","data","totalItems","isLoading","error","CancelToken","a","cancel","async","value","response","cancelToken","c","items","e","isCancel","useTypologies","model","request","languageId","guid","get","controller","createTypologyService","client","params","action","post","typologyService","base","exchangeKey","pesosExchangeRateAmount","amount","isDisplayMxCurrency","Boolean","locale","convertFromUsdToMxn","Math","ceil","convertFromMxnToUsd","getUsdPrice","useCurrency","currency","computedLocale","Object","values","find","language","currencyCode","code","shouldConvertToMexicanPeso","Number","parseFloat","currencySuffix","toLocaleString","minimumFractionDigits","maximumFractionDigits","createExchangeRateService","exchangeRateService","PESOS_EXCHANGE_KEY","render","_vm","this","_h","$createElement","_c","_self","attrs","scopedSlots","_u","key","fn","ref","handleSubmit","reset","staticClass","on","$event","preventDefault","submit","apply","arguments","enableEditMode","enabled","rows","columns","column","formattedRow","row","field","_v","_s","editMode","priceLabel","required","min_value","errors","setCurrency","originalIndex","price","callback","$$v","$set","_n","expression","isSubmitting","proxy","_e","staticRenderFns","name","components","ValidationObserver","ValidationProvider","form","i18n","t","priceUsd","priceMxn","label","thClass","tdClass","pageNumber","rowsPerPage","forEach","typologyId","isSoldOut","typologiesToUpdate","index","length","typology","update","typologyTableType","dispatch","variant","message","idx","findIndex","el","component","useExchangeRate","useService","getFn","Array","isArray","retry"],"m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,MAC1Bf,EAAK3E,MAAM8H,GAAKV,UAAYV,EAAEU,aAIlCjC,EAASnF,OAAQ,EACjB,MAAOL,GACP,OAAWgI,SAAS,CAClBC,QAAS,QACTC,QAASpB,EAAA,KAAKC,EAAE,yBAtBpB,QAyBEV,EAAahG,OAAQ,GAIzB,MAAO,CACL2E,OACAjF,YACAD,aACAE,QACAiF,UACAO,WACAV,iBACAe,cACAlB,SACA9D,QACAwF,eACAZ,aACAoB,WC1RiZ,I,wBCOnZyB,EAAY,eACd,EACA9E,EACAgD,GACA,EACA,KACA,KACA,MAMoB,oBAAX,cAAuB,qBAAO8B,GAE1B,aAAAA,E,2CCtBf,0EAOM,SAAUC,EAAgB1H,GAC9B,MAAMC,EAAU,eAAwB,KAAM,IACzCD,KAGL,OAAO,eAAWC,EAAS,IAAM,OAAoBG,IAAIH,EAAQT,U,kCCZnE,kDAGM,SAAUmI,EACd/I,EACAC,GAEA,MAAMG,EAAO,eAAI,IACXE,EAAY,gBAAI,GAChBC,EAAQ,eAAoB,MAOlCI,eAAeqI,IACb,IACE1I,EAAUM,OAAQ,EAClB,MAAMC,QAAiBZ,IACvBG,EAAKQ,MAAQqI,MAAMC,QAAQrI,EAAST,MAChCS,EAAST,KACT,CAACS,EAAST,MACd,MAAOa,GACPV,EAAMK,MAAQK,EAPhB,QASEX,EAAUM,OAAQ,GAItBD,eAAewI,UACPH,IAGR,OAvBA,eAAMhJ,EAAQgJ,EAAO,CACnBnJ,MAAM,EACNC,WAAW,IAqBN,CACLM,OACAE,YACAC,QACA4I,W,kCCtCJ,yBAA6R,eAAG","file":"js/Typologies.vue.5231c396.js","sourcesContent":["module.exports = function (Component) {\n Component.options.__i18n = Component.options.__i18n || []\n Component.options.__i18n.push('{\"en-US\":{\"submitUpdate\":\"Save changes\",\"submitUpdateButtonLoading\":\"Saving changes\"},\"es-MX\":{\"submitUpdate\":\"Guardar cambios\",\"submitUpdateButtonLoading\":\"Guardando cambios\"}}')\n delete Component.options._Ctor\n}\n","import { PaginationList, PaginationSelectModel } from '@/services/utils'\nimport {\n Ref,\n ref,\n watch,\n WatchOptions,\n WatchSource,\n} from '@vue/composition-api'\nimport axios, { AxiosRequestConfig, AxiosResponse, Canceler } from 'axios'\n\nexport interface ServicePaginatedSettings {\n onSuccess?: () => void\n onError?: () => void\n onCancel?: () => void\n watchOptions?: WatchOptions\n}\n\nconst defaultSettings = {\n onSuccess: () => {},\n onError: () => {},\n onCancel: () => {},\n watchOptions: {\n deep: true,\n immediate: true,\n },\n}\n\nexport function useServicePaginated(\n getKey: WatchSource,\n fetcher: (\n config?: AxiosRequestConfig\n ) => Promise>>,\n settings?: ServicePaginatedSettings\n) {\n const serviceSettings = {\n ...defaultSettings,\n ...settings,\n }\n\n const data = ref([]) as Ref\n const totalItems = ref(0)\n const isLoading = ref(false)\n const error = ref(null)\n\n const CancelToken = axios.CancelToken\n const cancel = ref(null)\n\n watch(\n getKey,\n async () => {\n try {\n if (cancel.value) {\n cancel.value()\n }\n isLoading.value = true\n const response = await fetcher({\n cancelToken: new CancelToken((c) => {\n cancel.value = c\n }),\n })\n data.value = response.data.items\n totalItems.value = response.data.totalItems\n } catch (e) {\n error.value = e\n if (axios.isCancel(e)) {\n serviceSettings.onCancel()\n } else {\n serviceSettings.onError()\n }\n } finally {\n isLoading.value = false\n cancel.value = null\n }\n },\n serviceSettings.watchOptions\n )\n\n return {\n data,\n totalItems,\n isLoading,\n error,\n }\n}\n","import { TypologyModel, typologyService } from '@/services/modules/typology'\nimport { currentLanguage } from '@/utils/language'\nimport { computed, ComputedRef, isRef } from '@vue/composition-api'\n// import { AxiosRequestConfig } from 'axios'\nimport { useServicePaginated } from './servicePaginated'\n\nexport function useTypologies(\n model: ComputedRef | TypologyModel\n) {\n const request = computed(() => ({\n languageId: currentLanguage.value.guid,\n ...(isRef(model) ? model.value : model),\n }))\n return useServicePaginated(request, () => typologyService.get(request.value))\n}\n","import { AxiosInstance } from 'axios'\nimport { api } from '../client'\nimport {\n Audit,\n serviceUrl,\n PaginationSelectModel,\n PaginationList,\n} from '../utils'\n\nconst controller = serviceUrl('typology')\n\nfunction createTypologyService(client: AxiosInstance) {\n return {\n get(params: TypologyModel) {\n return client.get>(\n controller.action('get'),\n {\n params,\n }\n )\n },\n\n update(model: TypologyUpdateModel) {\n return client.post(controller.action('update'), model)\n },\n }\n}\n\nexport const typologyService = createTypologyService(api.base)\n\nexport interface TypologyModel extends PaginationSelectModel {\n languageId?: string\n typologyId?: string\n}\n\nexport interface TypologyUpdateModel {\n typologyTableType: TypologyTableType[]\n}\n\nexport interface TypologyViewModel extends Audit {\n typologyId: string\n typologyKey: number\n price: number\n code: string\n description: string\n isDeleted: boolean\n displayOrder: number\n isSoldOut: boolean\n}\n\nexport interface TypologyTableType {\n typologyId: string\n price: number\n isSoldOut: boolean\n}\n","import { PESOS_EXCHANGE_KEY } from '@/services/modules/exchangeRate'\nimport i18n from '@/setup/i18n'\nimport { esMx, languages } from '@/utils/language'\nimport { computed } from '@vue/composition-api'\nimport { useExchangeRate } from './exchangeRate'\nimport { CurrencyViewModel } from '@/services/modules/currency'\n\nconst { data } = useExchangeRate({ exchangeKey: PESOS_EXCHANGE_KEY })\n\nexport const pesosExchangeRateAmount = computed(() => data.value[0]?.amount)\n\nexport const isDisplayMxCurrency = computed(() =>\n Boolean(i18n.locale === esMx.locale && pesosExchangeRateAmount.value)\n)\n\nexport function convertFromUsdToMxn(value: number) {\n return Math.ceil(value * pesosExchangeRateAmount.value)\n}\n\nexport function convertFromMxnToUsd(value: number) {\n return Math.ceil(value / pesosExchangeRateAmount.value)\n}\n\nexport function getLocalizedPrice(value: number | undefined) {\n return isDisplayMxCurrency.value && value ? convertFromUsdToMxn(value) : value\n}\n\nexport function getUsdPrice(value: number | undefined) {\n return isDisplayMxCurrency.value && value ? convertFromMxnToUsd(value) : value\n}\n\nexport interface UseCurrencyOptions {\n value: number | string\n locale?: string\n currency?: CurrencyViewModel\n}\n\nexport function useCurrency({\n value,\n locale = i18n.locale,\n currency,\n}: UseCurrencyOptions) {\n return computed(() => {\n const computedLocale = currency\n ? Object.values(languages).find(\n (language) => language.currencyCode === currency?.code\n )?.locale ?? locale\n : locale\n const shouldConvertToMexicanPeso =\n !currency &&\n Boolean(locale === esMx.locale && pesosExchangeRateAmount.value)\n let amount = typeof value === 'string' ? Number.parseFloat(value) : value\n const currencySuffix = shouldConvertToMexicanPeso\n ? 'MXN'\n : currency?.code || 'USD'\n\n if (shouldConvertToMexicanPeso) {\n amount = convertFromUsdToMxn(amount)\n }\n\n return `$${amount.toLocaleString(computedLocale, {\n minimumFractionDigits: 0,\n maximumFractionDigits: 2,\n })} ${currencySuffix}`\n })\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(controller.action('get'), {\n params,\n })\n },\n\n update(model: ExchangeUpdateModel) {\n return client.post(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","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\",staticClass:\"\\n grid\\n gap-6\\n sm:rounded-md sm:overflow-hidden\\n px-4\\n py-5\\n sm:p-6\\n bg-white\\n \",attrs:{\"novalidate\":\"\"},on:{\"submit\":function($event){$event.preventDefault();return handleSubmit(_vm.submit)},\"reset\":function($event){$event.preventDefault();return reset.apply(null, arguments)}}},[_c('BaseBox',{staticClass:\"grid gap-4\"},[_c('BaseBox',{staticClass:\"flex justify-end\"},[_c('BaseButton',{attrs:{\"variant\":\"solid\",\"tone\":\"tertiary\"},on:{\"click\":function($event){return _vm.enableEditMode()}}},[_c('BaseIcon',{attrs:{\"name\":\"edit\"}})],1)],1),_c('BaseTable',{attrs:{\"mode\":\"remote\",\"total-rows\":_vm.totalItems,\"is-loading\":_vm.isLoading,\"sort-options\":{\n enabled: false,\n },\"pagination-options\":{\n enabled: false,\n },\"rows\":_vm.rows,\"columns\":_vm.columns,\"style-class\":\"vgt-table striped\"},scopedSlots:_vm._u([{key:\"table-row\",fn:function(ref){\n var column = ref.column;\n var formattedRow = ref.formattedRow;\n var row = ref.row;\nreturn [(column.field === 'code')?[_c('BaseText',{staticClass:\"text-tertiary\"},[_vm._v(\" \"+_vm._s(row.code)+\" \")])]:(column.field === 'price')?[(!_vm.editMode)?[_c('BaseText',[_vm._v(\" \"+_vm._s(_vm.setCurrency(row.price))+\" \")])]:[_c('BaseBox',{staticClass:\"w-full md:w-1/2 mx-auto\"},[_c('ValidationProvider',{attrs:{\"name\":_vm.priceLabel,\"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\":\"\",\"tertiary-label\":_vm.setCurrency(_vm.model[row.originalIndex].price),\"html-for\":(\"price-\" + (row.code))}}),_c('BaseInputText',{attrs:{\"id\":(\"price-\" + (row.code)),\"type\":\"number\",\"min\":\"0\"},model:{value:(_vm.model[row.originalIndex].price),callback:function ($$v) {_vm.$set(_vm.model[row.originalIndex], \"price\", _vm._n($$v))},expression:\"model[row.originalIndex].price\"}}),_c('BaseFieldMessage',{attrs:{\"id\":(\"price-message-\" + (row.code)),\"message\":errors[0],\"tone\":\"critical\"}})]}}],null,true)})],1)]]:(column.field === 'isSoldOut')?[(!_vm.editMode)?[_c('BaseInputCheckbox',{attrs:{\"id\":(\"soldout-\" + (row.code)),\"disabled\":\"\"},model:{value:(_vm.rows[row.originalIndex].isSoldOut),callback:function ($$v) {_vm.$set(_vm.rows[row.originalIndex], \"isSoldOut\", $$v)},expression:\"rows[row.originalIndex].isSoldOut\"}})]:[_c('BaseInputCheckbox',{attrs:{\"id\":(\"soldout-\" + (row.code))},model:{value:(_vm.model[row.originalIndex].isSoldOut),callback:function ($$v) {_vm.$set(_vm.model[row.originalIndex], \"isSoldOut\", $$v)},expression:\"model[row.originalIndex].isSoldOut\"}})]]:[_vm._v(\" \"+_vm._s(formattedRow[column.field])+\" \")]]}}],null,true)}),(_vm.editMode)?_c('BaseBox',{staticClass:\"flex justify-end\"},[_c('BaseButton',{attrs:{\"loading\":_vm.isSubmitting,\"variant\":\"solid\",\"tone\":\"tertiary\",\"type\":\"submit\"},scopedSlots:_vm._u([{key:\"default\",fn:function(){return [_c('i18n',{attrs:{\"tag\":false,\"path\":'submitUpdate'}})]},proxy:true},{key:\"loading-text\",fn:function(){return [_c('i18n',{attrs:{\"tag\":false,\"path\":'submitUpdateButtonLoading'}})]},proxy:true}],null,true)})],1):_vm._e()],1)],1)]}}])})}\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\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 { useTypologies } from '@/composition/typologies'\nimport { typologyService } from '@/services/modules/typology'\nimport {\n TypologyTableType,\n TypologyViewModel,\n} from '@/services/modules/typology'\nimport i18n from '@/setup/i18n'\nimport { VueGoodTableColumn } from '@/setup/vue-good-table'\nimport { useCurrency } from '@/composition/currency'\nimport { enUs, esMx } from '@/utils/language'\nimport { ValidationObserver, ValidationProvider } from 'vee-validate'\nimport communique from '@/notification'\nimport { defineComponent, computed, ref } from '@vue/composition-api'\n\nexport default defineComponent({\n name: 'Typologies',\n\n components: {\n ValidationObserver,\n ValidationProvider,\n },\n\n setup() {\n const editMode = ref(false)\n\n const isSubmitting = ref(false)\n\n const form = ref(null)\n\n const model = ref([])\n\n const priceLabel = computed(() => i18n.t('price') as string)\n\n const setCurrency = (price: number) => {\n const priceUsd = useCurrency({\n value: price,\n locale: enUs.locale,\n }).value\n const priceMxn = useCurrency({\n value: price,\n locale: esMx.locale,\n }).value\n return `${priceUsd} (${priceMxn})`\n }\n\n const columns = computed[]>(() => [\n {\n label: i18n.t('code') as string,\n field: 'code',\n thClass: 'text-center',\n tdClass: 'text-center',\n },\n {\n label: i18n.t('description') as string,\n field: 'description',\n thClass: 'text-center',\n tdClass: 'text-center',\n },\n {\n label: i18n.t('price') as string,\n field: 'price',\n thClass: 'text-center',\n tdClass: 'text-center',\n },\n {\n label: i18n.t('soldOut') as string,\n field: 'isSoldOut',\n thClass: 'text-center',\n tdClass: 'text-center',\n },\n ])\n\n const {\n data: rows,\n isLoading,\n totalItems,\n error,\n } = useTypologies({\n pageNumber: 1,\n rowsPerPage: -1,\n })\n\n function enableEditMode() {\n editMode.value = true\n\n rows.value.forEach((row) => {\n model.value.push({\n typologyId: row.typologyId,\n price: row.price,\n isSoldOut: row.isSoldOut,\n })\n })\n }\n\n async function submit() {\n const typologiesToUpdate: TypologyTableType[] = []\n\n rows.value.forEach((row, index) => {\n if (\n row.price !== model.value[index].price ||\n row.isSoldOut !== model.value[index].isSoldOut\n )\n typologiesToUpdate.push(model.value[index])\n })\n\n if (typologiesToUpdate.length === 0) return\n\n try {\n isSubmitting.value = true\n\n await typologyService.update({ typologyTableType: model.value })\n\n communique.dispatch({\n variant: 'success',\n message: i18n.t('typologyUpdateSuccess') as string,\n })\n\n typologiesToUpdate.forEach((t) => {\n let idx = rows.value.findIndex((el) => el.typologyId === t.typologyId)\n if (idx !== -1) {\n rows.value[idx].price = t.price\n rows.value[idx].isSoldOut = t.isSoldOut\n }\n })\n\n editMode.value = false\n } catch (error) {\n communique.dispatch({\n variant: 'error',\n message: i18n.t('typologyUpdateError') as string,\n })\n } finally {\n isSubmitting.value = false\n }\n }\n\n return {\n rows,\n isLoading,\n totalItems,\n error,\n columns,\n editMode,\n enableEditMode,\n setCurrency,\n submit,\n model,\n isSubmitting,\n priceLabel,\n form,\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!./Typologies.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!./Typologies.vue?vue&type=script&lang=ts&\"","import { render, staticRenderFns } from \"./Typologies.vue?vue&type=template&id=2ed0564c&\"\nimport script from \"./Typologies.vue?vue&type=script&lang=ts&\"\nexport * from \"./Typologies.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 \"./Typologies.vue?vue&type=custom&index=0&blockType=i18n&lang=json\"\nif (typeof block0 === 'function') block0(component)\n\nexport default component.exports","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(() => ({\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(\n getKey: WatchSource,\n fetcher: (...args: any) => Promise>\n) {\n const data = ref([]) as Ref\n const isLoading = ref(false)\n const error = ref(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","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!./Typologies.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!./Typologies.vue?vue&type=custom&index=0&blockType=i18n&lang=json\""],"sourceRoot":""}