@odynn/awayz-core 0.10.7 → 0.10.9
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.
|
@@ -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
|
|
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:
|
|
41
|
+
}), { data: S } = n({
|
|
38
42
|
queryKey: [a.CARDS],
|
|
39
43
|
queryFn: o.getCards,
|
|
40
44
|
placeholderData: []
|
|
41
|
-
}), { data:
|
|
45
|
+
}), { data: g } = n({
|
|
42
46
|
queryKey: [a.USER_CARDS],
|
|
43
47
|
queryFn: o.getUserCards,
|
|
44
48
|
placeholderData: []
|
|
45
|
-
}), { featureFlags:
|
|
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:
|
|
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:
|
|
76
|
+
}), { mutateAsync: F } = s({
|
|
69
77
|
mutationFn: async ({ mainProgram: e, awardsAmount: m }) => {
|
|
70
|
-
const d = t == null ? void 0 : t.find((
|
|
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:
|
|
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:
|
|
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:
|
|
121
|
+
updatePoints: F,
|
|
114
122
|
addAwardProgram: K,
|
|
115
123
|
removeAwardProgram: f,
|
|
116
124
|
// Card Management
|
|
117
125
|
banks: A || [],
|
|
118
|
-
allCards:
|
|
119
|
-
userCards:
|
|
120
|
-
addCards:
|
|
121
|
-
removeCards:
|
|
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
|
|
2
|
-
var i = (
|
|
3
|
-
var r = (
|
|
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
|
-
|
|
106
|
-
|
|
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
|
|
118
|
+
const R = new u();
|
|
111
119
|
export {
|
|
112
|
-
|
|
120
|
+
R as WalletService
|
|
113
121
|
};
|