@odynn/awayz-core 0.6.38 → 0.6.40
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,9 +1,9 @@
|
|
|
1
|
-
import { useQuery as n, useMutation as
|
|
1
|
+
import { useQuery as n, useMutation as s } from "@tanstack/react-query";
|
|
2
2
|
import "../../arrayExtensions-DlcBOj5a.js";
|
|
3
|
-
import { E as a, b as
|
|
3
|
+
import { E as a, b as m } from "../../AccountService-DHR8seWS.js";
|
|
4
4
|
import "react";
|
|
5
5
|
import "react/jsx-runtime";
|
|
6
|
-
import { awayzClient as
|
|
6
|
+
import { awayzClient as i } from "../../configs/awayzClient.js";
|
|
7
7
|
import '../../assets/_styles4.css';import '../../assets/_styles3.css';import '../../assets/_styles2.css';import '../../assets/_styles.css';import '../../assets/_styles5.css';/* empty css */
|
|
8
8
|
/* empty css */
|
|
9
9
|
import "react-i18next";
|
|
@@ -15,20 +15,20 @@ import "../../context/AwayzContext.js";
|
|
|
15
15
|
import "../../services/noRetryInstance.js";
|
|
16
16
|
import { WalletService as o } from "../../services/wallet/WalletService.js";
|
|
17
17
|
const B = () => {
|
|
18
|
-
const { user:
|
|
18
|
+
const { user: r } = l(), { data: t } = n({
|
|
19
19
|
queryKey: [a.PROGRAMS],
|
|
20
20
|
queryFn: o.getAwards,
|
|
21
21
|
placeholderData: []
|
|
22
22
|
}), { data: c } = n({
|
|
23
|
-
queryKey: [a.USER_PROGRAMS,
|
|
24
|
-
queryFn: () =>
|
|
23
|
+
queryKey: [a.USER_PROGRAMS, r == null ? void 0 : r.id],
|
|
24
|
+
queryFn: () => r != null && r.id ? o.getUserAwards(r.id) : [],
|
|
25
25
|
placeholderData: [],
|
|
26
|
-
enabled: !!(
|
|
26
|
+
enabled: !!(r != null && r.id)
|
|
27
27
|
}), { data: y } = n({
|
|
28
|
-
queryKey: [a.LINKED_USER_PROGRAMS,
|
|
29
|
-
queryFn: () =>
|
|
28
|
+
queryKey: [a.LINKED_USER_PROGRAMS, r == null ? void 0 : r.id],
|
|
29
|
+
queryFn: () => r != null && r.id ? o.getLinkedUserAwards(r.id) : [],
|
|
30
30
|
placeholderData: [],
|
|
31
|
-
enabled: !!(
|
|
31
|
+
enabled: !!(r != null && r.id)
|
|
32
32
|
}), { data: A } = n({
|
|
33
33
|
queryKey: [a.BANKS],
|
|
34
34
|
queryFn: o.getBanks,
|
|
@@ -46,56 +46,52 @@ const B = () => {
|
|
|
46
46
|
queryFn: o.getPointsAsCash,
|
|
47
47
|
placeholderData: { availablePoints: 0, valuePerPoint: 0, currency: "" },
|
|
48
48
|
enabled: S && R.usePointsAsCashFeature
|
|
49
|
-
}), { mutate: C } =
|
|
50
|
-
mutationFn: async (
|
|
51
|
-
const { mainProgram:
|
|
52
|
-
await o.addAwardProgram(
|
|
49
|
+
}), { mutate: C } = s({
|
|
50
|
+
mutationFn: async (e) => {
|
|
51
|
+
const { mainProgram: u, awardsAmount: d } = typeof e == "string" ? { mainProgram: e, awardsAmount: 0 } : e;
|
|
52
|
+
await o.addAwardProgram(u, d);
|
|
53
53
|
},
|
|
54
54
|
onSuccess: () => {
|
|
55
|
-
|
|
55
|
+
i.invalidateQueries({
|
|
56
56
|
queryKey: [a.LINKED_USER_PROGRAMS]
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
|
-
}), { mutate: E } =
|
|
60
|
-
mutationFn: async (
|
|
61
|
-
await o.removeAwardProgram(
|
|
59
|
+
}), { mutate: E } = s({
|
|
60
|
+
mutationFn: async (e) => {
|
|
61
|
+
await o.removeAwardProgram(e);
|
|
62
62
|
},
|
|
63
63
|
onSuccess: () => {
|
|
64
|
-
|
|
64
|
+
i.invalidateQueries({
|
|
65
65
|
queryKey: [a.LINKED_USER_PROGRAMS]
|
|
66
66
|
});
|
|
67
67
|
}
|
|
68
|
-
}), { mutateAsync: K } =
|
|
69
|
-
mutationFn: async ({ mainProgram:
|
|
70
|
-
const d = t == null ? void 0 : t.find((F) => F.mainProgram ===
|
|
68
|
+
}), { mutateAsync: K } = s({
|
|
69
|
+
mutationFn: async ({ mainProgram: e, awardsAmount: u }) => {
|
|
70
|
+
const d = t == null ? void 0 : t.find((F) => F.mainProgram === e);
|
|
71
71
|
if (!d)
|
|
72
72
|
throw new Error("Program not found");
|
|
73
|
-
return o.setAwardPoints(d.mainProgram,
|
|
73
|
+
return o.setAwardPoints(d.mainProgram, u);
|
|
74
74
|
},
|
|
75
75
|
onSuccess: () => {
|
|
76
76
|
[
|
|
77
77
|
a.LINKED_USER_PROGRAMS,
|
|
78
78
|
a.USER_PROGRAMS,
|
|
79
79
|
a.PROGRAMS
|
|
80
|
-
].forEach((
|
|
81
|
-
|
|
80
|
+
].forEach((e) => {
|
|
81
|
+
i.invalidateQueries({ queryKey: [e] });
|
|
82
82
|
});
|
|
83
83
|
}
|
|
84
|
-
}), {
|
|
85
|
-
mutationFn: async (
|
|
86
|
-
await o.addCardsToWallet(r);
|
|
87
|
-
},
|
|
84
|
+
}), { mutateAsync: f } = s({
|
|
85
|
+
mutationFn: async (e) => o.addCardsToWallet(e),
|
|
88
86
|
onSuccess: () => {
|
|
89
|
-
|
|
87
|
+
i.invalidateQueries({
|
|
90
88
|
queryKey: [a.USER_CARDS]
|
|
91
89
|
});
|
|
92
90
|
}
|
|
93
|
-
}), {
|
|
94
|
-
mutationFn: async (
|
|
95
|
-
await o.removeCardsFromWallet(r);
|
|
96
|
-
},
|
|
91
|
+
}), { mutateAsync: q } = s({
|
|
92
|
+
mutationFn: async (e) => o.removeCardsFromWallet(e),
|
|
97
93
|
onSuccess: () => {
|
|
98
|
-
|
|
94
|
+
i.invalidateQueries({
|
|
99
95
|
queryKey: [a.USER_CARDS]
|
|
100
96
|
});
|
|
101
97
|
}
|
|
@@ -106,13 +102,13 @@ const B = () => {
|
|
|
106
102
|
userPrograms: c || [],
|
|
107
103
|
linkedUserPrograms: y || [],
|
|
108
104
|
hotelPrograms: (t == null ? void 0 : t.filter(
|
|
109
|
-
(
|
|
105
|
+
(e) => e.category.includes(m.HOTEL)
|
|
110
106
|
)) || [],
|
|
111
107
|
airlinePrograms: (t == null ? void 0 : t.filter(
|
|
112
|
-
(
|
|
108
|
+
(e) => e.category.includes(m.AIRLINE)
|
|
113
109
|
)) || [],
|
|
114
110
|
bankPrograms: (t == null ? void 0 : t.filter(
|
|
115
|
-
(
|
|
111
|
+
(e) => e.category.includes(m.BANK)
|
|
116
112
|
)) || [],
|
|
117
113
|
updatePoints: K,
|
|
118
114
|
addAwardProgram: C,
|
|
@@ -60,12 +60,12 @@ export interface IWalletHook {
|
|
|
60
60
|
* Adds cards to the user's wallet.
|
|
61
61
|
* @param cardIds - The IDs of the cards to be added.
|
|
62
62
|
*/
|
|
63
|
-
addCards: (cardIds: string[]) => void
|
|
63
|
+
addCards: (cardIds: string[]) => Promise<void>;
|
|
64
64
|
/**
|
|
65
65
|
* Removes cards from the user's wallet.
|
|
66
66
|
* @param cardIds - The IDs of the cards to be removed.
|
|
67
67
|
*/
|
|
68
|
-
removeCards: (cardIds: string[]) => void
|
|
68
|
+
removeCards: (cardIds: string[]) => Promise<void>;
|
|
69
69
|
/**
|
|
70
70
|
* Points as cash value object containing available points and dollar per point value.
|
|
71
71
|
*/
|