@odynn/awayz-core 0.9.31 → 0.9.33

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,42 +1,42 @@
1
1
  import { jsx as r, jsxs as l } from "react/jsx-runtime";
2
- import { useQuery as E } from "@tanstack/react-query";
2
+ import { useQuery as R } from "@tanstack/react-query";
3
3
  import "../../arrayExtensions-DlcBOj5a.js";
4
- import { g as m, a as R, b as C } from "../../cashUtils-DB_r0g-F.js";
5
- import { E as _ } from "../../noRetryInstance-DKhe8ju0.js";
6
- import { useMemo as S } from "react";
7
- import { a as N } from "../../index-C8p5kinH.js";
4
+ import { g as m, a as _, b as N } from "../../cashUtils-DB_r0g-F.js";
5
+ import { E as S } from "../../noRetryInstance-DKhe8ju0.js";
6
+ import { useMemo as T } from "react";
7
+ import { a as f } from "../../index-C8p5kinH.js";
8
8
  import "react-i18next";
9
9
  import '../../assets/_styles3.css';import '../../assets/_styles.css';import '../../assets/_styles2.css';/* empty css */
10
10
  import "../../_styles.flight-booking-CaUgKcMC.js";
11
11
  /* empty css */
12
- import { EInvalidAmountDisplayOption as o, EToolTipPosition as T } from "./CashValueTypes.js";
13
- import { useAwayzContext as D } from "../../hooks/useAwayzContext.js";
12
+ import { EInvalidAmountDisplayOption as s, EToolTipPosition as D } from "./CashValueTypes.js";
13
+ import { useAwayzContext as I } from "../../hooks/useAwayzContext.js";
14
14
  import "../../configs/awayzClient.js";
15
15
  /* empty css */
16
16
  import "../../context/AwayzContext.js";
17
- import { CurrencyService as I } from "../../services/currency/CurrencyService.js";
18
- import { Tooltip as M } from "../Tooltip/Tooltip.js";
19
- const O = 1e3 * 60 * 60, G = ({
17
+ import { CurrencyService as M } from "../../services/currency/CurrencyService.js";
18
+ import { Tooltip as O } from "../Tooltip/Tooltip.js";
19
+ const x = 1e3 * 60 * 60, k = ({
20
20
  amount: i,
21
21
  currency: e,
22
- position: f = T.RIGHT,
23
- zeroDisplayOption: v = o.NA,
24
- customDisplay: A,
22
+ position: v = D.RIGHT,
23
+ zeroDisplayOption: A = s.NA,
24
+ customDisplay: y,
25
25
  decimalPlaces: p = 2,
26
- showConversion: y = !1,
27
- showOriginal: g = !1
26
+ showConversion: g = !1,
27
+ showOriginal: E = !1
28
28
  }) => {
29
- var h;
30
- const { user: s } = D(), n = ((h = s == null ? void 0 : s.preferences) == null ? void 0 : h.currency) ?? e, t = n !== e, { data: c, isPending: d } = E({
31
- queryKey: [_.CONVERT_CURRENCY, e, n],
32
- queryFn: () => I.convertCurrency({
29
+ var h, C;
30
+ const { user: o } = I(), n = ((h = o == null ? void 0 : o.preferences) == null ? void 0 : h.currency) ?? ((C = o == null ? void 0 : o.userRegion) == null ? void 0 : C.currency), t = n !== e, { data: c, isPending: d } = R({
31
+ queryKey: [S.CONVERT_CURRENCY, e, n],
32
+ queryFn: () => M.convertCurrency({
33
33
  baseCurrency: e,
34
34
  targetCurrency: n
35
35
  }),
36
36
  enabled: t && !!e && !!i,
37
- staleTime: O
38
- }), a = S(() => {
39
- if (!s)
37
+ staleTime: x
38
+ }), a = T(() => {
39
+ if (!o)
40
40
  return null;
41
41
  let u = typeof i == "string" ? parseFloat(i) : i;
42
42
  if (t) {
@@ -44,25 +44,25 @@ const O = 1e3 * 60 * 60, G = ({
44
44
  u = u * c;
45
45
  }
46
46
  return u;
47
- }, [i, s, d, t, c]);
48
- if (g)
47
+ }, [i, o, d, t, c]);
48
+ if (E)
49
49
  return /* @__PURE__ */ r("span", { className: "currency-conversion", children: m(i, e, p) });
50
50
  if (d && t)
51
51
  return /* @__PURE__ */ r("span", { className: "currency-conversion loading", children: i });
52
52
  if (!n || !a || a < 0)
53
- switch (v) {
54
- case o.NA:
53
+ switch (A) {
54
+ case s.NA:
55
55
  return /* @__PURE__ */ r("span", { children: "N/A" });
56
- case o.HIDDEN:
56
+ case s.HIDDEN:
57
57
  return /* @__PURE__ */ r("span", { className: "hidden", children: "N/A" });
58
- case o.DISPLAY_AS_ZERO:
58
+ case s.DISPLAY_AS_ZERO:
59
59
  return /* @__PURE__ */ r("span", { children: "0" });
60
- case o.DISPLAY_AS_ZERO_WITH_CURRENCY:
61
- return /* @__PURE__ */ r("span", { children: C(0, n ?? e) });
62
- case o.DISPLAY_AS_ZERO_WITH_CURRENCY_NO_DECIMAL:
63
- return /* @__PURE__ */ r("span", { children: R(0, n ?? e) });
64
- case o.CUSTOM:
65
- return /* @__PURE__ */ r("span", { children: a == 0 ? A : "N/A" });
60
+ case s.DISPLAY_AS_ZERO_WITH_CURRENCY:
61
+ return /* @__PURE__ */ r("span", { children: N(0, n ?? e) });
62
+ case s.DISPLAY_AS_ZERO_WITH_CURRENCY_NO_DECIMAL:
63
+ return /* @__PURE__ */ r("span", { children: _(0, n ?? e) });
64
+ case s.CUSTOM:
65
+ return /* @__PURE__ */ r("span", { children: a == 0 ? y : "N/A" });
66
66
  default:
67
67
  return /* @__PURE__ */ r("span", { children: "N/A" });
68
68
  }
@@ -72,11 +72,11 @@ const O = 1e3 * 60 * 60, G = ({
72
72
  n,
73
73
  p
74
74
  ),
75
- t && y && /* @__PURE__ */ r(
76
- M,
75
+ t && g && /* @__PURE__ */ r(
76
+ O,
77
77
  {
78
- trigger: /* @__PURE__ */ r("sup", { children: /* @__PURE__ */ r(N, {}) }),
79
- position: f,
78
+ trigger: /* @__PURE__ */ r("sup", { children: /* @__PURE__ */ r(f, {}) }),
79
+ position: v,
80
80
  children: /* @__PURE__ */ l("div", { className: "currency-conversion-container", children: [
81
81
  /* @__PURE__ */ l("p", { children: [
82
82
  "Converted from ",
@@ -91,7 +91,7 @@ const O = 1e3 * 60 * 60, G = ({
91
91
  n,
92
92
  p
93
93
  ) }) }),
94
- /* @__PURE__ */ r("span", { className: "conversion-icon", children: /* @__PURE__ */ r(N, {}) })
94
+ /* @__PURE__ */ r("span", { className: "conversion-icon", children: /* @__PURE__ */ r(f, {}) })
95
95
  ] }),
96
96
  /* @__PURE__ */ r("div", { className: "currency-conversion-rate", children: /* @__PURE__ */ l("p", { children: [
97
97
  "Current Rate:",
@@ -104,7 +104,7 @@ const O = 1e3 * 60 * 60, G = ({
104
104
  ) : "N/A",
105
105
  " ",
106
106
  "≈ ",
107
- C(1, n)
107
+ N(1, n)
108
108
  ] }) })
109
109
  ] })
110
110
  }
@@ -112,6 +112,6 @@ const O = 1e3 * 60 * 60, G = ({
112
112
  ] });
113
113
  };
114
114
  export {
115
- G as CashValue,
116
- O as CurrencyCallStaleTimeMs
115
+ k as CashValue,
116
+ x as CurrencyCallStaleTimeMs
117
117
  };
@@ -17,22 +17,22 @@ import "../../context/AwayzContext.js";
17
17
  /* empty css */
18
18
  import { EAuthFlow as T } from "../../types/EAuthFlow.js";
19
19
  const x = (s, c) => {
20
- var m, y;
21
- let i = "", d = c;
22
- typeof c == "string" ? i = c : c instanceof P ? (i = c.message, d = {
20
+ var m, S;
21
+ let i = "", y = c;
22
+ typeof c == "string" ? i = c : c instanceof P ? (i = c.message, y = {
23
23
  message: c.message,
24
24
  cause: c.cause,
25
25
  status: c.status,
26
26
  data: (m = c == null ? void 0 : c.response) == null ? void 0 : m.data
27
- }) : i = c.message, (y = window.parent) == null || y.postMessage(
27
+ }) : i = c.message, (S = window.parent) == null || S.postMessage(
28
28
  {
29
29
  type: "auth_error",
30
- details: { message: i, action: s, info: d }
30
+ details: { message: i, action: s, info: y }
31
31
  },
32
32
  "*"
33
33
  );
34
34
  }, le = (s) => {
35
- const [c, i] = f(!0), [d, m] = f(!1), [y, A] = f(), [S, k] = f(), [C, _] = f([]), [p, F] = f([]), g = I(
35
+ const [c, i] = f(!0), [y, m] = f(!1), [S, A] = f(), [g, k] = f(), [C, _] = f([]), [p, F] = f([]), E = I(
36
36
  async (t) => {
37
37
  s != null && s.onSuccess && (s == null || s.onSuccess(t)), s != null && s.onSuccessAsync && await (s == null ? void 0 : s.onSuccessAsync(t)), i(!1), m(!0), A(t.token), k(t.user), O.invalidateQueries();
38
38
  },
@@ -59,13 +59,13 @@ const x = (s, c) => {
59
59
  u("no awayz token returned after exchanging id token");
60
60
  return;
61
61
  }
62
- localStorage.setItem(o.TOKEN, n.token), await g(n);
63
- const { data: E, ...K } = await l.getRequestLimit();
62
+ localStorage.setItem(o.TOKEN, n.token), await E(n);
63
+ const { data: d, ...K } = await l.getRequestLimit();
64
64
  if (!K.success) {
65
65
  console.error({ reqLimitError: K });
66
66
  return;
67
67
  }
68
- E == null || E.forEach(
68
+ d == null || d.forEach(
69
69
  (H) => window.parent.postMessage(
70
70
  {
71
71
  type: "request_limit",
@@ -89,7 +89,7 @@ const x = (s, c) => {
89
89
  u(e);
90
90
  return;
91
91
  }
92
- await g({
92
+ await E({
93
93
  user: e,
94
94
  token: localStorage.getItem(o.TOKEN)
95
95
  });
@@ -126,11 +126,11 @@ const x = (s, c) => {
126
126
  if (e.data.type !== "auth") return;
127
127
  const r = (w = e.data) == null ? void 0 : w.idToken, a = e.data.refreshToken, n = s.isTestMode ? e.data.overrideTokenExchangeEndpoint : void 0;
128
128
  if (!r) {
129
- const E = `received message ${JSON.stringify(
129
+ const d = `received message ${JSON.stringify(
130
130
  e.data
131
131
  )}
132
132
  no idToken in body`;
133
- u(E);
133
+ u(d);
134
134
  return;
135
135
  }
136
136
  localStorage.setItem(o.REFRESH_TOKEN, a), await R(r, a, n);
@@ -146,9 +146,9 @@ const x = (s, c) => {
146
146
  };
147
147
  }, []), {
148
148
  isAuthenticating: c,
149
- isAuthenticated: d,
150
- token: y,
151
- user: S,
149
+ isAuthenticated: y,
150
+ token: S,
151
+ user: g,
152
152
  supportedRegions: C,
153
153
  supportedCurrencies: p,
154
154
  signIn: async (t) => {
@@ -158,7 +158,7 @@ const x = (s, c) => {
158
158
  u(e.message);
159
159
  else {
160
160
  const a = (r = e.data) == null ? void 0 : r.refreshToken;
161
- localStorage.setItem(o.REFRESH_TOKEN, a), await g(e.data);
161
+ localStorage.setItem(o.REFRESH_TOKEN, a), await E(e.data);
162
162
  }
163
163
  return e;
164
164
  },
@@ -169,7 +169,7 @@ const x = (s, c) => {
169
169
  u(e.message);
170
170
  else {
171
171
  const a = (r = e.data) == null ? void 0 : r.refreshToken;
172
- localStorage.setItem(o.REFRESH_TOKEN, a), await g(e.data);
172
+ localStorage.setItem(o.REFRESH_TOKEN, a), await E(e.data);
173
173
  }
174
174
  return e;
175
175
  },
@@ -186,7 +186,7 @@ const x = (s, c) => {
186
186
  u(r.message);
187
187
  else {
188
188
  const n = (a = r.data) == null ? void 0 : a.refreshToken;
189
- localStorage.setItem(o.REFRESH_TOKEN, n), await g(r.data);
189
+ localStorage.setItem(o.REFRESH_TOKEN, n), await E(r.data);
190
190
  }
191
191
  return r;
192
192
  },
@@ -198,12 +198,12 @@ const x = (s, c) => {
198
198
  const e = await q.setCurrency(t);
199
199
  if (!e.success || !e.data)
200
200
  return console.error("Failed to set preferred currency:", e), !1;
201
- if (S) {
201
+ if (g) {
202
202
  const r = {
203
- ...S,
203
+ ...g,
204
204
  preferences: {
205
- ...S.preferences,
206
- currency: e.data.currency
205
+ ...g.preferences,
206
+ currency: e.data.currency || g.preferences.currency
207
207
  }
208
208
  };
209
209
  k(r), O.invalidateQueries({
@@ -2,7 +2,7 @@ import { useQuery as U } from "@tanstack/react-query";
2
2
  import "../arrayExtensions-DlcBOj5a.js";
3
3
  import { E as e, t as F } from "../noRetryInstance-DKhe8ju0.js";
4
4
  import "react";
5
- import { FeatureService as r } from "../services/features/featureService.js";
5
+ import { FeatureService as N } from "../services/features/featureService.js";
6
6
  const L = [
7
7
  "DEFAULT_CURRENCY_FEATURE",
8
8
  "TOTAL_DISPLAY_FEATURE",
@@ -45,18 +45,19 @@ const L = [
45
45
  "ENABLE_EASY_SUPPORT_BOT_FEATURE",
46
46
  "SHOW_ONLY_BOOKABLE_FEATURE",
47
47
  "HIDE_FLIGHT_SEARCH_CONTAINER_FEATURE",
48
- "HIDE_HOTEL_SEARCH_CONTAINER_FEATURE"
48
+ "HIDE_HOTEL_SEARCH_CONTAINER_FEATURE",
49
+ "EXTERNAL_INVENTORY_FEATURE"
49
50
  ], I = [
50
51
  "WALLET_PROGRAM_TYPES_FEATURES",
51
52
  "HOTEL_FILTERS_FEATURES",
52
53
  "FLIGHT_FILTERS_FEATURES",
53
54
  "WALLET_FEATURES"
54
55
  ];
55
- var N = /* @__PURE__ */ ((E) => (E.DEFAULT = "default", E.FULL_VCC_PARTIAL_ENABLED = "Full VCC - Partial Enabled", E.FULL_VCC_PARTIAL_DISABLED = "Full VCC - Partial Disabled", E))(N || {}), t = /* @__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))(t || {}), H = /* @__PURE__ */ ((E) => (E.RESULT = "result", E.SHEET = "sheet", E))(H || {});
56
+ var r = /* @__PURE__ */ ((E) => (E.DEFAULT = "default", E.FULL_VCC_PARTIAL_ENABLED = "Full VCC - Partial Enabled", E.FULL_VCC_PARTIAL_DISABLED = "Full VCC - Partial Disabled", E))(r || {}), t = /* @__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))(t || {}), H = /* @__PURE__ */ ((E) => (E.RESULT = "result", E.SHEET = "sheet", E))(H || {});
56
57
  const l = () => {
57
58
  const { data: E, isSuccess: R } = U({
58
59
  queryKey: [e.FEATURES, "new"],
59
- queryFn: r.getFeatureFlags,
60
+ queryFn: N.getFeatureFlags,
60
61
  staleTime: 1 / 0
61
62
  }), O = R && E ? (() => {
62
63
  const T = {};
@@ -92,7 +93,7 @@ const l = () => {
92
93
  };
93
94
  export {
94
95
  t as EAmountsDisplayFeature,
95
- N as EBookingPaymentMethod,
96
+ r as EBookingPaymentMethod,
96
97
  H as EFlightBookingOptionsDisplayFeature,
97
98
  l as useFeatureFlags
98
99
  };
@@ -29,6 +29,7 @@ export interface IAwayzConfig {
29
29
  /**
30
30
  * Enable non-chain hotels for hotel searches
31
31
  * @default false
32
+ * @deprecated Use EXTERNAL_INVENTORY_FEATURE feature flag instead. This property is kept for backwards compatibility.
32
33
  */
33
34
  externalInventory?: boolean;
34
35
  /**
@@ -1,6 +1,6 @@
1
1
  type CamelCase<S extends string> = S extends `${infer P1}_${infer P2}${infer P3}` ? `${Lowercase<P1>}${Uppercase<P2>}${CamelCase<P3>}` : Lowercase<S>;
2
2
  declare const StringFeatureFlag: readonly ["DEFAULT_CURRENCY_FEATURE", "TOTAL_DISPLAY_FEATURE", "HOTEL_DETAILS_LAYOUT_FEATURE", "TRIP_MANAGEMENT_FEATURE", "FLIGHT_FILTER_LAYOUT_FEATURE", "WALLET_MANAGEMENT_FEATURE", "WALLET_PROGRAM_TYPES_FEATURES", "FLIGHT_PAGINATION_FEATURE", "AVAILABILITY_ALERTS_DISPLAY_FEATURE", "PAYMENT_TYPE_FEATURE", "HOTEL_DETAILS_FEATURES", "SEARCH_RADIUS_POSITION_FEATURE", "NAVIGATION_FEATURE", "BOOKING_PAYMENT_METHOD_FEATURE", "AMOUNTS_DISPLAY_FEATURE", "FLIGHT_BOOKING_OPTIONS_DISPLAY_FEATURE"];
3
- declare const BooleanFeatureFlag: readonly ["CURRENCY_FILTER_FEATURE", "FREE_HOTEL_NIGHTS_FEATURE", "SHOW_BOOKABLE_FEATURE", "FILTER_PRESETS_FEATURE", "SPLIT_HOTEL_CHAINS_FEATURE", "FLIGHT_SHOW_ANIMATION_FEATURE", "SHOW_FOOTER_FEATURE", "SHOW_AVAILABILITY_ALERTS_FEATURE", "USE_POINTS_AS_CASH_FEATURE", "HAS_HEADER_FEATURE", "SHOW_FLIGHTS_TRANSFER_PARTNER_FEATURE", "HOTEL_POINTS_ONLY_FEATURE", "FREE_HOTEL_NIGHTS_FEATURE", "HOTEL_DISPLAY_BEST_VALUE_FEATURE", "HOTEL_DISPLAY_POINTS_BREAKDOWN_FEATURE", "TAB_NAVIGATION_FEATURE", "ADD_AIRLINE_HEALTH_PAGE_FEATURE", "SHOW_NAVIGATION_POPUP_FEATURE", "SHOW_ONLY_BOOKABLE_FEATURE", "CASH_BOOKING_FEATURE", "DISABLE_FREE_USER_CASH_BOOKING_FEATURE", "ENABLE_EASY_SUPPORT_BOT_FEATURE", "SHOW_ONLY_BOOKABLE_FEATURE", "HIDE_FLIGHT_SEARCH_CONTAINER_FEATURE", "HIDE_HOTEL_SEARCH_CONTAINER_FEATURE"];
3
+ declare const BooleanFeatureFlag: readonly ["CURRENCY_FILTER_FEATURE", "FREE_HOTEL_NIGHTS_FEATURE", "SHOW_BOOKABLE_FEATURE", "FILTER_PRESETS_FEATURE", "SPLIT_HOTEL_CHAINS_FEATURE", "FLIGHT_SHOW_ANIMATION_FEATURE", "SHOW_FOOTER_FEATURE", "SHOW_AVAILABILITY_ALERTS_FEATURE", "USE_POINTS_AS_CASH_FEATURE", "HAS_HEADER_FEATURE", "SHOW_FLIGHTS_TRANSFER_PARTNER_FEATURE", "HOTEL_POINTS_ONLY_FEATURE", "FREE_HOTEL_NIGHTS_FEATURE", "HOTEL_DISPLAY_BEST_VALUE_FEATURE", "HOTEL_DISPLAY_POINTS_BREAKDOWN_FEATURE", "TAB_NAVIGATION_FEATURE", "ADD_AIRLINE_HEALTH_PAGE_FEATURE", "SHOW_NAVIGATION_POPUP_FEATURE", "SHOW_ONLY_BOOKABLE_FEATURE", "CASH_BOOKING_FEATURE", "DISABLE_FREE_USER_CASH_BOOKING_FEATURE", "ENABLE_EASY_SUPPORT_BOT_FEATURE", "SHOW_ONLY_BOOKABLE_FEATURE", "HIDE_FLIGHT_SEARCH_CONTAINER_FEATURE", "HIDE_HOTEL_SEARCH_CONTAINER_FEATURE", "EXTERNAL_INVENTORY_FEATURE"];
4
4
  declare const ListFeatureFlag: readonly ["WALLET_PROGRAM_TYPES_FEATURES", "HOTEL_FILTERS_FEATURES", "FLIGHT_FILTERS_FEATURES", "WALLET_FEATURES"];
5
5
  export declare enum EBookingPaymentMethod {
6
6
  DEFAULT = "default",
@@ -14,7 +14,7 @@ export interface IUser {
14
14
  isSocialUser: boolean;
15
15
  }
16
16
  export interface IUserPreferences {
17
- currency?: string;
17
+ currency: string;
18
18
  }
19
19
  export interface IAccount {
20
20
  userId: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@odynn/awayz-core",
3
- "version": "0.9.31",
3
+ "version": "0.9.33",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"