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