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