ingeniuscliq-core 0.5.71 → 0.5.72

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,9 @@
1
1
  import { AxiosInstance } from 'axios';
2
2
  export declare let api: AxiosInstance;
3
+ /** Returns the stored currency short_name, or null if none has been set. */
4
+ export declare const getCurrency: () => string | null;
5
+ /** Persists the selected currency short_name. */
6
+ export declare const setCurrencyStorage: (shortName: string) => void;
3
7
  /**
4
8
  * Returns the existing guest token from localStorage or generates and stores a new one.
5
9
  */
@@ -1 +1 @@
1
- {"version":3,"file":"axiosGlobal.d.ts","sourceRoot":"","sources":["../../src/helpers/axiosGlobal.ts"],"names":[],"mappings":"AAAA,OAAc,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAG7C,eAAO,IAAI,GAAG,EAAE,aAKd,CAAC;AAKH;;GAEG;AACH,eAAO,MAAM,aAAa,QAAO,MAOhC,CAAC;AAEF,2EAA2E;AAC3E,eAAO,MAAM,YAAY,QAAO,MAAM,GAAG,IACH,CAAC;AAEvC,iEAAiE;AACjE,eAAO,MAAM,YAAY,GAAI,OAAO,MAAM,KAAG,IACA,CAAC;AAE9C,4DAA4D;AAC5D,eAAO,MAAM,eAAe,QAAO,IACM,CAAC;AAE1C;;GAEG;AACH,eAAO,MAAM,gBAAgB,GAAI,SAAS,MAAM,KAAG,IAiBlD,CAAC;AAEF,eAAe,GAAG,CAAC"}
1
+ {"version":3,"file":"axiosGlobal.d.ts","sourceRoot":"","sources":["../../src/helpers/axiosGlobal.ts"],"names":[],"mappings":"AAAA,OAAc,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAG7C,eAAO,IAAI,GAAG,EAAE,aAKd,CAAC;AAMH,4EAA4E;AAC5E,eAAO,MAAM,WAAW,QAAO,MAAM,GAAG,IACJ,CAAC;AAErC,iDAAiD;AACjD,eAAO,MAAM,kBAAkB,GAAI,WAAW,MAAM,KAAG,IACR,CAAC;AAEhD;;GAEG;AACH,eAAO,MAAM,aAAa,QAAO,MAOhC,CAAC;AAEF,2EAA2E;AAC3E,eAAO,MAAM,YAAY,QAAO,MAAM,GAAG,IACH,CAAC;AAEvC,iEAAiE;AACjE,eAAO,MAAM,YAAY,GAAI,OAAO,MAAM,KAAG,IACA,CAAC;AAE9C,4DAA4D;AAC5D,eAAO,MAAM,eAAe,QAAO,IACM,CAAC;AAE1C;;GAEG;AACH,eAAO,MAAM,gBAAgB,GAAI,SAAS,MAAM,KAAG,IAsBlD,CAAC;AAEF,eAAe,GAAG,CAAC"}
@@ -8,6 +8,9 @@ let api = axios.create({
8
8
  });
9
9
  const GUEST_TOKEN_KEY = "click_guest_token";
10
10
  const AUTH_TOKEN_KEY = "click_auth_token";
11
+ const CURRENCY_KEY = "click_currency";
12
+ const getCurrency = () => localStorage.getItem(CURRENCY_KEY);
13
+ const setCurrencyStorage = (shortName) => localStorage.setItem(CURRENCY_KEY, shortName);
11
14
  const getGuestToken = () => {
12
15
  let token = localStorage.getItem(GUEST_TOKEN_KEY);
13
16
  if (!token) {
@@ -30,10 +33,14 @@ const initAxiosConfigs = (baseURL) => {
30
33
  } else {
31
34
  config.headers["X-Guest-Token"] = getGuestToken();
32
35
  }
36
+ const currency = getCurrency();
37
+ if (currency) {
38
+ config.headers["X-Currency"] = currency;
39
+ }
33
40
  return config;
34
41
  },
35
42
  (error) => Promise.reject(error)
36
43
  );
37
44
  };
38
45
 
39
- export { api, api as default, getAuthToken, getGuestToken, initAxiosConfigs, removeAuthToken, setAuthToken };
46
+ export { api, api as default, getAuthToken, getCurrency, getGuestToken, initAxiosConfigs, removeAuthToken, setAuthToken, setCurrencyStorage };
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  export { CoreBuilder } from './classes/CoreBuilder.js';
2
2
  export { CoreBaseBuilder } from './classes/CoreBaseBuilder.js';
3
- export { api, getAuthToken, getGuestToken, initAxiosConfigs, removeAuthToken, setAuthToken } from './helpers/axiosGlobal.js';
3
+ export { api, getAuthToken, getCurrency, getGuestToken, initAxiosConfigs, removeAuthToken, setAuthToken, setCurrencyStorage } from './helpers/axiosGlobal.js';
4
4
  export { capitalizeFirstLetter } from './helpers/strings.js';
5
5
  export { getImageUrlByTenant } from './helpers/image.js';
6
6
  export { formatSchedule, formatScheduleArray, getTodaySchedule, isStoreOpen } from './helpers/schedule.js';
@@ -1 +1 @@
1
- {"version":3,"file":"CoreCustomizationBuilder.d.ts","sourceRoot":"","sources":["../../../../src/modules/CoreCustomization/classes/CoreCustomizationBuilder.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,4BAA4B,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAGnE,qBAAa,wBAAwB,CACnC,MAAM,SAAS,sBAAsB,GAAG,sBAAsB,CAC9D,SAAQ,eAAe,CAAC,MAAM,CAAC;IAC/B,SAAS,CAAC,oBAAoB,EAAE,4BAA4B,CAAC;IAC7D,SAAS,CAAC,YAAY,EAOjB,IAAI,CAAC,MAAM,EAAE,UAAU,GAAG,YAAY,GAAG,QAAQ,GAAG,UAAU,GAAG,SAAS,GAAG,OAAO,CAAC,CAAC;gBAGzF,OAAO,GAAE,4BAAiE,EAC1E,YAAY,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC;IAShC,SAAS,CAAC,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,GAAG,MAAM;IA8G5C,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiBb"}
1
+ {"version":3,"file":"CoreCustomizationBuilder.d.ts","sourceRoot":"","sources":["../../../../src/modules/CoreCustomization/classes/CoreCustomizationBuilder.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,4BAA4B,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAInE,qBAAa,wBAAwB,CACnC,MAAM,SAAS,sBAAsB,GAAG,sBAAsB,CAC9D,SAAQ,eAAe,CAAC,MAAM,CAAC;IAC/B,SAAS,CAAC,oBAAoB,EAAE,4BAA4B,CAAC;IAC7D,SAAS,CAAC,YAAY,EAOjB,IAAI,CAAC,MAAM,EAAE,UAAU,GAAG,YAAY,GAAG,QAAQ,GAAG,UAAU,GAAG,SAAS,GAAG,OAAO,CAAC,CAAC;gBAGzF,OAAO,GAAE,4BAAiE,EAC1E,YAAY,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC;IAShC,SAAS,CAAC,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,GAAG,MAAM;IA+G5C,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiBb"}
@@ -2,6 +2,7 @@ import { create } from 'zustand';
2
2
  import { persist } from '../../../node_modules/zustand/esm/middleware.js';
3
3
  import { CoreCustomizationBaseService } from '../services/base.js';
4
4
  import { CoreBaseBuilder } from '../../../classes/CoreBaseBuilder.js';
5
+ import { setCurrencyStorage } from '../../../helpers/axiosGlobal.js';
5
6
 
6
7
  class CoreCustomizationBuilder extends CoreBaseBuilder {
7
8
  customizationService;
@@ -78,6 +79,7 @@ class CoreCustomizationBuilder extends CoreBaseBuilder {
78
79
  },
79
80
  changeCoin: async (currency, actions) => {
80
81
  try {
82
+ setCurrencyStorage(currency);
81
83
  const response = await this.customizationService.changeCoin(currency);
82
84
  const updatedSettings = await this.customizationService.fetchSettings();
83
85
  const settings = updatedSettings.data.data.configuration;
@@ -1 +1 @@
1
- {"version":3,"file":"currencyStore.d.ts","sourceRoot":"","sources":["../../src/stores/currencyStore.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAG/E,UAAU,aAAa;IACnB,QAAQ,EAAE,mBAAmB,CAAC;IAC9B,WAAW,EAAE,CAAC,QAAQ,EAAE,mBAAmB,KAAK,IAAI,CAAC;IACrD,kBAAkB,EAAE,MAAM,IAAI,CAAC;IAC/B,WAAW,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;CAC1C;AAUD,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;EAkC5B,CAAC"}
1
+ {"version":3,"file":"currencyStore.d.ts","sourceRoot":"","sources":["../../src/stores/currencyStore.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAI/E,UAAU,aAAa;IACnB,QAAQ,EAAE,mBAAmB,CAAC;IAC9B,WAAW,EAAE,CAAC,QAAQ,EAAE,mBAAmB,KAAK,IAAI,CAAC;IACrD,kBAAkB,EAAE,MAAM,IAAI,CAAC;IAC/B,WAAW,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;CAC1C;AAUD,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;EAsC5B,CAAC"}
@@ -1,6 +1,7 @@
1
1
  import { create } from 'zustand';
2
2
  import { persist } from '../node_modules/zustand/esm/middleware.js';
3
3
  import { useCustomizationStore } from './customizationStore.js';
4
+ import { setCurrencyStorage } from '../helpers/axiosGlobal.js';
4
5
 
5
6
  const defaultCurrency = {
6
7
  short_name: "USD",
@@ -13,11 +14,15 @@ const useCurrencyStore = create()(
13
14
  persist(
14
15
  (set, get) => ({
15
16
  currency: defaultCurrency,
16
- setCurrency: (currency) => set({ currency }),
17
+ setCurrency: (currency) => {
18
+ setCurrencyStorage(currency.short_name);
19
+ set({ currency });
20
+ },
17
21
  initializeCurrency: () => {
18
22
  const { settings } = useCustomizationStore();
19
23
  const currentCoin = settings?.current_coin || settings?.base_coin;
20
24
  if (currentCoin) {
25
+ setCurrencyStorage(currentCoin.short_name);
21
26
  set({ currency: currentCoin });
22
27
  }
23
28
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ingeniuscliq-core",
3
- "version": "0.5.71",
3
+ "version": "0.5.72",
4
4
  "description": "IngeniusCliq Core UI y lógica compartida",
5
5
  "license": "MIT",
6
6
  "type": "module",