@odynn/awayz-core 0.10.5 → 0.10.7

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,7 +1,7 @@
1
1
  import { useQuery as U } from "@tanstack/react-query";
2
2
  import "../arrayExtensions-DlcBOj5a.js";
3
3
  import { E as r, t as F } from "../noRetryInstance-C4bqpBc7.js";
4
- import "react";
4
+ import { useMemo as e } from "react";
5
5
  import { FeatureService as N } from "../services/features/featureService.js";
6
6
  const L = [
7
7
  "DEFAULT_CURRENCY_FEATURE",
@@ -54,31 +54,34 @@ const L = [
54
54
  "FLIGHT_FILTERS_FEATURES",
55
55
  "WALLET_FEATURES"
56
56
  ];
57
- var e = /* @__PURE__ */ ((E) => (E.DEFAULT = "default", E.FULL_VCC_PARTIAL_ENABLED = "Full VCC - Partial Enabled", E.FULL_VCC_PARTIAL_DISABLED = "Full VCC - Partial Disabled", E))(e || {}), H = /* @__PURE__ */ ((E) => (E.LIGHT = "light", E.DARK = "dark", E.USER = "user", E))(H || {}), 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 || {}), s = /* @__PURE__ */ ((E) => (E.RESULT = "result", E.SHEET = "sheet", E))(s || {});
58
- const l = () => {
57
+ var H = /* @__PURE__ */ ((E) => (E.DEFAULT = "default", E.FULL_VCC_PARTIAL_ENABLED = "Full VCC - Partial Enabled", E.FULL_VCC_PARTIAL_DISABLED = "Full VCC - Partial Disabled", E))(H || {}), t = /* @__PURE__ */ ((E) => (E.LIGHT = "light", E.DARK = "dark", E.USER = "user", E))(t || {}), s = /* @__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))(s || {}), a = /* @__PURE__ */ ((E) => (E.RESULT = "result", E.SHEET = "sheet", E))(a || {});
58
+ const i = () => {
59
59
  const { data: E, isSuccess: R } = U({
60
60
  queryKey: [r.FEATURES, "new"],
61
61
  queryFn: N.getFeatureFlags,
62
62
  staleTime: 1 / 0
63
- }), O = R && E ? (() => {
64
- const T = {};
65
- return L.forEach((_) => {
66
- const A = F(
67
- _.toLowerCase()
68
- );
69
- E[_] !== void 0 && (T[A] = E[_]);
70
- }), S.forEach((_) => {
71
- const A = F(
72
- _.toLowerCase()
73
- );
74
- E[_] !== void 0 && (T[A] = E[_]);
75
- }), I.forEach((_) => {
76
- const A = F(
77
- _.toLowerCase()
78
- );
79
- E[_] !== void 0 && (T[A] = E[_]);
80
- }), T;
81
- })() : null;
63
+ }), O = e(
64
+ () => R && E ? (() => {
65
+ const T = {};
66
+ return L.forEach((_) => {
67
+ const A = F(
68
+ _.toLowerCase()
69
+ );
70
+ E[_] !== void 0 && (T[A] = E[_]);
71
+ }), S.forEach((_) => {
72
+ const A = F(
73
+ _.toLowerCase()
74
+ );
75
+ E[_] !== void 0 && (T[A] = E[_]);
76
+ }), I.forEach((_) => {
77
+ const A = F(
78
+ _.toLowerCase()
79
+ );
80
+ E[_] !== void 0 && (T[A] = E[_]);
81
+ }), T;
82
+ })() : {},
83
+ [R, E]
84
+ );
82
85
  if (R && E) {
83
86
  const _ = [
84
87
  ...L,
@@ -88,14 +91,14 @@ const l = () => {
88
91
  _.length > 0 && console.error("Missing feature flags:", _);
89
92
  }
90
93
  return {
91
- featureFlags: O ?? {},
94
+ featureFlags: O,
92
95
  loaded: R
93
96
  };
94
97
  };
95
98
  export {
96
- t as EAmountsDisplayFeature,
97
- e as EBookingPaymentMethod,
98
- s as EFlightBookingOptionsDisplayFeature,
99
- H as EThemeFeatureFlag,
100
- l as useFeatureFlags
99
+ s as EAmountsDisplayFeature,
100
+ H as EBookingPaymentMethod,
101
+ a as EFlightBookingOptionsDisplayFeature,
102
+ t as EThemeFeatureFlag,
103
+ i as useFeatureFlags
101
104
  };
@@ -1,6 +1,6 @@
1
1
  import { useQuery as n, useMutation as s } from "@tanstack/react-query";
2
2
  import "../../arrayExtensions-DlcBOj5a.js";
3
- import { E as a, d as m } from "../../noRetryInstance-C4bqpBc7.js";
3
+ import { E as a, d as u } from "../../noRetryInstance-C4bqpBc7.js";
4
4
  import "react";
5
5
  import "react/jsx-runtime";
6
6
  import "react-i18next";
@@ -16,41 +16,40 @@ import { useAwayzContext as c } from "../useAwayzContext.js";
16
16
  import "../../context/AwayzContext.js";
17
17
  import { WalletService as o } from "../../services/wallet/WalletService.js";
18
18
  const z = () => {
19
- const { user: e } = c(), { data: t } = n({
19
+ const { user: r } = c(), { data: t } = n({
20
20
  queryKey: [a.PROGRAMS],
21
21
  queryFn: o.getAwards,
22
22
  placeholderData: []
23
23
  }), { data: l } = n({
24
- queryKey: [a.USER_PROGRAMS, e == null ? void 0 : e.id],
25
- queryFn: () => e != null && e.id ? o.getUserAwards(e.id) : [],
24
+ queryKey: [a.USER_PROGRAMS, r == null ? void 0 : r.id],
25
+ queryFn: () => r != null && r.id ? o.getUserAwards(r.id) : [],
26
26
  placeholderData: [],
27
- enabled: !!(e != null && e.id)
27
+ enabled: !!(r != null && r.id)
28
28
  }), { data: y } = n({
29
- queryKey: [a.LINKED_USER_PROGRAMS, e == null ? void 0 : e.id],
30
- queryFn: () => e != null && e.id ? o.getLinkedUserAwards(e.id) : [],
29
+ queryKey: [a.LINKED_USER_PROGRAMS, r == null ? void 0 : r.id],
30
+ queryFn: () => r != null && r.id ? o.getLinkedUserAwards(r.id) : [],
31
31
  placeholderData: [],
32
- enabled: !!(e != null && e.id)
32
+ enabled: !!(r != null && r.id)
33
33
  }), { data: A } = n({
34
34
  queryKey: [a.BANKS],
35
35
  queryFn: o.getBanks,
36
36
  placeholderData: []
37
- }), { data: P } = n({
37
+ }), { data: g } = n({
38
38
  queryKey: [a.CARDS],
39
39
  queryFn: o.getCards,
40
40
  placeholderData: []
41
- }), { data: g } = n({
41
+ }), { data: P } = n({
42
42
  queryKey: [a.USER_CARDS],
43
43
  queryFn: o.getUserCards,
44
44
  placeholderData: []
45
- }), { featureFlags: p, featureFlagsLoaded: R, isAuthenticated: S } = c(), { data: C, isLoading: E } = n({
45
+ }), { featureFlags: R, featureFlagsLoaded: S, isAuthenticated: p } = c(), { data: C, isFetching: E } = n({
46
46
  queryKey: [a.POINTS_AS_CASH],
47
47
  queryFn: o.getPointsAsCash,
48
- placeholderData: { availablePoints: 0, valuePerPoint: 0, currency: "" },
49
- enabled: R && p.usePointsAsCashFeature && S
48
+ enabled: S && R.usePointsAsCashFeature && p
50
49
  }), { mutate: K } = s({
51
- mutationFn: async (r) => {
52
- const { mainProgram: u, awardsAmount: d } = typeof r == "string" ? { mainProgram: r, awardsAmount: 0 } : r;
53
- await o.addAwardProgram(u, d);
50
+ mutationFn: async (e) => {
51
+ const { mainProgram: m, awardsAmount: d } = typeof e == "string" ? { mainProgram: e, awardsAmount: 0 } : e;
52
+ await o.addAwardProgram(m, d);
54
53
  },
55
54
  onSuccess: () => {
56
55
  i.invalidateQueries({
@@ -58,8 +57,8 @@ const z = () => {
58
57
  });
59
58
  }
60
59
  }), { mutate: f } = s({
61
- mutationFn: async (r) => {
62
- await o.removeAwardProgram(r);
60
+ mutationFn: async (e) => {
61
+ await o.removeAwardProgram(e);
63
62
  },
64
63
  onSuccess: () => {
65
64
  i.invalidateQueries({
@@ -67,30 +66,30 @@ const z = () => {
67
66
  });
68
67
  }
69
68
  }), { mutateAsync: q } = s({
70
- mutationFn: async ({ mainProgram: r, awardsAmount: u }) => {
71
- const d = t == null ? void 0 : t.find((_) => _.mainProgram === r);
69
+ mutationFn: async ({ mainProgram: e, awardsAmount: m }) => {
70
+ const d = t == null ? void 0 : t.find((_) => _.mainProgram === e);
72
71
  if (!d)
73
72
  throw new Error("Program not found");
74
- return o.setAwardPoints(d.mainProgram, u);
73
+ return o.setAwardPoints(d.mainProgram, m);
75
74
  },
76
75
  onSuccess: () => {
77
76
  [
78
77
  a.LINKED_USER_PROGRAMS,
79
78
  a.USER_PROGRAMS,
80
79
  a.PROGRAMS
81
- ].forEach((r) => {
82
- i.invalidateQueries({ queryKey: [r] });
80
+ ].forEach((e) => {
81
+ i.invalidateQueries({ queryKey: [e] });
83
82
  });
84
83
  }
85
- }), { mutateAsync: h } = s({
86
- mutationFn: async (r) => o.addCardsToWallet(r),
84
+ }), { mutateAsync: F } = s({
85
+ mutationFn: async (e) => o.addCardsToWallet(e),
87
86
  onSuccess: () => {
88
87
  i.invalidateQueries({
89
88
  queryKey: [a.USER_CARDS]
90
89
  });
91
90
  }
92
- }), { mutateAsync: F } = s({
93
- mutationFn: async (r) => o.removeCardsFromWallet(r),
91
+ }), { mutateAsync: h } = s({
92
+ mutationFn: async (e) => o.removeCardsFromWallet(e),
94
93
  onSuccess: () => {
95
94
  i.invalidateQueries({
96
95
  queryKey: [a.USER_CARDS]
@@ -103,23 +102,23 @@ const z = () => {
103
102
  userPrograms: l || [],
104
103
  linkedUserPrograms: y || [],
105
104
  hotelPrograms: (t == null ? void 0 : t.filter(
106
- (r) => r.category.includes(m.HOTEL)
105
+ (e) => e.category.includes(u.HOTEL)
107
106
  )) || [],
108
107
  airlinePrograms: (t == null ? void 0 : t.filter(
109
- (r) => r.category.includes(m.AIRLINE)
108
+ (e) => e.category.includes(u.AIRLINE)
110
109
  )) || [],
111
110
  bankPrograms: (t == null ? void 0 : t.filter(
112
- (r) => r.category.includes(m.BANK)
111
+ (e) => e.category.includes(u.BANK)
113
112
  )) || [],
114
113
  updatePoints: q,
115
114
  addAwardProgram: K,
116
115
  removeAwardProgram: f,
117
116
  // Card Management
118
117
  banks: A || [],
119
- allCards: P || [],
120
- userCards: g || [],
121
- addCards: h,
122
- removeCards: F,
118
+ allCards: g || [],
119
+ userCards: P || [],
120
+ addCards: F,
121
+ removeCards: h,
123
122
  pointsAsCash: C || {
124
123
  availablePoints: 0,
125
124
  valuePerPoint: 0,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@odynn/awayz-core",
3
- "version": "0.10.5",
3
+ "version": "0.10.7",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"