@odynn/awayz-core 0.3.21 → 0.3.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.
Files changed (32) hide show
  1. package/dist/{AccountService-D_6U8vP6.js → AccountService-cvx__9rR.js} +55 -55
  2. package/dist/{TripsService-BbbkMtx6.js → TripsService-G1T_Co8r.js} +1 -1
  3. package/dist/components/CashValue/CashValue.js +198 -194
  4. package/dist/components/CashValue/CashValue.stories.js +30 -14
  5. package/dist/components/CashValue/CashValueTypes.js +3 -3
  6. package/dist/components/Wallet/Card/Card.stories.js +2 -2
  7. package/dist/hooks/useAwayzAuth/useAwayzAuth.js +1 -1
  8. package/dist/hooks/useBookingManagement/useBookingManagement.js +1 -1
  9. package/dist/hooks/useBookingManagement/useBookingManagement.test.js +1 -1
  10. package/dist/hooks/useSearchLimit.js +17 -15
  11. package/dist/hooks/useTripManagement/useTripManagement.js +2 -2
  12. package/dist/hooks/useTripManagement/useTripManagement.test.js +2 -2
  13. package/dist/hooks/useWallet/useWallet.js +72 -42
  14. package/dist/hooks/useWallet/useWallet.test.js +80 -46
  15. package/dist/lib/components/CashValue/CashValue.stories.d.ts +2 -0
  16. package/dist/lib/components/CashValue/CashValueTypes.d.ts +2 -0
  17. package/dist/lib/hooks/useSearchLimit.d.ts +3 -1
  18. package/dist/lib/hooks/useWallet/useWallet.types.d.ts +16 -2
  19. package/dist/lib/services/bookings/BookingService.d.ts +1 -1
  20. package/dist/lib/services/wallet/WalletService.d.ts +3 -0
  21. package/dist/main.js +1 -1
  22. package/dist/providers/AwayzProvider.js +1 -1
  23. package/dist/services/account/AccountService.js +1 -1
  24. package/dist/services/bookings/BookingService.js +1 -1
  25. package/dist/services/currency/CurrencyService.js +1 -1
  26. package/dist/services/index.js +1 -1
  27. package/dist/services/instance.js +1 -1
  28. package/dist/services/instanceConfig.js +1 -1
  29. package/dist/services/noRetryInstance.js +1 -1
  30. package/dist/services/trips/TripsService.js +2 -2
  31. package/dist/services/wallet/WalletService.js +55 -26
  32. package/package.json +1 -1
@@ -3,10 +3,10 @@ import { CashValue as n } from "./CashValue.js";
3
3
  import { AwayzProvider as a } from "../../providers/AwayzProvider.js";
4
4
  import "react";
5
5
  import "../../context/AwayzContext.js";
6
+ import "@tanstack/react-query";
6
7
  import "../../arrayExtensions-DlcBOj5a.js";
7
- import "../../AccountService-D_6U8vP6.js";
8
+ import "../../AccountService-cvx__9rR.js";
8
9
  import "../../configs/awayzClient.js";
9
- import "@tanstack/react-query";
10
10
  import { EAuthFlow as i } from "../../types/EAuthFlow.js";
11
11
  import "../../services/noRetryInstance.js";
12
12
  import { EToolTipPosition as t, EInvalidAmountDisplayOption as o } from "./CashValueTypes.js";
@@ -14,7 +14,7 @@ import '../../assets/_styles5.css';import '../../assets/_styles4.css';import '..
14
14
  /* empty css */
15
15
  /* empty css */
16
16
  /* empty css */
17
- const h = {
17
+ const f = {
18
18
  title: "Core/Cash Value",
19
19
  component: n,
20
20
  parameters: {
@@ -56,32 +56,46 @@ const h = {
56
56
  }
57
57
  )
58
58
  ]
59
- }, R = {
59
+ }, h = {
60
60
  name: "Euro to Dollar Cash Value",
61
61
  args: {
62
62
  amount: 100,
63
63
  currency: "EUR"
64
64
  }
65
- }, j = {
65
+ }, _ = {
66
66
  name: "Invalid Amount",
67
67
  args: {
68
68
  amount: "invalid",
69
69
  currency: "EUR"
70
70
  }
71
- }, C = {
71
+ }, v = {
72
72
  name: "Zero Amount with Display as Zero",
73
73
  args: {
74
74
  amount: 0,
75
75
  zeroDisplayOption: o.DISPLAY_AS_ZERO,
76
76
  currency: "EUR"
77
77
  }
78
- }, T = {
78
+ }, I = {
79
+ name: "Zero Amount with Display as Zero With Currency",
80
+ args: {
81
+ amount: 0,
82
+ zeroDisplayOption: o.DISPLAY_AS_ZERO_WITH_CURRENCY,
83
+ currency: "EUR"
84
+ }
85
+ }, U = {
86
+ name: "Zero Amount with Display as Zero With Currency No Decimal",
87
+ args: {
88
+ amount: 0,
89
+ zeroDisplayOption: o.DISPLAY_AS_ZERO_WITH_CURRENCY_NO_DECIMAL,
90
+ currency: "EUR"
91
+ }
92
+ }, b = {
79
93
  name: "Negative Amount",
80
94
  args: {
81
95
  amount: -100,
82
96
  currency: "EUR"
83
97
  }
84
- }, U = {
98
+ }, N = {
85
99
  name: "Custom Zero Amount",
86
100
  args: {
87
101
  amount: 0,
@@ -91,10 +105,12 @@ const h = {
91
105
  }
92
106
  };
93
107
  export {
94
- U as CustomZeroAmount,
95
- R as Default,
96
- j as InvalidAmount,
97
- T as NegativeAmount,
98
- C as ZeroAmount,
99
- h as default
108
+ N as CustomZeroAmount,
109
+ h as Default,
110
+ _ as InvalidAmount,
111
+ b as NegativeAmount,
112
+ v as ZeroAmount,
113
+ I as ZeroCurrencyAmount,
114
+ U as ZeroCurrencyNoDecimalAmount,
115
+ f as default
100
116
  };
@@ -1,5 +1,5 @@
1
- var e = /* @__PURE__ */ ((r) => (r.TOP = "top", r.BOTTOM = "bottom", r.RIGHT = "right", r.LEFT = "left", r))(e || {}), H = /* @__PURE__ */ ((r) => (r.NA = "N/A", r.HIDDEN = "Hidden", r.DISPLAY_AS_ZERO = "Display as Zero", r.CUSTOM = "Custom", r))(H || {});
1
+ var _ = /* @__PURE__ */ ((r) => (r.TOP = "top", r.BOTTOM = "bottom", r.RIGHT = "right", r.LEFT = "left", r))(_ || {}), e = /* @__PURE__ */ ((r) => (r.NA = "N/A", r.HIDDEN = "Hidden", r.DISPLAY_AS_ZERO = "Display as Zero", r.DISPLAY_AS_ZERO_WITH_CURRENCY = "Display as Zero with Currency", r.DISPLAY_AS_ZERO_WITH_CURRENCY_NO_DECIMAL = "Display as Zero with Currency (No Decimal)", r.CUSTOM = "Custom", r))(e || {});
2
2
  export {
3
- H as EInvalidAmountDisplayOption,
4
- e as EToolTipPosition
3
+ e as EInvalidAmountDisplayOption,
4
+ _ as EToolTipPosition
5
5
  };
@@ -3,10 +3,10 @@ import { Card as r } from "./Card.js";
3
3
  import { AwayzProvider as a } from "../../../providers/AwayzProvider.js";
4
4
  import "react";
5
5
  import "../../../context/AwayzContext.js";
6
+ import "@tanstack/react-query";
6
7
  import "../../../arrayExtensions-DlcBOj5a.js";
7
- import "../../../AccountService-D_6U8vP6.js";
8
+ import "../../../AccountService-cvx__9rR.js";
8
9
  import "../../../configs/awayzClient.js";
9
- import "@tanstack/react-query";
10
10
  import { EAuthFlow as e } from "../../../types/EAuthFlow.js";
11
11
  import "../../../services/noRetryInstance.js";
12
12
  import '../../../assets/_styles5.css';import '../../../assets/_styles4.css';import '../../../assets/_styles3.css';import '../../../assets/_styles.css';/* empty css */
@@ -1,5 +1,5 @@
1
1
  import "../../arrayExtensions-DlcBOj5a.js";
2
- import { f as U, d as r, A as o, E as v } from "../../AccountService-D_6U8vP6.js";
2
+ import { f as U, d as r, A as o, E as v } from "../../AccountService-cvx__9rR.js";
3
3
  import { useState as E, useCallback as R, useEffect as y } from "react";
4
4
  import { EAuthFlow as S } from "../../types/EAuthFlow.js";
5
5
  import { awayzClient as A } from "../../configs/awayzClient.js";
@@ -1,7 +1,7 @@
1
1
  import { useQuery as a, useMutation as s } from "@tanstack/react-query";
2
2
  import { EBookingType as e } from "../../services/trips/TripService.types.js";
3
3
  import "../../arrayExtensions-DlcBOj5a.js";
4
- import { E as t } from "../../AccountService-D_6U8vP6.js";
4
+ import { E as t } from "../../AccountService-cvx__9rR.js";
5
5
  import "react";
6
6
  import { BookingService as o } from "../../services/bookings/BookingService.js";
7
7
  import "react/jsx-runtime";
@@ -1,6 +1,6 @@
1
1
  import { renderHook as t, waitFor as r } from "../../tests/TestWrapper.js";
2
2
  import { useBookingManagement as a } from "./useBookingManagement.js";
3
- import { c as i } from "../../AccountService-D_6U8vP6.js";
3
+ import { c as i } from "../../AccountService-cvx__9rR.js";
4
4
  import "../../services/noRetryInstance.js";
5
5
  import "../../arrayExtensions-DlcBOj5a.js";
6
6
  import "react";
@@ -1,26 +1,28 @@
1
- import { E as s, A as i, b as n } from "../AccountService-D_6U8vP6.js";
2
1
  import { useQuery as u } from "@tanstack/react-query";
3
2
  import "../arrayExtensions-DlcBOj5a.js";
4
- import "react";
5
- import { useAwayzContext as c } from "./useAwayzContext.js";
6
- var o = /* @__PURE__ */ ((e) => (e.HOTEL = "Hotel", e.FLIGHT = "Flight", e))(o || {});
7
- const f = () => {
8
- const { isAuthenticated: e } = c(), { data: a } = u({
9
- queryKey: [s.SEARCH_LIMIT],
3
+ import { E as m, A as c, b as f } from "../AccountService-cvx__9rR.js";
4
+ import { useEffect as d } from "react";
5
+ import { useAwayzContext as y } from "./useAwayzContext.js";
6
+ var i = /* @__PURE__ */ ((r) => (r.HOTEL = "Hotel", r.FLIGHT = "Flight", r))(i || {});
7
+ const H = (r) => {
8
+ const { isAuthenticated: o } = y(), { data: t } = u({
9
+ queryKey: [m.SEARCH_LIMIT],
10
10
  queryFn: async () => {
11
- const { data: t, ...r } = await i.getRequestLimit();
12
- if (!r.success) {
13
- console.error({ reqLimitError: r });
11
+ const { data: s, ...e } = await c.getRequestLimit();
12
+ if (!e.success) {
13
+ console.error({ reqLimitError: e });
14
14
  return;
15
15
  }
16
- return n(t);
16
+ return f(s);
17
17
  },
18
- enabled: e
18
+ enabled: o
19
19
  });
20
- return a ? [o.FLIGHT, o.HOTEL].map(
21
- (t) => a.find((r) => r.searchType === t)
20
+ return d(() => {
21
+ t && (r == null || r());
22
+ }, [t, r]), t ? [i.FLIGHT, i.HOTEL].map(
23
+ (s) => t.find((e) => e.searchType === s)
22
24
  ) : [void 0, void 0];
23
25
  };
24
26
  export {
25
- f as useSearchLimit
27
+ H as useSearchLimit
26
28
  };
@@ -1,8 +1,8 @@
1
1
  import { useQuery as p, useMutation as s } from "@tanstack/react-query";
2
2
  import { h as m } from "../../arrayExtensions-DlcBOj5a.js";
3
- import { E as e } from "../../AccountService-D_6U8vP6.js";
3
+ import { E as e } from "../../AccountService-cvx__9rR.js";
4
4
  import "react";
5
- import { T as t } from "../../TripsService-BbbkMtx6.js";
5
+ import { T as t } from "../../TripsService-G1T_Co8r.js";
6
6
  import "react/jsx-runtime";
7
7
  import "../../context/AwayzContext.js";
8
8
  import { awayzClient as o } from "../../configs/awayzClient.js";
@@ -4,8 +4,8 @@ import { useTripManagement as n } from "./useTripManagement.js";
4
4
  import "react/jsx-runtime";
5
5
  import "react";
6
6
  import "../../context/AwayzContext.js";
7
- import { D as f } from "../../TripsService-BbbkMtx6.js";
8
- import { c } from "../../AccountService-D_6U8vP6.js";
7
+ import { D as f } from "../../TripsService-G1T_Co8r.js";
8
+ import { c } from "../../AccountService-cvx__9rR.js";
9
9
  import { EMyTripsEndpoints as d } from "../../configs/endpoints.js";
10
10
  import "../../configs/awayzClient.js";
11
11
  import "@tanstack/react-query";
@@ -1,86 +1,116 @@
1
- import { useQuery as o, useMutation as n } from "@tanstack/react-query";
1
+ import { useQuery as n, useMutation as i } from "@tanstack/react-query";
2
2
  import "../../arrayExtensions-DlcBOj5a.js";
3
- import { E as t, a as s } from "../../AccountService-D_6U8vP6.js";
3
+ import { E as t, a as d } from "../../AccountService-cvx__9rR.js";
4
4
  import "react";
5
- import { WalletService as a } from "../../services/wallet/WalletService.js";
6
5
  import "react/jsx-runtime";
7
6
  import "../../context/AwayzContext.js";
8
- import { awayzClient as i } from "../../configs/awayzClient.js";
7
+ import { awayzClient as s } from "../../configs/awayzClient.js";
8
+ import { useAwayzContext as f } 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 */
12
12
  /* empty css */
13
13
  /* empty css */
14
14
  /* empty css */
15
- const b = () => {
16
- const { data: r } = o({
15
+ import { WalletService as o } from "../../services/wallet/WalletService.js";
16
+ const B = () => {
17
+ const { user: e } = f(), { data: a } = n({
17
18
  queryKey: [t.PROGRAMS],
18
- queryFn: a.getAwards,
19
+ queryFn: o.getAwards,
19
20
  placeholderData: []
20
- }), { data: u } = o({
21
+ }), { data: y } = n({
22
+ queryKey: [t.USER_PROGRAMS, e == null ? void 0 : e.id],
23
+ queryFn: () => e != null && e.id ? o.getUserAwards(e.id) : [],
24
+ placeholderData: [],
25
+ enabled: !!(e != null && e.id)
26
+ }), { data: l } = n({
21
27
  queryKey: [t.BANKS],
22
- queryFn: a.getBanks,
28
+ queryFn: o.getBanks,
23
29
  placeholderData: []
24
- }), { data: l } = o({
30
+ }), { data: g } = n({
25
31
  queryKey: [t.CARDS],
26
- queryFn: a.getCards,
32
+ queryFn: o.getCards,
27
33
  placeholderData: []
28
- }), { data: c } = o({
34
+ }), { data: p } = n({
29
35
  queryKey: [t.USER_CARDS],
30
- queryFn: a.getUserCards,
36
+ queryFn: o.getUserCards,
31
37
  placeholderData: []
32
- }), { mutate: y } = n({
33
- mutationFn: async (e) => {
34
- const { mainProgram: g, awardsAmount: C } = e, m = r == null ? void 0 : r.find(
35
- (S) => S.mainProgram === g
38
+ }), { mutate: A } = i({
39
+ mutationFn: async (r) => {
40
+ const { mainProgram: m, awardsAmount: u } = typeof r == "string" ? { mainProgram: r, awardsAmount: 0 } : r;
41
+ await o.addAwardProgram(m, u);
42
+ },
43
+ onSuccess: () => {
44
+ s.invalidateQueries({
45
+ queryKey: [t.PROGRAMS]
46
+ });
47
+ }
48
+ }), { mutate: P } = i({
49
+ mutationFn: async (r) => {
50
+ await o.removeAwardProgram(r);
51
+ },
52
+ onSuccess: () => {
53
+ s.invalidateQueries({
54
+ queryKey: [t.PROGRAMS]
55
+ });
56
+ }
57
+ }), { mutate: R } = i({
58
+ mutationFn: async (r) => {
59
+ const { mainProgram: m, awardsAmount: u } = r, c = a == null ? void 0 : a.find(
60
+ (w) => w.mainProgram === m
36
61
  );
37
- if (!m)
62
+ if (!c)
38
63
  throw new Error("Program not found");
39
- await a.setAwardPoints(m.mainProgram, C);
64
+ await o.setAwardPoints(c.mainProgram, u);
40
65
  },
41
66
  onSuccess: () => {
42
- i.invalidateQueries({
67
+ s.invalidateQueries({
43
68
  queryKey: [t.PROGRAMS]
44
69
  });
45
70
  }
46
- }), { mutate: d } = n({
47
- mutationFn: async (e) => {
48
- await a.addCardsToWallet(e);
71
+ }), { mutate: S } = i({
72
+ mutationFn: async (r) => {
73
+ await o.addCardsToWallet(r);
49
74
  },
50
75
  onSuccess: () => {
51
- i.invalidateQueries({
76
+ s.invalidateQueries({
52
77
  queryKey: [t.USER_CARDS]
53
78
  });
54
79
  }
55
- }), { mutate: p } = n({
56
- mutationFn: async (e) => {
57
- await a.removeCardsFromWallet(e);
80
+ }), { mutate: C } = i({
81
+ mutationFn: async (r) => {
82
+ await o.removeCardsFromWallet(r);
58
83
  },
59
84
  onSuccess: () => {
60
- i.invalidateQueries({
85
+ s.invalidateQueries({
61
86
  queryKey: [t.USER_CARDS]
62
87
  });
63
88
  }
64
89
  });
65
90
  return {
66
- allPrograms: r || [],
67
- hotelPrograms: (r == null ? void 0 : r.filter(
68
- (e) => e.category.includes(s.HOTEL)
91
+ // Program Management
92
+ allPrograms: a || [],
93
+ userPrograms: y || [],
94
+ hotelPrograms: (a == null ? void 0 : a.filter(
95
+ (r) => r.category.includes(d.HOTEL)
69
96
  )) || [],
70
- airlinePrograms: (r == null ? void 0 : r.filter(
71
- (e) => e.category.includes(s.AIRLINE)
97
+ airlinePrograms: (a == null ? void 0 : a.filter(
98
+ (r) => r.category.includes(d.AIRLINE)
72
99
  )) || [],
73
- bankPrograms: (r == null ? void 0 : r.filter(
74
- (e) => e.category.includes(s.BANK)
100
+ bankPrograms: (a == null ? void 0 : a.filter(
101
+ (r) => r.category.includes(d.BANK)
75
102
  )) || [],
76
- updatePoints: y,
77
- banks: u || [],
78
- allCards: l || [],
79
- userCards: c || [],
80
- addCards: d,
81
- removeCards: p
103
+ updatePoints: R,
104
+ addAwardProgram: A,
105
+ removeAwardProgram: P,
106
+ // Car Management
107
+ banks: l || [],
108
+ allCards: g || [],
109
+ userCards: p || [],
110
+ addCards: S,
111
+ removeCards: C
82
112
  };
83
113
  };
84
114
  export {
85
- b as useWallet
115
+ B as useWallet
86
116
  };