@odynn/awayz-core 0.9.0 → 0.9.2

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.
@@ -49,7 +49,7 @@ const $ = (n, t) => {
49
49
  }
50
50
  }), {
51
51
  mutate: I,
52
- isPending: p,
52
+ isPending: m,
53
53
  isError: y,
54
54
  error: G,
55
55
  isSuccess: L
@@ -62,7 +62,7 @@ const $ = (n, t) => {
62
62
  provider: r.pointsAsCash.provider,
63
63
  type: o.FLIGHT,
64
64
  pointsAmount: r.pointsAsCash.points,
65
- cashAmount: r.pointsAsCash.cashValue
65
+ cashAmount: r.pointsAsCash.cashValue.amount
66
66
  }), e.confirmCancelFlightBooking(n);
67
67
  if (t === o.HOTEL)
68
68
  return i != null && i.pointsAsCash && await e.cancelPointsBooking({
@@ -71,7 +71,7 @@ const $ = (n, t) => {
71
71
  provider: i.pointsAsCash.provider,
72
72
  type: o.HOTEL,
73
73
  pointsAmount: i.pointsAsCash.points,
74
- cashAmount: i.pointsAsCash.cashValue
74
+ cashAmount: i.pointsAsCash.cashValue.amount
75
75
  }), e.cancelHotelBooking(n);
76
76
  },
77
77
  onSuccess: () => {
@@ -84,15 +84,15 @@ const $ = (n, t) => {
84
84
  error: K
85
85
  } = u({
86
86
  mutationFn: async (c) => {
87
- var m, l;
88
- const C = (l = (m = r == null ? void 0 : r.airlineInitiatedChanges) == null ? void 0 : m.filter(
87
+ var C, l;
88
+ const p = (l = (C = r == null ? void 0 : r.airlineInitiatedChanges) == null ? void 0 : C.filter(
89
89
  (T) => !T.actionTaken
90
90
  )) == null ? void 0 : l[0];
91
- if (t === o.FLIGHT && (r != null && r.airlineInitiatedChanges) && C)
91
+ if (t === o.FLIGHT && (r != null && r.airlineInitiatedChanges) && p)
92
92
  return e.actionAirlineChanges({
93
93
  bookingId: n,
94
94
  acceptChanges: c,
95
- aicId: C.id
95
+ aicId: p.id
96
96
  });
97
97
  throw new Error("Not supported for hotel bookings");
98
98
  },
@@ -118,8 +118,8 @@ const $ = (n, t) => {
118
118
  initiateCancellationError: H,
119
119
  isInitiateCancellationSuccess: O,
120
120
  cancelBooking: I,
121
- isCancellingBooking: p,
122
- isCancelingBooking: p,
121
+ isCancellingBooking: m,
122
+ isCancelingBooking: m,
123
123
  isCancelBookingError: y,
124
124
  cancelBookingError: G,
125
125
  isCancelBookingSuccess: L,
@@ -1,8 +1,9 @@
1
+ import { useQuery as U } from "@tanstack/react-query";
1
2
  import "../arrayExtensions-DlcBOj5a.js";
2
- import { t as R } from "../noRetryInstance-oiHCni_Z.js";
3
- import { useState as e, useEffect as I } from "react";
4
- import { FeatureService as r } from "../services/features/featureService.js";
5
- const O = [
3
+ import { E as O, t as F } from "../noRetryInstance-oiHCni_Z.js";
4
+ import "react";
5
+ import { FeatureService as t } from "../services/features/featureService.js";
6
+ const L = [
6
7
  "DEFAULT_CURRENCY_FEATURE",
7
8
  "TOTAL_DISPLAY_FEATURE",
8
9
  "HOTEL_DETAILS_LAYOUT_FEATURE",
@@ -17,7 +18,7 @@ const O = [
17
18
  "SEARCH_RADIUS_POSITION_FEATURE",
18
19
  "NAVIGATION_FEATURE",
19
20
  "AMOUNTS_DISPLAY_FEATURE"
20
- ], U = [
21
+ ], e = [
21
22
  "CURRENCY_FILTER_FEATURE",
22
23
  "FREE_HOTEL_NIGHTS_FEATURE",
23
24
  "SHOW_BOOKABLE_FEATURE",
@@ -38,51 +39,52 @@ const O = [
38
39
  "ADD_AIRLINE_HEALTH_PAGE_FEATURE",
39
40
  "SHOW_NAVIGATION_POPUP_FEATURE",
40
41
  "SHOW_ONLY_BOOKABLE_FEATURE"
41
- ], a = [
42
+ ], S = [
42
43
  "HOTEL_DETAILS_FEATURE",
43
44
  "WALLET_PROGRAM_TYPES_FEATURES",
44
45
  "HOTEL_FILTERS_FEATURES",
45
46
  "FLIGHT_FILTERS_FEATURES",
46
47
  "WALLET_FEATURES"
47
48
  ];
48
- var o = /* @__PURE__ */ ((E) => (E.CASH_ONLY = "Cash Only", E.CASH_AND_TRAVEL_PARTNER_POINTS = "Cash And Travel Partner Points", E.CASH_AND_CLIENT_POINTS = "Cash And Client Points", E))(o || {});
49
- const c = () => {
50
- const [E, L] = e({}), [F, t] = e(!1), S = async () => {
51
- try {
52
- const A = await r.getFeatureFlags();
53
- L(A);
54
- } catch (A) {
55
- console.error("Error fetching feature flags:", A);
56
- } finally {
57
- t(!0);
58
- }
59
- };
60
- return I(() => {
61
- S();
62
- }, []), {
63
- featureFlags: (F && E ? (() => {
64
- const A = {};
65
- return O.forEach((T) => {
66
- const _ = R(
67
- T.toLowerCase()
68
- );
69
- E[T] !== void 0 && (A[_] = E[T]);
70
- }), U.forEach((T) => {
71
- const _ = R(
72
- T.toLowerCase()
73
- );
74
- E[T] !== void 0 && (A[_] = E[T]);
75
- }), a.forEach((T) => {
76
- const _ = R(
77
- T.toLowerCase()
78
- );
79
- E[T] !== void 0 && (A[_] = E[T]);
80
- }), A;
81
- })() : void 0) ?? {},
82
- loaded: F
49
+ var r = /* @__PURE__ */ ((E) => (E.CASH_ONLY = "Cash Only", E.CASH_AND_TRAVEL_PARTNER_POINTS = "Cash And Travel Partner Points", E.CASH_AND_CLIENT_POINTS = "Cash And Client Points", E))(r || {});
50
+ const n = () => {
51
+ const { data: E, isSuccess: R } = U({
52
+ queryKey: [O.FEATURES, "new"],
53
+ queryFn: t.getFeatureFlags,
54
+ staleTime: 1 / 0
55
+ }), I = R && E ? (() => {
56
+ const _ = {};
57
+ return L.forEach((T) => {
58
+ const A = F(
59
+ T.toLowerCase()
60
+ );
61
+ E[T] !== void 0 && (_[A] = E[T]);
62
+ }), e.forEach((T) => {
63
+ const A = F(
64
+ T.toLowerCase()
65
+ );
66
+ E[T] !== void 0 && (_[A] = E[T]);
67
+ }), S.forEach((T) => {
68
+ const A = F(
69
+ T.toLowerCase()
70
+ );
71
+ E[T] !== void 0 && (_[A] = E[T]);
72
+ }), _;
73
+ })() : null;
74
+ if (R && E) {
75
+ const T = [
76
+ ...L,
77
+ ...e,
78
+ ...S
79
+ ].filter((A) => E[A] === void 0);
80
+ T.length > 0 && console.error("Missing feature flags:", T);
81
+ }
82
+ return {
83
+ featureFlags: I ?? {},
84
+ loaded: R
83
85
  };
84
86
  };
85
87
  export {
86
- o as EAmountsDisplayFeature,
87
- c as useFeatureFlags
88
+ r as EAmountsDisplayFeature,
89
+ n as useFeatureFlags
88
90
  };
@@ -58,7 +58,10 @@ export interface IPointsAsCash {
58
58
  pointsValue: number;
59
59
  confirmationCode: string;
60
60
  provider: string;
61
- cashValue: number;
61
+ cashValue: {
62
+ amount: number;
63
+ currency: string;
64
+ };
62
65
  }
63
66
  export interface ICancellationTimeline {
64
67
  refundAmount: number;
@@ -1,4 +1,4 @@
1
- import { jsx as t } from "react/jsx-runtime";
1
+ import { jsx as o } from "react/jsx-runtime";
2
2
  import { QueryClientProvider as m } from "@tanstack/react-query";
3
3
  import "../arrayExtensions-DlcBOj5a.js";
4
4
  import { a as r } from "../_styles.flight-booking-DEUJthTJ.js";
@@ -7,30 +7,30 @@ import { setCustomBaseUrl as i, setBaseUrl as d } from "../configs/baseUrl.js";
7
7
  import { defaultAwayzConfig as p } from "../configs/defaultAwayzConfig.js";
8
8
  import { setGatewayBaseUrl as h } from "../configs/gatewayBaseUrl.js";
9
9
  import { AwayzContext as w } from "../context/AwayzContext.js";
10
- import { useAwayzAuth as y } from "../hooks/useAwayzAuth/useAwayzAuth.js";
10
+ import { useAwayzAuth as n } from "../hooks/useAwayzAuth/useAwayzAuth.js";
11
11
  import "react-i18next";
12
12
  import '../assets/_styles3.css';import '../assets/_styles4.css';import '../assets/_styles.css';import '../assets/_styles2.css';/* empty css */
13
13
  /* empty css */
14
- import { awayzClient as A } from "../configs/awayzClient.js";
14
+ import { awayzClient as y } from "../configs/awayzClient.js";
15
15
  import "../noRetryInstance-oiHCni_Z.js";
16
16
  /* empty css */
17
17
  /* empty css */
18
- import { useFeatureFlags as F } from "../hooks/useFeatureFlags.js";
19
- const K = ({ children: o, config: e }) => {
20
- const a = y({
18
+ import { useFeatureFlags as A } from "../hooks/useFeatureFlags.js";
19
+ const K = ({ children: t, config: e }) => /* @__PURE__ */ o(m, { client: y, children: /* @__PURE__ */ o(F, { config: e, children: t }) }), F = ({ children: t, config: e }) => {
20
+ const a = n({
21
21
  authFlow: e.authFlow,
22
22
  onSuccess: e.onAuthSuccess,
23
23
  onError: e.onAuthFailure,
24
24
  trustedOrigins: e.trustedOrigins,
25
25
  isTestMode: e.testMode
26
- }), { featureFlags: s, loaded: l } = F();
26
+ }), { featureFlags: s, loaded: l } = A();
27
27
  return u(() => {
28
28
  if (!e.clientId) {
29
29
  console.error("You need to provide a client ID to the AwayzProvider");
30
30
  return;
31
31
  }
32
32
  localStorage.setItem(r.CLIENT_ID, e.clientId), localStorage.setItem(r.AUTH_FLOW, e.authFlow), e.debugRefreshToken && e.testMode && (localStorage.setItem(r.REFRESH_TOKEN, e.debugRefreshToken), localStorage.setItem(r.TOKEN, e.debugRefreshToken)), e.overrideBaseUrl ? i(e.overrideBaseUrl) : d(e.testMode ?? !1), h(e.gatewayBaseUrl);
33
- }, [e]), /* @__PURE__ */ t(m, { client: A, children: /* @__PURE__ */ t(
33
+ }, [e]), /* @__PURE__ */ o(
34
34
  w.Provider,
35
35
  {
36
36
  value: {
@@ -42,9 +42,9 @@ const K = ({ children: o, config: e }) => {
42
42
  featureFlags: s,
43
43
  featureFlagsLoaded: l
44
44
  },
45
- children: o
45
+ children: t
46
46
  }
47
- ) });
47
+ );
48
48
  };
49
49
  export {
50
50
  K as AwayzProvider
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@odynn/awayz-core",
3
- "version": "0.9.0",
3
+ "version": "0.9.2",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"