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