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