@odynn/awayz-core 0.10.8 → 0.10.10

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.
@@ -9,7 +9,7 @@ import "react-i18next";
9
9
  import '../../assets/_styles4.css';import '../../assets/_styles2.css';import '../../assets/_styles.css';import '../../assets/_styles3.css';/* empty css */
10
10
  /* empty css */
11
11
  /* empty css */
12
- import { EInvalidAmountDisplayOption as s, EToolTipPosition as D } from "./CashValueTypes.js";
12
+ import { EInvalidAmountDisplayOption as t, EToolTipPosition as D } from "./CashValueTypes.js";
13
13
  import { useAwayzContext as I } from "../../hooks/useAwayzContext.js";
14
14
  import "../../configs/awayzClient.js";
15
15
  /* empty css */
@@ -20,48 +20,48 @@ const x = 1e3 * 60 * 60, k = ({
20
20
  amount: i,
21
21
  currency: e,
22
22
  position: v = D.RIGHT,
23
- zeroDisplayOption: A = s.NA,
23
+ zeroDisplayOption: A = t.NA,
24
24
  customDisplay: y,
25
25
  decimalPlaces: p = 2,
26
26
  showConversion: g = !1,
27
- showOriginal: E = !1
27
+ showOriginal: E = !0
28
28
  }) => {
29
29
  var h, C;
30
- const { user: o } = I(), n = ((h = o == null ? void 0 : o.preferences) == null ? void 0 : h.currency) ?? ((C = o == null ? void 0 : o.userRegion) == null ? void 0 : C.currency), t = n !== e, { data: c, isPending: d } = R({
30
+ const { user: o } = I(), n = ((h = o == null ? void 0 : o.preferences) == null ? void 0 : h.currency) ?? ((C = o == null ? void 0 : o.userRegion) == null ? void 0 : C.currency), s = n !== e, { data: c, isPending: d } = R({
31
31
  queryKey: [S.CONVERT_CURRENCY, e, n],
32
32
  queryFn: () => M.convertCurrency({
33
33
  baseCurrency: e,
34
34
  targetCurrency: n
35
35
  }),
36
- enabled: t && !!e && !!i,
36
+ enabled: s && !!e && !!i,
37
37
  staleTime: x
38
38
  }), a = T(() => {
39
39
  if (!o)
40
40
  return null;
41
41
  let u = typeof i == "string" ? parseFloat(i) : i;
42
- if (t) {
42
+ if (s) {
43
43
  if (d || !c) return null;
44
44
  u = u * c;
45
45
  }
46
46
  return u;
47
- }, [i, o, d, t, c]);
47
+ }, [i, o, d, s, c]);
48
48
  if (E)
49
49
  return /* @__PURE__ */ r("span", { className: "currency-conversion", children: m(i, e, p) });
50
- if (d && t)
50
+ if (d && s)
51
51
  return /* @__PURE__ */ r("span", { className: "currency-conversion loading", children: i });
52
52
  if (!n || !a || a < 0)
53
53
  switch (A) {
54
- case s.NA:
54
+ case t.NA:
55
55
  return /* @__PURE__ */ r("span", { children: "N/A" });
56
- case s.HIDDEN:
56
+ case t.HIDDEN:
57
57
  return /* @__PURE__ */ r("span", { className: "hidden", children: "N/A" });
58
- case s.DISPLAY_AS_ZERO:
58
+ case t.DISPLAY_AS_ZERO:
59
59
  return /* @__PURE__ */ r("span", { children: "0" });
60
- case s.DISPLAY_AS_ZERO_WITH_CURRENCY:
60
+ case t.DISPLAY_AS_ZERO_WITH_CURRENCY:
61
61
  return /* @__PURE__ */ r("span", { children: N(0, n ?? e) });
62
- case s.DISPLAY_AS_ZERO_WITH_CURRENCY_NO_DECIMAL:
62
+ case t.DISPLAY_AS_ZERO_WITH_CURRENCY_NO_DECIMAL:
63
63
  return /* @__PURE__ */ r("span", { children: _(0, n ?? e) });
64
- case s.CUSTOM:
64
+ case t.CUSTOM:
65
65
  return /* @__PURE__ */ r("span", { children: a == 0 ? y : "N/A" });
66
66
  default:
67
67
  return /* @__PURE__ */ r("span", { children: "N/A" });
@@ -72,7 +72,7 @@ const x = 1e3 * 60 * 60, k = ({
72
72
  n,
73
73
  p
74
74
  ),
75
- t && g && /* @__PURE__ */ r(
75
+ s && g && /* @__PURE__ */ r(
76
76
  O,
77
77
  {
78
78
  trigger: /* @__PURE__ */ r("sup", { children: /* @__PURE__ */ r(f, {}) }),
@@ -15,7 +15,11 @@ import { useAwayzContext as c } from "../useAwayzContext.js";
15
15
  /* empty css */
16
16
  import "../../context/AwayzContext.js";
17
17
  import { WalletService as o } from "../../services/wallet/WalletService.js";
18
- const z = () => {
18
+ const U = {
19
+ availablePoints: 0,
20
+ valuePerPoint: 0,
21
+ currency: ""
22
+ }, z = () => {
19
23
  const { user: r } = c(), { data: t } = n({
20
24
  queryKey: [a.PROGRAMS],
21
25
  queryFn: o.getAwards,
@@ -34,18 +38,22 @@ const z = () => {
34
38
  queryKey: [a.BANKS],
35
39
  queryFn: o.getBanks,
36
40
  placeholderData: []
37
- }), { data: g } = n({
41
+ }), { data: S } = n({
38
42
  queryKey: [a.CARDS],
39
43
  queryFn: o.getCards,
40
44
  placeholderData: []
41
- }), { data: P } = n({
45
+ }), { data: g } = n({
42
46
  queryKey: [a.USER_CARDS],
43
47
  queryFn: o.getUserCards,
44
48
  placeholderData: []
45
- }), { featureFlags: R, featureFlagsLoaded: S, isAuthenticated: p } = c(), { data: C, isFetching: E } = n({
49
+ }), { featureFlags: P, featureFlagsLoaded: R, isAuthenticated: p } = c(), {
50
+ data: C = U,
51
+ isFetching: E
52
+ } = n({
46
53
  queryKey: [a.POINTS_AS_CASH],
47
54
  queryFn: o.getPointsAsCash,
48
- enabled: S && R.usePointsAsCashFeature && p
55
+ enabled: R && P.usePointsAsCashFeature && p,
56
+ retry: !1
49
57
  }), { mutate: K } = s({
50
58
  mutationFn: async (e) => {
51
59
  const { mainProgram: m, awardsAmount: d } = typeof e == "string" ? { mainProgram: e, awardsAmount: 0 } : e;
@@ -65,9 +73,9 @@ const z = () => {
65
73
  queryKey: [a.LINKED_USER_PROGRAMS]
66
74
  });
67
75
  }
68
- }), { mutateAsync: q } = s({
76
+ }), { mutateAsync: F } = s({
69
77
  mutationFn: async ({ mainProgram: e, awardsAmount: m }) => {
70
- const d = t == null ? void 0 : t.find((_) => _.mainProgram === e);
78
+ const d = t == null ? void 0 : t.find((h) => h.mainProgram === e);
71
79
  if (!d)
72
80
  throw new Error("Program not found");
73
81
  return o.setAwardPoints(d.mainProgram, m);
@@ -81,14 +89,14 @@ const z = () => {
81
89
  i.invalidateQueries({ queryKey: [e] });
82
90
  });
83
91
  }
84
- }), { mutateAsync: F } = s({
92
+ }), { mutateAsync: _ } = s({
85
93
  mutationFn: async (e) => o.addCardsToWallet(e),
86
94
  onSuccess: () => {
87
95
  i.invalidateQueries({
88
96
  queryKey: [a.USER_CARDS]
89
97
  });
90
98
  }
91
- }), { mutateAsync: h } = s({
99
+ }), { mutateAsync: q } = s({
92
100
  mutationFn: async (e) => o.removeCardsFromWallet(e),
93
101
  onSuccess: () => {
94
102
  i.invalidateQueries({
@@ -110,20 +118,16 @@ const z = () => {
110
118
  bankPrograms: (t == null ? void 0 : t.filter(
111
119
  (e) => e.category.includes(u.BANK)
112
120
  )) || [],
113
- updatePoints: q,
121
+ updatePoints: F,
114
122
  addAwardProgram: K,
115
123
  removeAwardProgram: f,
116
124
  // Card Management
117
125
  banks: A || [],
118
- allCards: g || [],
119
- userCards: P || [],
120
- addCards: F,
121
- removeCards: h,
122
- pointsAsCash: C || {
123
- availablePoints: 0,
124
- valuePerPoint: 0,
125
- currency: ""
126
- },
126
+ allCards: S || [],
127
+ userCards: g || [],
128
+ addCards: _,
129
+ removeCards: q,
130
+ pointsAsCash: C,
127
131
  pointsAsCashLoading: E
128
132
  };
129
133
  };
@@ -1,6 +1,6 @@
1
- var o = Object.defineProperty;
2
- var i = (d, a, t) => a in d ? o(d, a, { enumerable: !0, configurable: !0, writable: !0, value: t }) : d[a] = t;
3
- var r = (d, a, t) => i(d, typeof a != "symbol" ? a + "" : a, t);
1
+ var d = Object.defineProperty;
2
+ var i = (o, a, t) => a in o ? d(o, a, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[a] = t;
3
+ var r = (o, a, t) => i(o, typeof a != "symbol" ? a + "" : a, t);
4
4
  import "../../arrayExtensions-DlcBOj5a.js";
5
5
  import { c as e, b as c, g as A } from "../../noRetryInstance-C4bqpBc7.js";
6
6
  import "react";
@@ -102,12 +102,20 @@ class u {
102
102
  return t;
103
103
  });
104
104
  r(this, "getPointsAsCash", async () => {
105
- const { data: a } = await A.get(s.POINTS_AS_CASH);
106
- return a.success ? c(a.data) : { availablePoints: 0, valuePerPoint: 0, currency: "" };
105
+ try {
106
+ const { data: a } = await A.get(
107
+ s.POINTS_AS_CASH
108
+ );
109
+ if (a.success)
110
+ return c(a.data);
111
+ throw new Error("Failed to fetch points as cash value");
112
+ } catch {
113
+ return { availablePoints: 0, valuePerPoint: 0, currency: "" };
114
+ }
107
115
  });
108
116
  }
109
117
  }
110
- const l = new u();
118
+ const R = new u();
111
119
  export {
112
- l as WalletService
120
+ R as WalletService
113
121
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@odynn/awayz-core",
3
- "version": "0.10.8",
3
+ "version": "0.10.10",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"