@odynn/awayz-core 0.9.21 → 0.9.23
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,6 +1,6 @@
|
|
|
1
1
|
import { useQuery as n, useMutation as s } from "@tanstack/react-query";
|
|
2
2
|
import "../../arrayExtensions-DlcBOj5a.js";
|
|
3
|
-
import { E as a, d as
|
|
3
|
+
import { E as a, d as m } from "../../noRetryInstance-DKhe8ju0.js";
|
|
4
4
|
import "react";
|
|
5
5
|
import "react/jsx-runtime";
|
|
6
6
|
import "react-i18next";
|
|
@@ -11,25 +11,25 @@ import { awayzClient as i } from "../../configs/awayzClient.js";
|
|
|
11
11
|
/* empty css */
|
|
12
12
|
/* empty css */
|
|
13
13
|
import "../../index-Cv-wvFlM.js";
|
|
14
|
-
import { useAwayzContext as
|
|
14
|
+
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
|
|
19
|
-
const { user:
|
|
18
|
+
const x = () => {
|
|
19
|
+
const { user: e } = c(), { data: t } = n({
|
|
20
20
|
queryKey: [a.PROGRAMS],
|
|
21
21
|
queryFn: o.getAwards,
|
|
22
22
|
placeholderData: []
|
|
23
|
-
}), { data:
|
|
24
|
-
queryKey: [a.USER_PROGRAMS,
|
|
25
|
-
queryFn: () =>
|
|
23
|
+
}), { data: l } = n({
|
|
24
|
+
queryKey: [a.USER_PROGRAMS, e == null ? void 0 : e.id],
|
|
25
|
+
queryFn: () => e != null && e.id ? o.getUserAwards(e.id) : [],
|
|
26
26
|
placeholderData: [],
|
|
27
|
-
enabled: !!(
|
|
27
|
+
enabled: !!(e != null && e.id)
|
|
28
28
|
}), { data: y } = n({
|
|
29
|
-
queryKey: [a.LINKED_USER_PROGRAMS,
|
|
30
|
-
queryFn: () =>
|
|
29
|
+
queryKey: [a.LINKED_USER_PROGRAMS, e == null ? void 0 : e.id],
|
|
30
|
+
queryFn: () => e != null && e.id ? o.getLinkedUserAwards(e.id) : [],
|
|
31
31
|
placeholderData: [],
|
|
32
|
-
enabled: !!(
|
|
32
|
+
enabled: !!(e != null && e.id)
|
|
33
33
|
}), { data: A } = n({
|
|
34
34
|
queryKey: [a.BANKS],
|
|
35
35
|
queryFn: o.getBanks,
|
|
@@ -42,55 +42,55 @@ const T = () => {
|
|
|
42
42
|
queryKey: [a.USER_CARDS],
|
|
43
43
|
queryFn: o.getUserCards,
|
|
44
44
|
placeholderData: []
|
|
45
|
-
}), { featureFlags: R, featureFlagsLoaded: S } =
|
|
45
|
+
}), { featureFlags: R, featureFlagsLoaded: S, isAuthenticated: p } = c(), { data: C } = n({
|
|
46
46
|
queryKey: [a.POINTS_AS_CASH],
|
|
47
47
|
queryFn: o.getPointsAsCash,
|
|
48
48
|
placeholderData: { availablePoints: 0, valuePerPoint: 0, currency: "" },
|
|
49
|
-
enabled: S && R.usePointsAsCashFeature
|
|
50
|
-
}), { mutate:
|
|
51
|
-
mutationFn: async (
|
|
52
|
-
const { mainProgram:
|
|
53
|
-
await o.addAwardProgram(
|
|
49
|
+
enabled: S && R.usePointsAsCashFeature && p
|
|
50
|
+
}), { mutate: E } = s({
|
|
51
|
+
mutationFn: async (r) => {
|
|
52
|
+
const { mainProgram: u, awardsAmount: d } = typeof r == "string" ? { mainProgram: r, awardsAmount: 0 } : r;
|
|
53
|
+
await o.addAwardProgram(u, d);
|
|
54
54
|
},
|
|
55
55
|
onSuccess: () => {
|
|
56
56
|
i.invalidateQueries({
|
|
57
57
|
queryKey: [a.LINKED_USER_PROGRAMS]
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
|
-
}), { mutate:
|
|
61
|
-
mutationFn: async (
|
|
62
|
-
await o.removeAwardProgram(
|
|
60
|
+
}), { mutate: K } = s({
|
|
61
|
+
mutationFn: async (r) => {
|
|
62
|
+
await o.removeAwardProgram(r);
|
|
63
63
|
},
|
|
64
64
|
onSuccess: () => {
|
|
65
65
|
i.invalidateQueries({
|
|
66
66
|
queryKey: [a.LINKED_USER_PROGRAMS]
|
|
67
67
|
});
|
|
68
68
|
}
|
|
69
|
-
}), { mutateAsync:
|
|
70
|
-
mutationFn: async ({ mainProgram:
|
|
71
|
-
const d = t == null ? void 0 : t.find((
|
|
69
|
+
}), { mutateAsync: f } = s({
|
|
70
|
+
mutationFn: async ({ mainProgram: r, awardsAmount: u }) => {
|
|
71
|
+
const d = t == null ? void 0 : t.find((h) => h.mainProgram === r);
|
|
72
72
|
if (!d)
|
|
73
73
|
throw new Error("Program not found");
|
|
74
|
-
return o.setAwardPoints(d.mainProgram,
|
|
74
|
+
return o.setAwardPoints(d.mainProgram, u);
|
|
75
75
|
},
|
|
76
76
|
onSuccess: () => {
|
|
77
77
|
[
|
|
78
78
|
a.LINKED_USER_PROGRAMS,
|
|
79
79
|
a.USER_PROGRAMS,
|
|
80
80
|
a.PROGRAMS
|
|
81
|
-
].forEach((
|
|
82
|
-
i.invalidateQueries({ queryKey: [
|
|
81
|
+
].forEach((r) => {
|
|
82
|
+
i.invalidateQueries({ queryKey: [r] });
|
|
83
83
|
});
|
|
84
84
|
}
|
|
85
|
-
}), { mutateAsync:
|
|
86
|
-
mutationFn: async (
|
|
85
|
+
}), { mutateAsync: q } = s({
|
|
86
|
+
mutationFn: async (r) => o.addCardsToWallet(r),
|
|
87
87
|
onSuccess: () => {
|
|
88
88
|
i.invalidateQueries({
|
|
89
89
|
queryKey: [a.USER_CARDS]
|
|
90
90
|
});
|
|
91
91
|
}
|
|
92
|
-
}), { mutateAsync:
|
|
93
|
-
mutationFn: async (
|
|
92
|
+
}), { mutateAsync: F } = s({
|
|
93
|
+
mutationFn: async (r) => o.removeCardsFromWallet(r),
|
|
94
94
|
onSuccess: () => {
|
|
95
95
|
i.invalidateQueries({
|
|
96
96
|
queryKey: [a.USER_CARDS]
|
|
@@ -100,27 +100,27 @@ const T = () => {
|
|
|
100
100
|
return {
|
|
101
101
|
// Program Management
|
|
102
102
|
allPrograms: t || [],
|
|
103
|
-
userPrograms:
|
|
103
|
+
userPrograms: l || [],
|
|
104
104
|
linkedUserPrograms: y || [],
|
|
105
105
|
hotelPrograms: (t == null ? void 0 : t.filter(
|
|
106
|
-
(
|
|
106
|
+
(r) => r.category.includes(m.HOTEL)
|
|
107
107
|
)) || [],
|
|
108
108
|
airlinePrograms: (t == null ? void 0 : t.filter(
|
|
109
|
-
(
|
|
109
|
+
(r) => r.category.includes(m.AIRLINE)
|
|
110
110
|
)) || [],
|
|
111
111
|
bankPrograms: (t == null ? void 0 : t.filter(
|
|
112
|
-
(
|
|
112
|
+
(r) => r.category.includes(m.BANK)
|
|
113
113
|
)) || [],
|
|
114
|
-
updatePoints:
|
|
115
|
-
addAwardProgram:
|
|
116
|
-
removeAwardProgram:
|
|
114
|
+
updatePoints: f,
|
|
115
|
+
addAwardProgram: E,
|
|
116
|
+
removeAwardProgram: K,
|
|
117
117
|
// Card Management
|
|
118
118
|
banks: A || [],
|
|
119
119
|
allCards: P || [],
|
|
120
120
|
userCards: g || [],
|
|
121
|
-
addCards:
|
|
122
|
-
removeCards:
|
|
123
|
-
pointsAsCash:
|
|
121
|
+
addCards: q,
|
|
122
|
+
removeCards: F,
|
|
123
|
+
pointsAsCash: C || {
|
|
124
124
|
availablePoints: 0,
|
|
125
125
|
valuePerPoint: 0,
|
|
126
126
|
currency: ""
|
|
@@ -128,5 +128,5 @@ const T = () => {
|
|
|
128
128
|
};
|
|
129
129
|
};
|
|
130
130
|
export {
|
|
131
|
-
|
|
131
|
+
x as useWallet
|
|
132
132
|
};
|