@odynn/awayz-core 0.4.7 → 0.4.8

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