@odynn/awayz-core 0.3.22 → 0.3.24
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.
- package/dist/{AccountService-D_6U8vP6.js → AccountService-cvx__9rR.js} +55 -55
- package/dist/{TripsService-BbbkMtx6.js → TripsService-G1T_Co8r.js} +1 -1
- package/dist/components/CashValue/CashValue.js +47 -47
- package/dist/components/CashValue/CashValue.stories.js +2 -2
- package/dist/components/Wallet/Card/Card.stories.js +2 -2
- package/dist/configs/endpoints.js +3 -2
- package/dist/context/AwayzContext.js +4 -3
- package/dist/hooks/useAwayzAuth/useAwayzAuth.js +100 -83
- package/dist/hooks/useBookingManagement/useBookingManagement.js +1 -1
- package/dist/hooks/useBookingManagement/useBookingManagement.test.js +1 -1
- package/dist/hooks/useSearchLimit.js +17 -15
- package/dist/hooks/useTripManagement/useTripManagement.js +2 -2
- package/dist/hooks/useTripManagement/useTripManagement.test.js +3 -3
- package/dist/hooks/useWallet/useWallet.js +72 -42
- package/dist/hooks/useWallet/useWallet.test.js +80 -46
- package/dist/lib/components/CashValue/CashValue.d.ts +1 -1
- package/dist/lib/configs/endpoints.d.ts +3 -0
- package/dist/lib/context/AwayzContext.d.ts +2 -1
- package/dist/lib/hooks/useAwayzAuth/useAwayzAuth.d.ts +2 -1
- package/dist/lib/hooks/useSearchLimit.d.ts +3 -1
- package/dist/lib/hooks/useWallet/useWallet.types.d.ts +16 -2
- package/dist/lib/services/account/AccountServices.types.d.ts +4 -0
- package/dist/lib/services/preferences/PreferencesService.d.ts +7 -0
- package/dist/lib/services/wallet/WalletService.d.ts +3 -0
- package/dist/main.js +1 -1
- package/dist/providers/AwayzProvider.js +1 -1
- package/dist/services/account/AccountService.js +1 -1
- package/dist/services/bookings/BookingService.js +1 -1
- package/dist/services/currency/CurrencyService.js +1 -1
- package/dist/services/index.js +1 -1
- package/dist/services/instance.js +1 -1
- package/dist/services/instanceConfig.js +1 -1
- package/dist/services/noRetryInstance.js +1 -1
- package/dist/services/preferences/PreferencesService.js +35 -0
- package/dist/services/trips/TripsService.js +2 -2
- package/dist/services/wallet/WalletService.js +55 -26
- package/package.json +1 -1
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
var r = /* @__PURE__ */ ((e) => (e.SIGN_IN = "auth/user-login", e.SIGN_UP = "auth/sign-up", e.ME = "user", e.RESEND_VERIFICATION_EMAIL = "auth/resend-verification-email", e.UPDATE_USER_DETAILS = "account/update/user", e.CONFIRM_EMAIL = "account/verifyAccount", e.FORGOT_PASSWORD = "email/sendVeri", e.RESEND_OTP = "email/sendForgotPasswordVerification", e.RESET_PASSWORD = "account/updateUserPassword", e.REQUEST_LIMIT = "user/request-limit", e.APPLE_SOCIAL_SIGN_UP = "tp/apple/get/user", e.GOOGLE_SOCIAL_SIGN_UP = "tp/google/get/user", e.UPDATE_USER = "account/details/addUserDetails", e.ACKNOWLEDGEMENT = "account/update/userAcknowledgement", e.REGIONS = "user/region", e.UPDATE_USER_REGION = "/account/update/userRegion", e.UPDATE_PASSENGER_DETAILS = "/account/awayz", e.REFRESH_TOKEN = "auth/refresh-token", e.EXCHANGE_TOKEN = "user/exchange-token", e.REFRESH_EMBED_TOKEN = "user/refresh-token", e.OAUTH_INITIATE = "user/oauth2/initiate", e.OAUTH_CALLBACK = "user/oauth2/callback", e))(r || {}), a = /* @__PURE__ */ ((e) => (e.CURRENCY_CONVERSION = "currency/convert", e))(a || {}), _ = /* @__PURE__ */ ((e) => (e.USER_AWARDS = "user/rewards", e.USER_CARDS = "user/cards", e.ADD_USER_CARDS = "user/cards/add", e.REMOVE_USER_CARDS = "user/cards/remove", e.BANKS = "banks", e.CARDS = "cards", e))(_ || {}), S = /* @__PURE__ */ ((e) => (e.TRIPS = "user/trips", e.ADD_BOOKING = "user/trips/add-booking-to-trip", e.REMOVE_BOOKING = "user/trips/remove-booking-from-trip", e.UNCATEGORISED_BOOKINGS = "/user/trips/get-uncategorized-bookings", e))(S || {}),
|
|
1
|
+
var r = /* @__PURE__ */ ((e) => (e.SIGN_IN = "auth/user-login", e.SIGN_UP = "auth/sign-up", e.ME = "user", e.RESEND_VERIFICATION_EMAIL = "auth/resend-verification-email", e.UPDATE_USER_DETAILS = "account/update/user", e.CONFIRM_EMAIL = "account/verifyAccount", e.FORGOT_PASSWORD = "email/sendVeri", e.RESEND_OTP = "email/sendForgotPasswordVerification", e.RESET_PASSWORD = "account/updateUserPassword", e.REQUEST_LIMIT = "user/request-limit", e.APPLE_SOCIAL_SIGN_UP = "tp/apple/get/user", e.GOOGLE_SOCIAL_SIGN_UP = "tp/google/get/user", e.UPDATE_USER = "account/details/addUserDetails", e.ACKNOWLEDGEMENT = "account/update/userAcknowledgement", e.REGIONS = "user/region", e.UPDATE_USER_REGION = "/account/update/userRegion", e.UPDATE_PASSENGER_DETAILS = "/account/awayz", e.REFRESH_TOKEN = "auth/refresh-token", e.EXCHANGE_TOKEN = "user/exchange-token", e.REFRESH_EMBED_TOKEN = "user/refresh-token", e.OAUTH_INITIATE = "user/oauth2/initiate", e.OAUTH_CALLBACK = "user/oauth2/callback", e))(r || {}), a = /* @__PURE__ */ ((e) => (e.CURRENCY_CONVERSION = "currency/convert", e))(a || {}), _ = /* @__PURE__ */ ((e) => (e.USER_AWARDS = "user/rewards", e.USER_CARDS = "user/cards", e.ADD_USER_CARDS = "user/cards/add", e.REMOVE_USER_CARDS = "user/cards/remove", e.BANKS = "banks", e.CARDS = "cards", e))(_ || {}), S = /* @__PURE__ */ ((e) => (e.TRIPS = "user/trips", e.ADD_BOOKING = "user/trips/add-booking-to-trip", e.REMOVE_BOOKING = "user/trips/remove-booking-from-trip", e.UNCATEGORISED_BOOKINGS = "/user/trips/get-uncategorized-bookings", e))(S || {}), R = /* @__PURE__ */ ((e) => (e.USER_HOTEL_BOOKINGS = "/user/bookings/hotels", e.USER_FLIGHT_BOOKINGS = "/user/bookings/flights", e.INITIATE_FLIGHT_CANCEL = "/duffel/flights/initiate-order-cancellation", e.CONFIRM_FLIGHT_CANCEL = "/duffel/flights/confirm-order-cancellation", e.CANCEL_HOTEL_BOOKING = "/duffel/hotels/cancel", e))(R || {}), O = /* @__PURE__ */ ((e) => (e.USER_PREFERENCES = "/user/user-preferences", e))(O || {});
|
|
2
2
|
export {
|
|
3
3
|
r as EAuthEndpoints,
|
|
4
|
-
|
|
4
|
+
R as EBookingEndpoints,
|
|
5
5
|
a as ECurrencyEndpoints,
|
|
6
6
|
S as EMyTripsEndpoints,
|
|
7
|
+
O as EPreferencesEndpoints,
|
|
7
8
|
_ as EWalletEndpoints
|
|
8
9
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createContext as
|
|
2
|
-
const t =
|
|
1
|
+
import { createContext as e } from "react";
|
|
2
|
+
const t = e({
|
|
3
3
|
isAuthenticated: !1,
|
|
4
4
|
isAuthenticating: !1,
|
|
5
5
|
supportedRegions: [],
|
|
@@ -9,7 +9,8 @@ const t = s({
|
|
|
9
9
|
},
|
|
10
10
|
resendVerificationEmail: async () => !1,
|
|
11
11
|
setTokens: () => {
|
|
12
|
-
}
|
|
12
|
+
},
|
|
13
|
+
setPreferredCurrency: async () => !1
|
|
13
14
|
});
|
|
14
15
|
export {
|
|
15
16
|
t as AwayzContext
|
|
@@ -1,54 +1,55 @@
|
|
|
1
1
|
import "../../arrayExtensions-DlcBOj5a.js";
|
|
2
|
-
import { f as
|
|
3
|
-
import { useState as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
2
|
+
import { f as P, d as n, A as o, E as U } from "../../AccountService-cvx__9rR.js";
|
|
3
|
+
import { useState as m, useCallback as A, useEffect as S } from "react";
|
|
4
|
+
import { awayzClient as O } from "../../configs/awayzClient.js";
|
|
5
|
+
import { PreferencesService as v } from "../../services/preferences/PreferencesService.js";
|
|
6
|
+
import { EAuthFlow as h } from "../../types/EAuthFlow.js";
|
|
7
|
+
const C = (t, r) => {
|
|
8
|
+
var g, y;
|
|
9
|
+
let c = "", E = r;
|
|
10
|
+
typeof r == "string" ? c = r : r instanceof P ? (c = r.message, E = {
|
|
11
|
+
message: r.message,
|
|
12
|
+
cause: r.cause,
|
|
13
|
+
status: r.status,
|
|
14
|
+
data: (g = r == null ? void 0 : r.response) == null ? void 0 : g.data
|
|
15
|
+
}) : c = r.message, (y = window.parent) == null || y.postMessage(
|
|
15
16
|
{
|
|
16
17
|
type: "auth_error",
|
|
17
|
-
details: { message: c, action:
|
|
18
|
+
details: { message: c, action: t, info: E }
|
|
18
19
|
},
|
|
19
20
|
"*"
|
|
20
21
|
);
|
|
21
|
-
},
|
|
22
|
-
const [
|
|
23
|
-
async (
|
|
24
|
-
|
|
22
|
+
}, W = (t) => {
|
|
23
|
+
const [r, c] = m(!0), [E, g] = m(!1), [y, R] = m(), [d, T] = m(), [I, K] = m([]), w = A(
|
|
24
|
+
async (s) => {
|
|
25
|
+
t != null && t.onSuccess && (t == null || t.onSuccess(s)), t != null && t.onSuccessAsync && await (t == null ? void 0 : t.onSuccessAsync(s)), c(!1), g(!0), R(s.token), T(s.user), O.invalidateQueries();
|
|
25
26
|
},
|
|
26
|
-
[
|
|
27
|
-
), i =
|
|
28
|
-
async (
|
|
29
|
-
if (
|
|
30
|
-
return
|
|
31
|
-
|
|
27
|
+
[t]
|
|
28
|
+
), i = A(
|
|
29
|
+
async (s, e) => {
|
|
30
|
+
if (t.authFlow !== h.POST_MESSAGE)
|
|
31
|
+
return C(e ?? "exchange_token", s);
|
|
32
|
+
t != null && t.onError && (t == null || t.onError(s)), t != null && t.onErrorAsync && await (t == null ? void 0 : t.onErrorAsync(s)), c(!1);
|
|
32
33
|
},
|
|
33
|
-
[
|
|
34
|
-
),
|
|
34
|
+
[t]
|
|
35
|
+
), k = async (s) => {
|
|
35
36
|
try {
|
|
36
|
-
const { success: e, data:
|
|
37
|
+
const { success: e, data: a, message: u } = await o.authenticateWithToken(s);
|
|
37
38
|
if (!e) {
|
|
38
39
|
i(u);
|
|
39
40
|
return;
|
|
40
41
|
}
|
|
41
|
-
if (!(
|
|
42
|
+
if (!(a != null && a.token)) {
|
|
42
43
|
i("no awayz token returned after exchanging id token");
|
|
43
44
|
return;
|
|
44
45
|
}
|
|
45
|
-
localStorage.setItem(
|
|
46
|
-
const { data:
|
|
47
|
-
if (!
|
|
48
|
-
console.error({ reqLimitError:
|
|
46
|
+
localStorage.setItem(n.TOKEN, a.token), await w(a);
|
|
47
|
+
const { data: f, ...l } = await o.getRequestLimit();
|
|
48
|
+
if (!l.success) {
|
|
49
|
+
console.error({ reqLimitError: l });
|
|
49
50
|
return;
|
|
50
51
|
}
|
|
51
|
-
|
|
52
|
+
f == null || f.forEach(
|
|
52
53
|
(_) => window.parent.postMessage(
|
|
53
54
|
{
|
|
54
55
|
type: "request_limit",
|
|
@@ -64,114 +65,130 @@ const H = (s, t) => {
|
|
|
64
65
|
}
|
|
65
66
|
}, N = async () => {
|
|
66
67
|
try {
|
|
67
|
-
const { success:
|
|
68
|
-
queryKey: [
|
|
68
|
+
const { success: s, data: e } = await O.ensureQueryData({
|
|
69
|
+
queryKey: [U.CHECK_USER],
|
|
69
70
|
queryFn: o.checkUser
|
|
70
71
|
});
|
|
71
|
-
if (!
|
|
72
|
+
if (!s) {
|
|
72
73
|
i(e);
|
|
73
74
|
return;
|
|
74
75
|
}
|
|
75
76
|
await w({
|
|
76
77
|
user: e,
|
|
77
|
-
token: localStorage.getItem(
|
|
78
|
+
token: localStorage.getItem(n.TOKEN)
|
|
78
79
|
});
|
|
79
|
-
} catch (
|
|
80
|
-
i(
|
|
80
|
+
} catch (s) {
|
|
81
|
+
i(s);
|
|
81
82
|
} finally {
|
|
82
83
|
c(!1);
|
|
83
84
|
}
|
|
84
85
|
};
|
|
85
|
-
|
|
86
|
-
if (
|
|
87
|
-
const
|
|
88
|
-
|
|
86
|
+
S(() => {
|
|
87
|
+
if (t.authFlow !== h.STANDARD) return;
|
|
88
|
+
const s = localStorage.getItem(n.TOKEN), e = localStorage.getItem(n.REFRESH_TOKEN);
|
|
89
|
+
s && e ? N() : c(!1);
|
|
89
90
|
}, []);
|
|
90
91
|
const F = async () => {
|
|
91
|
-
const
|
|
92
|
-
K(
|
|
92
|
+
const s = await o.getRegions();
|
|
93
|
+
K(s);
|
|
93
94
|
};
|
|
94
|
-
return
|
|
95
|
+
return S(() => {
|
|
95
96
|
F();
|
|
96
|
-
}, []),
|
|
97
|
-
if (
|
|
98
|
-
const e = new URLSearchParams(window.location.search).get(
|
|
99
|
-
e &&
|
|
100
|
-
}, []),
|
|
101
|
-
if (
|
|
102
|
-
const
|
|
103
|
-
var
|
|
97
|
+
}, []), S(() => {
|
|
98
|
+
if (t.authFlow !== h.QUERY) return;
|
|
99
|
+
const e = new URLSearchParams(window.location.search).get(n.TOKEN);
|
|
100
|
+
e && k(e);
|
|
101
|
+
}, []), S(() => {
|
|
102
|
+
if (t.authFlow !== h.POST_MESSAGE) return;
|
|
103
|
+
const s = async (e) => {
|
|
104
|
+
var f;
|
|
104
105
|
if (e.data.type !== "auth") return;
|
|
105
|
-
const
|
|
106
|
-
if (!
|
|
107
|
-
const
|
|
106
|
+
const a = (f = e.data) == null ? void 0 : f.idToken, u = e.data.refreshToken;
|
|
107
|
+
if (!a) {
|
|
108
|
+
const l = `received message ${JSON.stringify(
|
|
108
109
|
e.data
|
|
109
110
|
)}
|
|
110
111
|
no idToken in body`;
|
|
111
|
-
i(
|
|
112
|
+
i(l);
|
|
112
113
|
return;
|
|
113
114
|
}
|
|
114
115
|
if (!u) {
|
|
115
|
-
const
|
|
116
|
+
const l = `received message: ${JSON.stringify(
|
|
116
117
|
e.data
|
|
117
118
|
)}
|
|
118
119
|
no refreshToken in body`;
|
|
119
120
|
i(
|
|
120
|
-
|
|
121
|
+
l,
|
|
121
122
|
"refresh_token"
|
|
122
123
|
/* REFRESH */
|
|
123
124
|
);
|
|
124
125
|
return;
|
|
125
126
|
}
|
|
126
|
-
localStorage.setItem(
|
|
127
|
+
localStorage.setItem(n.REFRESH_TOKEN, u), await k(a);
|
|
127
128
|
};
|
|
128
|
-
return window.addEventListener("message",
|
|
129
|
+
return window.addEventListener("message", s), window.parent && window.parent.postMessage(
|
|
129
130
|
{
|
|
130
131
|
type: "ready"
|
|
131
132
|
/* READY */
|
|
132
133
|
},
|
|
133
134
|
"*"
|
|
134
135
|
), () => {
|
|
135
|
-
window.removeEventListener("message",
|
|
136
|
+
window.removeEventListener("message", s);
|
|
136
137
|
};
|
|
137
138
|
}, []), {
|
|
138
|
-
isAuthenticating:
|
|
139
|
-
isAuthenticated:
|
|
140
|
-
token:
|
|
141
|
-
user:
|
|
139
|
+
isAuthenticating: r,
|
|
140
|
+
isAuthenticated: E,
|
|
141
|
+
token: y,
|
|
142
|
+
user: d,
|
|
142
143
|
supportedRegions: I,
|
|
143
|
-
signIn: async (
|
|
144
|
-
var
|
|
145
|
-
const e = await o.login(
|
|
144
|
+
signIn: async (s) => {
|
|
145
|
+
var a;
|
|
146
|
+
const e = await o.login(s);
|
|
146
147
|
if (!e.success)
|
|
147
148
|
i(e.message);
|
|
148
149
|
else {
|
|
149
|
-
const u = (
|
|
150
|
-
localStorage.setItem(
|
|
150
|
+
const u = (a = e.data) == null ? void 0 : a.refreshToken;
|
|
151
|
+
localStorage.setItem(n.REFRESH_TOKEN, u), await w(e.data);
|
|
151
152
|
}
|
|
152
153
|
return e;
|
|
153
154
|
},
|
|
154
|
-
signUp: async (
|
|
155
|
-
var
|
|
156
|
-
const e = await o.signUp(
|
|
155
|
+
signUp: async (s) => {
|
|
156
|
+
var a;
|
|
157
|
+
const e = await o.signUp(s);
|
|
157
158
|
if (!e.success)
|
|
158
159
|
i(e.message);
|
|
159
160
|
else {
|
|
160
|
-
const u = (
|
|
161
|
-
localStorage.setItem(
|
|
161
|
+
const u = (a = e.data) == null ? void 0 : a.refreshToken;
|
|
162
|
+
localStorage.setItem(n.REFRESH_TOKEN, u), await w(e.data);
|
|
162
163
|
}
|
|
163
164
|
return e;
|
|
164
165
|
},
|
|
165
166
|
signOut: () => {
|
|
166
|
-
localStorage.removeItem(
|
|
167
|
+
localStorage.removeItem(n.TOKEN), localStorage.removeItem(n.REFRESH_TOKEN), g(!1), R(void 0), T(void 0);
|
|
167
168
|
},
|
|
168
|
-
resendVerificationEmail: async (
|
|
169
|
-
setTokens: (
|
|
170
|
-
localStorage.setItem(
|
|
169
|
+
resendVerificationEmail: async (s) => (await o.resendVerificationEmail(s)).success,
|
|
170
|
+
setTokens: (s, e) => {
|
|
171
|
+
localStorage.setItem(n.TOKEN, s), localStorage.setItem(n.REFRESH_TOKEN, e), k(s);
|
|
172
|
+
},
|
|
173
|
+
setPreferredCurrency: async (s) => {
|
|
174
|
+
const e = await v.setCurrency(s);
|
|
175
|
+
if (!e.success || !e.data)
|
|
176
|
+
return console.error("Failed to set preferred currency:", e), !1;
|
|
177
|
+
if (d) {
|
|
178
|
+
const a = {
|
|
179
|
+
...d,
|
|
180
|
+
preferences: {
|
|
181
|
+
...d.preferences,
|
|
182
|
+
currency: e.data.currency || d.preferences.currency
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
T(a);
|
|
186
|
+
}
|
|
187
|
+
return !0;
|
|
171
188
|
}
|
|
172
189
|
};
|
|
173
190
|
};
|
|
174
191
|
export {
|
|
175
|
-
|
|
176
|
-
|
|
192
|
+
C as authFailurePostMessage,
|
|
193
|
+
W as useAwayzAuth
|
|
177
194
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useQuery as a, useMutation as s } from "@tanstack/react-query";
|
|
2
2
|
import { EBookingType as e } from "../../services/trips/TripService.types.js";
|
|
3
3
|
import "../../arrayExtensions-DlcBOj5a.js";
|
|
4
|
-
import { E as t } from "../../AccountService-
|
|
4
|
+
import { E as t } from "../../AccountService-cvx__9rR.js";
|
|
5
5
|
import "react";
|
|
6
6
|
import { BookingService as o } from "../../services/bookings/BookingService.js";
|
|
7
7
|
import "react/jsx-runtime";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { renderHook as t, waitFor as r } from "../../tests/TestWrapper.js";
|
|
2
2
|
import { useBookingManagement as a } from "./useBookingManagement.js";
|
|
3
|
-
import { c as i } from "../../AccountService-
|
|
3
|
+
import { c as i } from "../../AccountService-cvx__9rR.js";
|
|
4
4
|
import "../../services/noRetryInstance.js";
|
|
5
5
|
import "../../arrayExtensions-DlcBOj5a.js";
|
|
6
6
|
import "react";
|
|
@@ -1,26 +1,28 @@
|
|
|
1
|
-
import { E as s, A as i, b as n } from "../AccountService-D_6U8vP6.js";
|
|
2
1
|
import { useQuery as u } from "@tanstack/react-query";
|
|
3
2
|
import "../arrayExtensions-DlcBOj5a.js";
|
|
4
|
-
import "
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
import { E as m, A as c, b as f } from "../AccountService-cvx__9rR.js";
|
|
4
|
+
import { useEffect as d } from "react";
|
|
5
|
+
import { useAwayzContext as y } from "./useAwayzContext.js";
|
|
6
|
+
var i = /* @__PURE__ */ ((r) => (r.HOTEL = "Hotel", r.FLIGHT = "Flight", r))(i || {});
|
|
7
|
+
const H = (r) => {
|
|
8
|
+
const { isAuthenticated: o } = y(), { data: t } = u({
|
|
9
|
+
queryKey: [m.SEARCH_LIMIT],
|
|
10
10
|
queryFn: async () => {
|
|
11
|
-
const { data:
|
|
12
|
-
if (!
|
|
13
|
-
console.error({ reqLimitError:
|
|
11
|
+
const { data: s, ...e } = await c.getRequestLimit();
|
|
12
|
+
if (!e.success) {
|
|
13
|
+
console.error({ reqLimitError: e });
|
|
14
14
|
return;
|
|
15
15
|
}
|
|
16
|
-
return
|
|
16
|
+
return f(s);
|
|
17
17
|
},
|
|
18
|
-
enabled:
|
|
18
|
+
enabled: o
|
|
19
19
|
});
|
|
20
|
-
return
|
|
21
|
-
|
|
20
|
+
return d(() => {
|
|
21
|
+
t && (r == null || r());
|
|
22
|
+
}, [t, r]), t ? [i.FLIGHT, i.HOTEL].map(
|
|
23
|
+
(s) => t.find((e) => e.searchType === s)
|
|
22
24
|
) : [void 0, void 0];
|
|
23
25
|
};
|
|
24
26
|
export {
|
|
25
|
-
|
|
27
|
+
H as useSearchLimit
|
|
26
28
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { useQuery as p, useMutation as s } from "@tanstack/react-query";
|
|
2
2
|
import { h as m } from "../../arrayExtensions-DlcBOj5a.js";
|
|
3
|
-
import { E as e } from "../../AccountService-
|
|
3
|
+
import { E as e } from "../../AccountService-cvx__9rR.js";
|
|
4
4
|
import "react";
|
|
5
|
-
import { T as t } from "../../TripsService-
|
|
5
|
+
import { T as t } from "../../TripsService-G1T_Co8r.js";
|
|
6
6
|
import "react/jsx-runtime";
|
|
7
7
|
import "../../context/AwayzContext.js";
|
|
8
8
|
import { awayzClient as o } from "../../configs/awayzClient.js";
|
|
@@ -4,10 +4,10 @@ import { useTripManagement as n } from "./useTripManagement.js";
|
|
|
4
4
|
import "react/jsx-runtime";
|
|
5
5
|
import "react";
|
|
6
6
|
import "../../context/AwayzContext.js";
|
|
7
|
-
import { D as f } from "../../TripsService-
|
|
8
|
-
import { c } from "../../AccountService-D_6U8vP6.js";
|
|
9
|
-
import { EMyTripsEndpoints as d } from "../../configs/endpoints.js";
|
|
7
|
+
import { D as f } from "../../TripsService-G1T_Co8r.js";
|
|
10
8
|
import "../../configs/awayzClient.js";
|
|
9
|
+
import { c } from "../../AccountService-cvx__9rR.js";
|
|
10
|
+
import { EMyTripsEndpoints as d } from "../../configs/endpoints.js";
|
|
11
11
|
import "@tanstack/react-query";
|
|
12
12
|
import { EBookingType as m } from "../../services/trips/TripService.types.js";
|
|
13
13
|
import "../../services/noRetryInstance.js";
|
|
@@ -1,86 +1,116 @@
|
|
|
1
|
-
import { useQuery as
|
|
1
|
+
import { useQuery as n, useMutation as i } from "@tanstack/react-query";
|
|
2
2
|
import "../../arrayExtensions-DlcBOj5a.js";
|
|
3
|
-
import { E as t, a as
|
|
3
|
+
import { E as t, a as d } from "../../AccountService-cvx__9rR.js";
|
|
4
4
|
import "react";
|
|
5
|
-
import { WalletService as a } from "../../services/wallet/WalletService.js";
|
|
6
5
|
import "react/jsx-runtime";
|
|
7
6
|
import "../../context/AwayzContext.js";
|
|
8
|
-
import { awayzClient as
|
|
7
|
+
import { awayzClient as s } from "../../configs/awayzClient.js";
|
|
8
|
+
import { useAwayzContext as f } 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 */
|
|
12
12
|
/* empty css */
|
|
13
13
|
/* empty css */
|
|
14
14
|
/* empty css */
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
import { WalletService as o } from "../../services/wallet/WalletService.js";
|
|
16
|
+
const B = () => {
|
|
17
|
+
const { user: e } = f(), { data: a } = n({
|
|
17
18
|
queryKey: [t.PROGRAMS],
|
|
18
|
-
queryFn:
|
|
19
|
+
queryFn: o.getAwards,
|
|
19
20
|
placeholderData: []
|
|
20
|
-
}), { data:
|
|
21
|
+
}), { data: y } = n({
|
|
22
|
+
queryKey: [t.USER_PROGRAMS, e == null ? void 0 : e.id],
|
|
23
|
+
queryFn: () => e != null && e.id ? o.getUserAwards(e.id) : [],
|
|
24
|
+
placeholderData: [],
|
|
25
|
+
enabled: !!(e != null && e.id)
|
|
26
|
+
}), { data: l } = n({
|
|
21
27
|
queryKey: [t.BANKS],
|
|
22
|
-
queryFn:
|
|
28
|
+
queryFn: o.getBanks,
|
|
23
29
|
placeholderData: []
|
|
24
|
-
}), { data:
|
|
30
|
+
}), { data: g } = n({
|
|
25
31
|
queryKey: [t.CARDS],
|
|
26
|
-
queryFn:
|
|
32
|
+
queryFn: o.getCards,
|
|
27
33
|
placeholderData: []
|
|
28
|
-
}), { data:
|
|
34
|
+
}), { data: p } = n({
|
|
29
35
|
queryKey: [t.USER_CARDS],
|
|
30
|
-
queryFn:
|
|
36
|
+
queryFn: o.getUserCards,
|
|
31
37
|
placeholderData: []
|
|
32
|
-
}), { mutate:
|
|
33
|
-
mutationFn: async (
|
|
34
|
-
const { mainProgram:
|
|
35
|
-
|
|
38
|
+
}), { mutate: A } = i({
|
|
39
|
+
mutationFn: async (r) => {
|
|
40
|
+
const { mainProgram: m, awardsAmount: u } = typeof r == "string" ? { mainProgram: r, awardsAmount: 0 } : r;
|
|
41
|
+
await o.addAwardProgram(m, u);
|
|
42
|
+
},
|
|
43
|
+
onSuccess: () => {
|
|
44
|
+
s.invalidateQueries({
|
|
45
|
+
queryKey: [t.PROGRAMS]
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}), { mutate: P } = i({
|
|
49
|
+
mutationFn: async (r) => {
|
|
50
|
+
await o.removeAwardProgram(r);
|
|
51
|
+
},
|
|
52
|
+
onSuccess: () => {
|
|
53
|
+
s.invalidateQueries({
|
|
54
|
+
queryKey: [t.PROGRAMS]
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}), { mutate: R } = i({
|
|
58
|
+
mutationFn: async (r) => {
|
|
59
|
+
const { mainProgram: m, awardsAmount: u } = r, c = a == null ? void 0 : a.find(
|
|
60
|
+
(w) => w.mainProgram === m
|
|
36
61
|
);
|
|
37
|
-
if (!
|
|
62
|
+
if (!c)
|
|
38
63
|
throw new Error("Program not found");
|
|
39
|
-
await
|
|
64
|
+
await o.setAwardPoints(c.mainProgram, u);
|
|
40
65
|
},
|
|
41
66
|
onSuccess: () => {
|
|
42
|
-
|
|
67
|
+
s.invalidateQueries({
|
|
43
68
|
queryKey: [t.PROGRAMS]
|
|
44
69
|
});
|
|
45
70
|
}
|
|
46
|
-
}), { mutate:
|
|
47
|
-
mutationFn: async (
|
|
48
|
-
await
|
|
71
|
+
}), { mutate: S } = i({
|
|
72
|
+
mutationFn: async (r) => {
|
|
73
|
+
await o.addCardsToWallet(r);
|
|
49
74
|
},
|
|
50
75
|
onSuccess: () => {
|
|
51
|
-
|
|
76
|
+
s.invalidateQueries({
|
|
52
77
|
queryKey: [t.USER_CARDS]
|
|
53
78
|
});
|
|
54
79
|
}
|
|
55
|
-
}), { mutate:
|
|
56
|
-
mutationFn: async (
|
|
57
|
-
await
|
|
80
|
+
}), { mutate: C } = i({
|
|
81
|
+
mutationFn: async (r) => {
|
|
82
|
+
await o.removeCardsFromWallet(r);
|
|
58
83
|
},
|
|
59
84
|
onSuccess: () => {
|
|
60
|
-
|
|
85
|
+
s.invalidateQueries({
|
|
61
86
|
queryKey: [t.USER_CARDS]
|
|
62
87
|
});
|
|
63
88
|
}
|
|
64
89
|
});
|
|
65
90
|
return {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
91
|
+
// Program Management
|
|
92
|
+
allPrograms: a || [],
|
|
93
|
+
userPrograms: y || [],
|
|
94
|
+
hotelPrograms: (a == null ? void 0 : a.filter(
|
|
95
|
+
(r) => r.category.includes(d.HOTEL)
|
|
69
96
|
)) || [],
|
|
70
|
-
airlinePrograms: (
|
|
71
|
-
(
|
|
97
|
+
airlinePrograms: (a == null ? void 0 : a.filter(
|
|
98
|
+
(r) => r.category.includes(d.AIRLINE)
|
|
72
99
|
)) || [],
|
|
73
|
-
bankPrograms: (
|
|
74
|
-
(
|
|
100
|
+
bankPrograms: (a == null ? void 0 : a.filter(
|
|
101
|
+
(r) => r.category.includes(d.BANK)
|
|
75
102
|
)) || [],
|
|
76
|
-
updatePoints:
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
103
|
+
updatePoints: R,
|
|
104
|
+
addAwardProgram: A,
|
|
105
|
+
removeAwardProgram: P,
|
|
106
|
+
// Car Management
|
|
107
|
+
banks: l || [],
|
|
108
|
+
allCards: g || [],
|
|
109
|
+
userCards: p || [],
|
|
110
|
+
addCards: S,
|
|
111
|
+
removeCards: C
|
|
82
112
|
};
|
|
83
113
|
};
|
|
84
114
|
export {
|
|
85
|
-
|
|
115
|
+
B as useWallet
|
|
86
116
|
};
|