@odynn/awayz-core 0.9.21 → 0.9.23

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,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 u } from "../../noRetryInstance-DKhe8ju0.js";
3
+ import { E as a, d as m } from "../../noRetryInstance-DKhe8ju0.js";
4
4
  import "react";
5
5
  import "react/jsx-runtime";
6
6
  import "react-i18next";
@@ -11,25 +11,25 @@ import { awayzClient as i } from "../../configs/awayzClient.js";
11
11
  /* empty css */
12
12
  /* empty css */
13
13
  import "../../index-Cv-wvFlM.js";
14
- import { useAwayzContext as l } from "../useAwayzContext.js";
14
+ import { useAwayzContext as c } from "../useAwayzContext.js";
15
15
  /* empty css */
16
16
  import "../../context/AwayzContext.js";
17
17
  import { WalletService as o } from "../../services/wallet/WalletService.js";
18
- const T = () => {
19
- const { user: r } = l(), { data: t } = n({
18
+ const x = () => {
19
+ const { user: e } = c(), { data: t } = n({
20
20
  queryKey: [a.PROGRAMS],
21
21
  queryFn: o.getAwards,
22
22
  placeholderData: []
23
- }), { data: c } = n({
24
- queryKey: [a.USER_PROGRAMS, r == null ? void 0 : r.id],
25
- queryFn: () => r != null && r.id ? o.getUserAwards(r.id) : [],
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) : [],
26
26
  placeholderData: [],
27
- enabled: !!(r != null && r.id)
27
+ enabled: !!(e != null && e.id)
28
28
  }), { data: y } = n({
29
- queryKey: [a.LINKED_USER_PROGRAMS, r == null ? void 0 : r.id],
30
- queryFn: () => r != null && r.id ? o.getLinkedUserAwards(r.id) : [],
29
+ queryKey: [a.LINKED_USER_PROGRAMS, e == null ? void 0 : e.id],
30
+ queryFn: () => e != null && e.id ? o.getLinkedUserAwards(e.id) : [],
31
31
  placeholderData: [],
32
- enabled: !!(r != null && r.id)
32
+ enabled: !!(e != null && e.id)
33
33
  }), { data: A } = n({
34
34
  queryKey: [a.BANKS],
35
35
  queryFn: o.getBanks,
@@ -42,55 +42,55 @@ const T = () => {
42
42
  queryKey: [a.USER_CARDS],
43
43
  queryFn: o.getUserCards,
44
44
  placeholderData: []
45
- }), { featureFlags: R, featureFlagsLoaded: S } = l(), { data: p } = n({
45
+ }), { featureFlags: R, featureFlagsLoaded: S, isAuthenticated: p } = c(), { data: C } = n({
46
46
  queryKey: [a.POINTS_AS_CASH],
47
47
  queryFn: o.getPointsAsCash,
48
48
  placeholderData: { availablePoints: 0, valuePerPoint: 0, currency: "" },
49
- enabled: S && R.usePointsAsCashFeature
50
- }), { mutate: C } = s({
51
- mutationFn: async (e) => {
52
- const { mainProgram: m, awardsAmount: d } = typeof e == "string" ? { mainProgram: e, awardsAmount: 0 } : e;
53
- await o.addAwardProgram(m, d);
49
+ enabled: S && R.usePointsAsCashFeature && p
50
+ }), { mutate: E } = 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);
54
54
  },
55
55
  onSuccess: () => {
56
56
  i.invalidateQueries({
57
57
  queryKey: [a.LINKED_USER_PROGRAMS]
58
58
  });
59
59
  }
60
- }), { mutate: E } = s({
61
- mutationFn: async (e) => {
62
- await o.removeAwardProgram(e);
60
+ }), { mutate: K } = s({
61
+ mutationFn: async (r) => {
62
+ await o.removeAwardProgram(r);
63
63
  },
64
64
  onSuccess: () => {
65
65
  i.invalidateQueries({
66
66
  queryKey: [a.LINKED_USER_PROGRAMS]
67
67
  });
68
68
  }
69
- }), { mutateAsync: K } = s({
70
- mutationFn: async ({ mainProgram: e, awardsAmount: m }) => {
71
- const d = t == null ? void 0 : t.find((F) => F.mainProgram === e);
69
+ }), { mutateAsync: f } = s({
70
+ mutationFn: async ({ mainProgram: r, awardsAmount: u }) => {
71
+ const d = t == null ? void 0 : t.find((h) => h.mainProgram === r);
72
72
  if (!d)
73
73
  throw new Error("Program not found");
74
- return o.setAwardPoints(d.mainProgram, m);
74
+ return o.setAwardPoints(d.mainProgram, u);
75
75
  },
76
76
  onSuccess: () => {
77
77
  [
78
78
  a.LINKED_USER_PROGRAMS,
79
79
  a.USER_PROGRAMS,
80
80
  a.PROGRAMS
81
- ].forEach((e) => {
82
- i.invalidateQueries({ queryKey: [e] });
81
+ ].forEach((r) => {
82
+ i.invalidateQueries({ queryKey: [r] });
83
83
  });
84
84
  }
85
- }), { mutateAsync: f } = s({
86
- mutationFn: async (e) => o.addCardsToWallet(e),
85
+ }), { mutateAsync: q } = s({
86
+ mutationFn: async (r) => o.addCardsToWallet(r),
87
87
  onSuccess: () => {
88
88
  i.invalidateQueries({
89
89
  queryKey: [a.USER_CARDS]
90
90
  });
91
91
  }
92
- }), { mutateAsync: q } = s({
93
- mutationFn: async (e) => o.removeCardsFromWallet(e),
92
+ }), { mutateAsync: F } = s({
93
+ mutationFn: async (r) => o.removeCardsFromWallet(r),
94
94
  onSuccess: () => {
95
95
  i.invalidateQueries({
96
96
  queryKey: [a.USER_CARDS]
@@ -100,27 +100,27 @@ const T = () => {
100
100
  return {
101
101
  // Program Management
102
102
  allPrograms: t || [],
103
- userPrograms: c || [],
103
+ userPrograms: l || [],
104
104
  linkedUserPrograms: y || [],
105
105
  hotelPrograms: (t == null ? void 0 : t.filter(
106
- (e) => e.category.includes(u.HOTEL)
106
+ (r) => r.category.includes(m.HOTEL)
107
107
  )) || [],
108
108
  airlinePrograms: (t == null ? void 0 : t.filter(
109
- (e) => e.category.includes(u.AIRLINE)
109
+ (r) => r.category.includes(m.AIRLINE)
110
110
  )) || [],
111
111
  bankPrograms: (t == null ? void 0 : t.filter(
112
- (e) => e.category.includes(u.BANK)
112
+ (r) => r.category.includes(m.BANK)
113
113
  )) || [],
114
- updatePoints: K,
115
- addAwardProgram: C,
116
- removeAwardProgram: E,
114
+ updatePoints: f,
115
+ addAwardProgram: E,
116
+ removeAwardProgram: K,
117
117
  // Card Management
118
118
  banks: A || [],
119
119
  allCards: P || [],
120
120
  userCards: g || [],
121
- addCards: f,
122
- removeCards: q,
123
- pointsAsCash: p || {
121
+ addCards: q,
122
+ removeCards: F,
123
+ pointsAsCash: C || {
124
124
  availablePoints: 0,
125
125
  valuePerPoint: 0,
126
126
  currency: ""
@@ -128,5 +128,5 @@ const T = () => {
128
128
  };
129
129
  };
130
130
  export {
131
- T as useWallet
131
+ x as useWallet
132
132
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@odynn/awayz-core",
3
- "version": "0.9.21",
3
+ "version": "0.9.23",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"