@odynn/awayz-core 0.3.23 → 0.3.25
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/components/CashValue/CashValue.js +47 -47
- 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/useTripManagement/useTripManagement.test.js +1 -1
- package/dist/hooks/useWallet/useWallet.test.js +1 -1
- 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/services/account/AccountServices.types.d.ts +4 -0
- package/dist/lib/services/preferences/PreferencesService.d.ts +7 -0
- package/dist/services/preferences/PreferencesService.js +35 -0
- package/package.json +1 -1
|
@@ -3,21 +3,21 @@ import * as i from "react";
|
|
|
3
3
|
import { useMemo as nt } from "react";
|
|
4
4
|
import { u as D, a as ot, c as A, b as q, d as ve, e as st, f as it, g as G, o as at, s as lt, h as ct, i as dt, j as ut, k as pt, l as ft, m as ht, n as vt, p as mt, P as me } from "../../index-BC-KTkxU.js";
|
|
5
5
|
import { r as yt, R as gt } from "../../index-Cv-wvFlM.js";
|
|
6
|
-
import {
|
|
6
|
+
import { useQuery as Ct } from "@tanstack/react-query";
|
|
7
7
|
import "../../arrayExtensions-DlcBOj5a.js";
|
|
8
|
-
import { E as
|
|
9
|
-
import {
|
|
10
|
-
import { CurrencyService as wt } from "../../services/currency/CurrencyService.js";
|
|
11
|
-
import '../../assets/_styles5.css';import '../../assets/_styles4.css';import '../../assets/_styles3.css';import '../../assets/_styles2.css';import '../../assets/_styles.css';/* empty css */
|
|
8
|
+
import { E as Et } from "../../AccountService-cvx__9rR.js";
|
|
9
|
+
import { b as ue } from "../../index-CDh8vAM_.js";
|
|
12
10
|
import "../../context/AwayzContext.js";
|
|
13
11
|
import "../../configs/awayzClient.js";
|
|
14
|
-
import { useAwayzContext as
|
|
12
|
+
import { useAwayzContext as wt } from "../../hooks/useAwayzContext.js";
|
|
15
13
|
import "../../services/noRetryInstance.js";
|
|
14
|
+
import { CurrencyService as Pt } from "../../services/currency/CurrencyService.js";
|
|
16
15
|
import { EInvalidAmountDisplayOption as N, EToolTipPosition as bt } from "./CashValueTypes.js";
|
|
17
|
-
|
|
16
|
+
import '../../assets/_styles.css';import '../../assets/_styles5.css';import '../../assets/_styles4.css';import '../../assets/_styles3.css';import '../../assets/_styles2.css';/* empty css */
|
|
18
17
|
/* empty css */
|
|
19
18
|
/* empty css */
|
|
20
19
|
/* empty css */
|
|
20
|
+
/* empty css */
|
|
21
21
|
const Y = (e, t) => {
|
|
22
22
|
var r = new Intl.NumberFormat("en-US", {
|
|
23
23
|
style: "currency",
|
|
@@ -125,24 +125,24 @@ var _t = "DismissableLayer", z = "dismissableLayer.update", Lt = "dismissableLay
|
|
|
125
125
|
onInteractOutside: a,
|
|
126
126
|
onDismiss: u,
|
|
127
127
|
...l
|
|
128
|
-
} = e, p = i.useContext(ge), [d, f] = i.useState(null),
|
|
128
|
+
} = e, p = i.useContext(ge), [d, f] = i.useState(null), v = (d == null ? void 0 : d.ownerDocument) ?? (globalThis == null ? void 0 : globalThis.document), [, h] = i.useState({}), m = D(t, (g) => f(g)), y = Array.from(p.layers), [C] = [...p.layersWithOutsidePointerEventsDisabled].slice(-1), w = y.indexOf(C), E = d ? y.indexOf(d) : -1, x = p.layersWithOutsidePointerEventsDisabled.size > 0, P = E >= w, T = kt((g) => {
|
|
129
129
|
const S = g.target, F = [...p.branches].some((I) => I.contains(S));
|
|
130
130
|
!P || F || (n == null || n(g), a == null || a(g), g.defaultPrevented || u == null || u());
|
|
131
|
-
},
|
|
131
|
+
}, v), b = Ft((g) => {
|
|
132
132
|
const S = g.target;
|
|
133
133
|
[...p.branches].some((I) => I.contains(S)) || (s == null || s(g), a == null || a(g), g.defaultPrevented || u == null || u());
|
|
134
|
-
},
|
|
134
|
+
}, v);
|
|
135
135
|
return ot((g) => {
|
|
136
136
|
E === p.layers.size - 1 && (o == null || o(g), !g.defaultPrevented && u && (g.preventDefault(), u()));
|
|
137
|
-
},
|
|
137
|
+
}, v), i.useEffect(() => {
|
|
138
138
|
if (d)
|
|
139
|
-
return r && (p.layersWithOutsidePointerEventsDisabled.size === 0 && (fe =
|
|
140
|
-
r && p.layersWithOutsidePointerEventsDisabled.size === 1 && (
|
|
139
|
+
return r && (p.layersWithOutsidePointerEventsDisabled.size === 0 && (fe = v.body.style.pointerEvents, v.body.style.pointerEvents = "none"), p.layersWithOutsidePointerEventsDisabled.add(d)), p.layers.add(d), he(), () => {
|
|
140
|
+
r && p.layersWithOutsidePointerEventsDisabled.size === 1 && (v.body.style.pointerEvents = fe);
|
|
141
141
|
};
|
|
142
|
-
}, [d,
|
|
142
|
+
}, [d, v, r, p]), i.useEffect(() => () => {
|
|
143
143
|
d && (p.layers.delete(d), p.layersWithOutsidePointerEventsDisabled.delete(d), he());
|
|
144
144
|
}, [d, p]), i.useEffect(() => {
|
|
145
|
-
const g = () =>
|
|
145
|
+
const g = () => h({});
|
|
146
146
|
return document.addEventListener(z, g), () => document.removeEventListener(z, g);
|
|
147
147
|
}, []), /* @__PURE__ */ c(
|
|
148
148
|
O.div,
|
|
@@ -271,8 +271,8 @@ var Q = "PopperContent", [Ut, Yt] = Pe(Q), Oe = i.forwardRef(
|
|
|
271
271
|
collisionBoundary: p = [],
|
|
272
272
|
collisionPadding: d = 0,
|
|
273
273
|
sticky: f = "partial",
|
|
274
|
-
hideWhenDetached:
|
|
275
|
-
updatePositionStrategy:
|
|
274
|
+
hideWhenDetached: v = !1,
|
|
275
|
+
updatePositionStrategy: h = "optimized",
|
|
276
276
|
onPlaced: m,
|
|
277
277
|
...y
|
|
278
278
|
} = e, C = xe(Q, r), [w, E] = i.useState(null), x = D(t, (M) => E(M)), [P, T] = i.useState(null), b = st(P), g = (b == null ? void 0 : b.width) ?? 0, S = (b == null ? void 0 : b.height) ?? 0, F = o + (s !== "center" ? "-" + s : ""), I = typeof d == "number" ? d : { top: 0, right: 0, bottom: 0, left: 0, ...d }, te = Array.isArray(p) ? p : [p], Ye = te.length > 0, $ = {
|
|
@@ -285,7 +285,7 @@ var Q = "PopperContent", [Ut, Yt] = Pe(Q), Oe = i.forwardRef(
|
|
|
285
285
|
strategy: "fixed",
|
|
286
286
|
placement: F,
|
|
287
287
|
whileElementsMounted: (...M) => ht(...M, {
|
|
288
|
-
animationFrame:
|
|
288
|
+
animationFrame: h === "always"
|
|
289
289
|
}),
|
|
290
290
|
elements: {
|
|
291
291
|
reference: C.anchor
|
|
@@ -308,7 +308,7 @@ var Q = "PopperContent", [Ut, Yt] = Pe(Q), Oe = i.forwardRef(
|
|
|
308
308
|
}),
|
|
309
309
|
P && ut({ element: P, padding: u }),
|
|
310
310
|
Gt({ arrowWidth: g, arrowHeight: S }),
|
|
311
|
-
|
|
311
|
+
v && pt({ strategy: "referenceHidden", ...$ })
|
|
312
312
|
]
|
|
313
313
|
}), [ne, Ge] = De(je), B = q(m);
|
|
314
314
|
G(() => {
|
|
@@ -431,9 +431,9 @@ var Gt = (e) => ({
|
|
|
431
431
|
options: e,
|
|
432
432
|
fn(t) {
|
|
433
433
|
var C, w, E;
|
|
434
|
-
const { placement: r, rects: o, middlewareData: n } = t, a = ((C = n.arrow) == null ? void 0 : C.centerOffset) !== 0, u = a ? 0 : e.arrowWidth, l = a ? 0 : e.arrowHeight, [p, d] = De(r), f = { start: "0%", center: "50%", end: "100%" }[d],
|
|
434
|
+
const { placement: r, rects: o, middlewareData: n } = t, a = ((C = n.arrow) == null ? void 0 : C.centerOffset) !== 0, u = a ? 0 : e.arrowWidth, l = a ? 0 : e.arrowHeight, [p, d] = De(r), f = { start: "0%", center: "50%", end: "100%" }[d], v = (((w = n.arrow) == null ? void 0 : w.x) ?? 0) + u / 2, h = (((E = n.arrow) == null ? void 0 : E.y) ?? 0) + l / 2;
|
|
435
435
|
let m = "", y = "";
|
|
436
|
-
return p === "bottom" ? (m = a ? f : `${
|
|
436
|
+
return p === "bottom" ? (m = a ? f : `${v}px`, y = `${-l}px`) : p === "top" ? (m = a ? f : `${v}px`, y = `${o.floating.height + l}px`) : p === "right" ? (m = `${-l}px`, y = a ? f : `${h}px`) : p === "left" && (m = `${o.floating.width + l}px`, y = a ? f : `${h}px`), { data: { x: m, y } };
|
|
437
437
|
}
|
|
438
438
|
});
|
|
439
439
|
function De(e) {
|
|
@@ -518,7 +518,7 @@ var H = "Tooltip", [nr, k] = V(H), He = (e) => {
|
|
|
518
518
|
onOpenChange: s,
|
|
519
519
|
disableHoverableContent: a,
|
|
520
520
|
delayDuration: u
|
|
521
|
-
} = e, l = J(H, e.__scopeTooltip), p = j(t), [d, f] = i.useState(null),
|
|
521
|
+
} = e, l = J(H, e.__scopeTooltip), p = j(t), [d, f] = i.useState(null), v = vt(), h = i.useRef(0), m = a ?? l.disableHoverableContent, y = u ?? l.delayDuration, C = i.useRef(!1), [w, E] = mt({
|
|
522
522
|
prop: o,
|
|
523
523
|
defaultProp: n ?? !1,
|
|
524
524
|
onChange: (g) => {
|
|
@@ -526,21 +526,21 @@ var H = "Tooltip", [nr, k] = V(H), He = (e) => {
|
|
|
526
526
|
},
|
|
527
527
|
caller: H
|
|
528
528
|
}), x = i.useMemo(() => w ? C.current ? "delayed-open" : "instant-open" : "closed", [w]), P = i.useCallback(() => {
|
|
529
|
-
window.clearTimeout(
|
|
529
|
+
window.clearTimeout(h.current), h.current = 0, C.current = !1, E(!0);
|
|
530
530
|
}, [E]), T = i.useCallback(() => {
|
|
531
|
-
window.clearTimeout(
|
|
531
|
+
window.clearTimeout(h.current), h.current = 0, E(!1);
|
|
532
532
|
}, [E]), b = i.useCallback(() => {
|
|
533
|
-
window.clearTimeout(
|
|
534
|
-
C.current = !0, E(!0),
|
|
533
|
+
window.clearTimeout(h.current), h.current = window.setTimeout(() => {
|
|
534
|
+
C.current = !0, E(!0), h.current = 0;
|
|
535
535
|
}, y);
|
|
536
536
|
}, [y, E]);
|
|
537
537
|
return i.useEffect(() => () => {
|
|
538
|
-
|
|
538
|
+
h.current && (window.clearTimeout(h.current), h.current = 0);
|
|
539
539
|
}, []), /* @__PURE__ */ c(zt, { ...p, children: /* @__PURE__ */ c(
|
|
540
540
|
nr,
|
|
541
541
|
{
|
|
542
542
|
scope: t,
|
|
543
|
-
contentId:
|
|
543
|
+
contentId: v,
|
|
544
544
|
open: w,
|
|
545
545
|
stateAttribute: x,
|
|
546
546
|
trigger: d,
|
|
@@ -549,7 +549,7 @@ var H = "Tooltip", [nr, k] = V(H), He = (e) => {
|
|
|
549
549
|
l.isOpenDelayedRef.current ? b() : P();
|
|
550
550
|
}, [l.isOpenDelayedRef, b, P]),
|
|
551
551
|
onTriggerLeave: i.useCallback(() => {
|
|
552
|
-
m ? T() : (window.clearTimeout(
|
|
552
|
+
m ? T() : (window.clearTimeout(h.current), h.current = 0);
|
|
553
553
|
}, [T, m]),
|
|
554
554
|
onOpen: P,
|
|
555
555
|
onClose: T,
|
|
@@ -569,8 +569,8 @@ var Z = "TooltipTrigger", ke = i.forwardRef(
|
|
|
569
569
|
"data-state": n.stateAttribute,
|
|
570
570
|
...o,
|
|
571
571
|
ref: l,
|
|
572
|
-
onPointerMove: A(e.onPointerMove, (
|
|
573
|
-
|
|
572
|
+
onPointerMove: A(e.onPointerMove, (v) => {
|
|
573
|
+
v.pointerType !== "touch" && !d.current && !s.isPointerInTransitRef.current && (n.onTriggerEnter(), d.current = !0);
|
|
574
574
|
}),
|
|
575
575
|
onPointerLeave: A(e.onPointerLeave, () => {
|
|
576
576
|
n.onTriggerLeave(), d.current = !1;
|
|
@@ -601,31 +601,31 @@ var L = "TooltipContent", $e = i.forwardRef(
|
|
|
601
601
|
return /* @__PURE__ */ c(me, { present: o || a.open, children: a.disableHoverableContent ? /* @__PURE__ */ c(We, { side: n, ...s, ref: t }) : /* @__PURE__ */ c(ir, { side: n, ...s, ref: t }) });
|
|
602
602
|
}
|
|
603
603
|
), ir = i.forwardRef((e, t) => {
|
|
604
|
-
const r = k(L, e.__scopeTooltip), o = J(L, e.__scopeTooltip), n = i.useRef(null), s = D(t, n), [a, u] = i.useState(null), { trigger: l, onClose: p } = r, d = n.current, { onPointerInTransitChange: f } = o,
|
|
604
|
+
const r = k(L, e.__scopeTooltip), o = J(L, e.__scopeTooltip), n = i.useRef(null), s = D(t, n), [a, u] = i.useState(null), { trigger: l, onClose: p } = r, d = n.current, { onPointerInTransitChange: f } = o, v = i.useCallback(() => {
|
|
605
605
|
u(null), f(!1);
|
|
606
|
-
}, [f]),
|
|
606
|
+
}, [f]), h = i.useCallback(
|
|
607
607
|
(m, y) => {
|
|
608
608
|
const C = m.currentTarget, w = { x: m.clientX, y: m.clientY }, E = dr(w, C.getBoundingClientRect()), x = ur(w, E), P = pr(y.getBoundingClientRect()), T = hr([...x, ...P]);
|
|
609
609
|
u(T), f(!0);
|
|
610
610
|
},
|
|
611
611
|
[f]
|
|
612
612
|
);
|
|
613
|
-
return i.useEffect(() => () =>
|
|
613
|
+
return i.useEffect(() => () => v(), [v]), i.useEffect(() => {
|
|
614
614
|
if (l && d) {
|
|
615
|
-
const m = (C) =>
|
|
615
|
+
const m = (C) => h(C, d), y = (C) => h(C, l);
|
|
616
616
|
return l.addEventListener("pointerleave", m), d.addEventListener("pointerleave", y), () => {
|
|
617
617
|
l.removeEventListener("pointerleave", m), d.removeEventListener("pointerleave", y);
|
|
618
618
|
};
|
|
619
619
|
}
|
|
620
|
-
}, [l, d,
|
|
620
|
+
}, [l, d, h, v]), i.useEffect(() => {
|
|
621
621
|
if (a) {
|
|
622
622
|
const m = (y) => {
|
|
623
623
|
const C = y.target, w = { x: y.clientX, y: y.clientY }, E = (l == null ? void 0 : l.contains(C)) || (d == null ? void 0 : d.contains(C)), x = !fr(w, a);
|
|
624
|
-
E ?
|
|
624
|
+
E ? v() : x && (v(), p());
|
|
625
625
|
};
|
|
626
626
|
return document.addEventListener("pointermove", m), () => document.removeEventListener("pointermove", m);
|
|
627
627
|
}
|
|
628
|
-
}, [l, d, a, p,
|
|
628
|
+
}, [l, d, a, p, v]), /* @__PURE__ */ c(We, { ...e, ref: s });
|
|
629
629
|
}), [ar, lr] = V(H, { isInside: !1 }), cr = /* @__PURE__ */ At("TooltipContent"), We = i.forwardRef(
|
|
630
630
|
(e, t) => {
|
|
631
631
|
const {
|
|
@@ -638,9 +638,9 @@ var L = "TooltipContent", $e = i.forwardRef(
|
|
|
638
638
|
} = e, l = k(L, r), p = j(r), { onClose: d } = l;
|
|
639
639
|
return i.useEffect(() => (document.addEventListener(X, d), () => document.removeEventListener(X, d)), [d]), i.useEffect(() => {
|
|
640
640
|
if (l.trigger) {
|
|
641
|
-
const f = (
|
|
642
|
-
const
|
|
643
|
-
|
|
641
|
+
const f = (v) => {
|
|
642
|
+
const h = v.target;
|
|
643
|
+
h != null && h.contains(l.trigger) && d();
|
|
644
644
|
};
|
|
645
645
|
return window.addEventListener("scroll", f, { capture: !0 }), () => window.removeEventListener("scroll", f, { capture: !0 });
|
|
646
646
|
}
|
|
@@ -747,8 +747,8 @@ function fr(e, t) {
|
|
|
747
747
|
const { x: r, y: o } = e;
|
|
748
748
|
let n = !1;
|
|
749
749
|
for (let s = 0, a = t.length - 1; s < t.length; a = s++) {
|
|
750
|
-
const u = t[s], l = t[a], p = u.x, d = u.y, f = l.x,
|
|
751
|
-
d > o !=
|
|
750
|
+
const u = t[s], l = t[a], p = u.x, d = u.y, f = l.x, v = l.y;
|
|
751
|
+
d > o != v > o && r < (f - p) * (o - d) / (v - d) + p && (n = !n);
|
|
752
752
|
}
|
|
753
753
|
return n;
|
|
754
754
|
}
|
|
@@ -789,10 +789,10 @@ const Pr = 1e3 * 60 * 60, Vr = ({
|
|
|
789
789
|
zeroDisplayOption: o = N.NA,
|
|
790
790
|
customDisplay: n
|
|
791
791
|
}) => {
|
|
792
|
-
var f;
|
|
793
|
-
const { user: s } =
|
|
794
|
-
queryKey: [
|
|
795
|
-
queryFn: () =>
|
|
792
|
+
var f, v;
|
|
793
|
+
const { user: s } = wt(), a = ((f = s == null ? void 0 : s.preferences) == null ? void 0 : f.currency) ?? ((v = s == null ? void 0 : s.userRegion) == null ? void 0 : v.currency), u = a !== t, { data: l, isPending: p } = Ct({
|
|
794
|
+
queryKey: [Et.CONVERT_CURRENCY, t, a],
|
|
795
|
+
queryFn: () => Pt.convertCurrency({ baseCurrency: t }),
|
|
796
796
|
enabled: u,
|
|
797
797
|
staleTime: Pr
|
|
798
798
|
}), d = nt(() => {
|
|
@@ -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
|
};
|
|
@@ -5,9 +5,9 @@ import "react/jsx-runtime";
|
|
|
5
5
|
import "react";
|
|
6
6
|
import "../../context/AwayzContext.js";
|
|
7
7
|
import { D as f } from "../../TripsService-G1T_Co8r.js";
|
|
8
|
+
import "../../configs/awayzClient.js";
|
|
8
9
|
import { c } from "../../AccountService-cvx__9rR.js";
|
|
9
10
|
import { EMyTripsEndpoints as d } from "../../configs/endpoints.js";
|
|
10
|
-
import "../../configs/awayzClient.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";
|
|
@@ -3,8 +3,8 @@ import "react/jsx-runtime";
|
|
|
3
3
|
import "react";
|
|
4
4
|
import "../../context/AwayzContext.js";
|
|
5
5
|
import "../../arrayExtensions-DlcBOj5a.js";
|
|
6
|
-
import { c as l } from "../../AccountService-cvx__9rR.js";
|
|
7
6
|
import "../../configs/awayzClient.js";
|
|
7
|
+
import { c as l } from "../../AccountService-cvx__9rR.js";
|
|
8
8
|
import "@tanstack/react-query";
|
|
9
9
|
import { useWallet as t } from "./useWallet.js";
|
|
10
10
|
import "../../services/noRetryInstance.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { IAwayzConfig } from '../configs/awayzConfig';
|
|
1
2
|
import { IRegion, IResendVerificationEmailParams, IUser } from '../services/account/AccountServices.types';
|
|
2
3
|
import { ISignInParams, ISignUpParams, TAuthResponse } from '../types/auth';
|
|
3
|
-
import { IAwayzConfig } from '../configs/awayzConfig';
|
|
4
4
|
export interface IAwayzContext {
|
|
5
5
|
config?: IAwayzConfig;
|
|
6
6
|
token?: string;
|
|
@@ -13,5 +13,6 @@ export interface IAwayzContext {
|
|
|
13
13
|
signOut: () => void;
|
|
14
14
|
resendVerificationEmail: (params: IResendVerificationEmailParams) => Promise<boolean>;
|
|
15
15
|
setTokens: (accessToken: string, refreshToken: string) => void;
|
|
16
|
+
setPreferredCurrency: (currency: string) => Promise<boolean>;
|
|
16
17
|
}
|
|
17
18
|
export declare const AwayzContext: import('react').Context<IAwayzContext>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { TEmbeddedAuthOptions } from './useAwayzAuth.types';
|
|
2
1
|
import { IAuthData, IRegion, IResendVerificationEmailParams, IUser } from '../../services/account/AccountServices.types';
|
|
3
2
|
import { ISignInParams, ISignUpParams } from '../../types/auth';
|
|
3
|
+
import { TEmbeddedAuthOptions } from './useAwayzAuth.types';
|
|
4
4
|
declare enum ETokenType {
|
|
5
5
|
EXCHANGE = "exchange_token",
|
|
6
6
|
REFRESH = "refresh_token"
|
|
@@ -33,5 +33,6 @@ export declare const useAwayzAuth: (options: TEmbeddedAuthOptions) => {
|
|
|
33
33
|
signOut: () => void;
|
|
34
34
|
resendVerificationEmail: (params: IResendVerificationEmailParams) => Promise<any>;
|
|
35
35
|
setTokens: (accessToken: string, refreshToken: string) => void;
|
|
36
|
+
setPreferredCurrency: (currency: string) => Promise<boolean>;
|
|
36
37
|
};
|
|
37
38
|
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { TServiceResponse } from '@type-op/shared';
|
|
2
|
+
import { IUserPreferences } from '../account/AccountServices.types';
|
|
3
|
+
declare class _PreferencesService {
|
|
4
|
+
setCurrency: (currency: string) => Promise<TServiceResponse<Partial<IUserPreferences>>>;
|
|
5
|
+
}
|
|
6
|
+
export declare const PreferencesService: _PreferencesService;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
var a = Object.defineProperty;
|
|
2
|
+
var o = (s, e, r) => e in s ? a(s, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : s[e] = r;
|
|
3
|
+
var n = (s, e, r) => o(s, typeof e != "symbol" ? e + "" : e, r);
|
|
4
|
+
import { EPreferencesEndpoints as u } from "../../configs/endpoints.js";
|
|
5
|
+
import { c as i } from "../../AccountService-cvx__9rR.js";
|
|
6
|
+
class E {
|
|
7
|
+
constructor() {
|
|
8
|
+
n(this, "setCurrency", async (e) => {
|
|
9
|
+
var r, t;
|
|
10
|
+
try {
|
|
11
|
+
const { data: c } = await i.put(
|
|
12
|
+
u.USER_PREFERENCES,
|
|
13
|
+
{
|
|
14
|
+
currency: e
|
|
15
|
+
}
|
|
16
|
+
);
|
|
17
|
+
return {
|
|
18
|
+
success: !0,
|
|
19
|
+
data: {
|
|
20
|
+
currency: c.data.currency
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
} catch (c) {
|
|
24
|
+
return console.error(c), {
|
|
25
|
+
success: !1,
|
|
26
|
+
message: ((t = (r = c == null ? void 0 : c.response) == null ? void 0 : r.data) == null ? void 0 : t.message) || "Failed to set currency"
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
const p = new E();
|
|
33
|
+
export {
|
|
34
|
+
p as PreferencesService
|
|
35
|
+
};
|