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