@odynn/awayz-core 0.3.11 → 0.3.12

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 (43) hide show
  1. package/dist/assets/_styles.css +1 -1
  2. package/dist/assets/_styles2.css +1 -1
  3. package/dist/assets/_styles3.css +1 -1
  4. package/dist/assets/_styles4.css +1 -1
  5. package/dist/assets/_styles5.css +1 -0
  6. package/dist/components/Bookings/FlightBooking/FlightBooking.js +2 -2
  7. package/dist/components/Bookings/HotelBooking/HotelBooking.js +2 -2
  8. package/dist/components/CashValue/CashValue.js +7 -5
  9. package/dist/components/CashValue/CashValue.stories.js +14 -13
  10. package/dist/components/Menu/Menu.js +11 -10
  11. package/dist/components/Wallet/Card/Card.js +35 -0
  12. package/dist/components/Wallet/Card/Card.stories.js +62 -0
  13. package/dist/components/index.js +6 -4
  14. package/dist/configs/endpoints.js +2 -2
  15. package/dist/hooks/useBookingManagement/useBookingManagement.js +57 -48
  16. package/dist/hooks/useBookingManagement/useBookingManagement.test.js +40 -39
  17. package/dist/hooks/useTripManagement/useTripManagement.js +4 -3
  18. package/dist/hooks/useTripManagement/useTripManagement.test.js +2 -1
  19. package/dist/hooks/useWallet/useWallet.js +52 -33
  20. package/dist/hooks/useWallet/useWallet.test.js +85 -15
  21. package/dist/hooks/useWallet/useWallet.types.js +1 -0
  22. package/dist/index-BC-KTkxU.js +1571 -0
  23. package/dist/index-CDh8vAM_.js +132 -0
  24. package/dist/lib/components/Wallet/Card/Card.d.ts +6 -0
  25. package/dist/lib/components/Wallet/Card/Card.stories.d.ts +14 -0
  26. package/dist/lib/components/index.d.ts +1 -0
  27. package/dist/lib/configs/endpoints.d.ts +2 -0
  28. package/dist/lib/hooks/useBookingManagement/mocks/HotelBooking200.json.d.ts +608 -67
  29. package/dist/lib/hooks/useBookingManagement/useBookingManagement.types.d.ts +8 -0
  30. package/dist/lib/hooks/useWallet/mocks/AllCardsResponse200.json.d.ts +177 -0
  31. package/dist/lib/hooks/useWallet/mocks/GetAllProgramsReponse200.json.d.ts +705 -0
  32. package/dist/lib/hooks/useWallet/mocks/UserCardsResponse200.json.d.ts +139 -0
  33. package/dist/lib/hooks/useWallet/useWallet.d.ts +2 -16
  34. package/dist/lib/hooks/useWallet/useWallet.types.d.ts +50 -0
  35. package/dist/lib/services/wallet/WalletService.d.ts +2 -0
  36. package/dist/lib/services/wallet/WalletService.types.d.ts +2 -5
  37. package/dist/main.js +20 -18
  38. package/dist/providers/AwayzProvider.js +4 -3
  39. package/dist/services/currency/CurrencyService.js +4 -3
  40. package/dist/services/wallet/WalletService.js +43 -63
  41. package/package.json +1 -1
  42. package/dist/index-COgXcb6p.js +0 -1696
  43. package/dist/lib/hooks/useWallet/mocks/CardsResponse.json.d.ts +0 -34
@@ -0,0 +1,139 @@
1
+ declare const _default: {
2
+ "data": [
3
+ {
4
+ "_id": "6830b5f8f8fd6ae84f4cc118",
5
+ "name": "Prestige",
6
+ "signupBonus": 50000,
7
+ "cashBonus": 0,
8
+ "minimumSpend": 4000,
9
+ "daysToSpend": 90,
10
+ "annual_fee": 495,
11
+ "annualFeeWaived": false,
12
+ "cashPerks": 300,
13
+ "bank": {
14
+ "name": "Citi"
15
+ },
16
+ "rewards_currency": "Citi ThankYou Points",
17
+ "bisCard": false,
18
+ "chargeCard": false,
19
+ "cardFamily": 11,
20
+ "websiteUrl": "",
21
+ "network": {
22
+ "name": "Mastercard"
23
+ },
24
+ "_modified": "2022-09-02T01:38:04.150Z",
25
+ "colour": "#1A3251",
26
+ "region": "US",
27
+ "faredrop_card_id": "",
28
+ "points_as_cash_conversion_ratio": 0.01,
29
+ "updatedAt": "2024-10-18T14:47:25.187Z",
30
+ "alternateRegions": [],
31
+ "logoUrl": "https://s3.us-east-1.amazonaws.com/awayz/card_logos/citi-white.svg",
32
+ "card_id": "CitiPrestige",
33
+ "user_id": "67d82b1c52c4a4dbe4e640c0",
34
+ "active_card": true
35
+ },
36
+ {
37
+ "_id": "6830b5f8f8fd6ae84f4cc119",
38
+ "name": "Sapphire Reserve",
39
+ "signupBonus": 60000,
40
+ "cashBonus": 0,
41
+ "minimumSpend": 4000,
42
+ "daysToSpend": 90,
43
+ "annual_fee": 550,
44
+ "annualFeeWaived": false,
45
+ "cashPerks": 0,
46
+ "bank": {
47
+ "name": "Chase"
48
+ },
49
+ "rewards_currency": "Chase Ultimate Rewards Points",
50
+ "bisCard": false,
51
+ "chargeCard": false,
52
+ "cardFamily": 21,
53
+ "websiteUrl": "https://yourbestcreditcards.com/card/chase-sapphire-reserve?ccid=ccref",
54
+ "network": {
55
+ "name": "Visa"
56
+ },
57
+ "_modified": "2023-10-10T07:20:51.860Z",
58
+ "colour": "#1A3251",
59
+ "region": "US",
60
+ "alternateRegions": ["CA"],
61
+ "faredrop_card_id": "chase-sapphire-reserve",
62
+ "points_as_cash_conversion_ratio": 0.015,
63
+ "updatedAt": "2024-10-18T14:47:25.187Z",
64
+ "logoUrl": "https://s3.us-east-1.amazonaws.com/awayz/card_logos/chase-white.svg",
65
+ "card_id": "SapphReserve",
66
+ "user_id": "67d82b1c52c4a4dbe4e640c0",
67
+ "active_card": true
68
+ },
69
+ {
70
+ "_id": "6835a6bef8fd6a342a14bfcd",
71
+ "name": "IHG Rewards Club Traveler",
72
+ "signupBonus": 0,
73
+ "cashBonus": 0,
74
+ "minimumSpend": 0,
75
+ "daysToSpend": 30,
76
+ "annual_fee": 0,
77
+ "annualFeeWaived": true,
78
+ "cashPerks": 0,
79
+ "bank": {
80
+ "name": "Chase"
81
+ },
82
+ "rewards_currency": "IHG Rewards Club",
83
+ "bisCard": false,
84
+ "chargeCard": false,
85
+ "cardFamily": 22,
86
+ "websiteUrl": "https://yourbestcreditcards.com/card/ihg-rewards-club-traveler-credit-card?ccid=ccref",
87
+ "network": {
88
+ "name": "Visa"
89
+ },
90
+ "_modified": "2022-09-02T00:53:47.499Z",
91
+ "colour": "#C8C8C8",
92
+ "region": "US",
93
+ "faredrop_card_id": "ihg-rewards-traveler-credit-card",
94
+ "alternateRegions": [],
95
+ "logoUrl": "https://s3.us-east-1.amazonaws.com/awayz/card_logos/chase-black.svg",
96
+ "card_id": "IHGcardTraveler",
97
+ "user_id": "67d82b1c52c4a4dbe4e640c0",
98
+ "active_card": true
99
+ },
100
+ {
101
+ "_id": "6835ac4df8fd6a87525def02",
102
+ "name": "IHG Rewards Club Premier",
103
+ "signupBonus": 140000,
104
+ "cashBonus": 0,
105
+ "minimumSpend": 3000,
106
+ "daysToSpend": 90,
107
+ "annual_fee": 89,
108
+ "annualFeeWaived": true,
109
+ "cashPerks": 0,
110
+ "bank": {
111
+ "name": "Chase"
112
+ },
113
+ "rewards_currency": "IHG Rewards Club",
114
+ "bisCard": false,
115
+ "chargeCard": false,
116
+ "cardFamily": 22,
117
+ "websiteUrl": "https://yourbestcreditcards.com/card/ihg-rewards-club-premier-credit-card?ccid=ccref",
118
+ "network": {
119
+ "name": "Visa"
120
+ },
121
+ "_modified": "2022-09-02T00:29:39.722Z",
122
+ "colour": "#C8C8C8",
123
+ "region": "US",
124
+ "faredrop_card_id": "ihg-rewards-premier-credit-card",
125
+ "alternateRegions": [],
126
+ "logoUrl": "https://s3.us-east-1.amazonaws.com/awayz/card_logos/chase-black.svg",
127
+ "card_id": "IHGcard",
128
+ "user_id": "67d82b1c52c4a4dbe4e640c0",
129
+ "active_card": true
130
+ }
131
+ ],
132
+ "success": true,
133
+ "metadata": {
134
+ "internalRequestId": "a0133305-71e4-40dd-97ec-3c1b57073a7e"
135
+ }
136
+ }
137
+ ;
138
+
139
+ export default _default;
@@ -1,16 +1,2 @@
1
- interface ISetAwardPointsRequest {
2
- programId: string;
3
- awardsAmount: number;
4
- }
5
- export declare const useWallet: () => {
6
- allPrograms: import('../../services').ILoyaltyProgram[];
7
- hotelPrograms: import('../../services').ILoyaltyProgram[];
8
- airlinePrograms: import('../../services').ILoyaltyProgram[];
9
- bankPrograms: import('../../services').ILoyaltyProgram[];
10
- updatePoints: import('@tanstack/react-query').UseMutateFunction<void, Error, ISetAwardPointsRequest, unknown>;
11
- getProgramById: (programId: string) => import('../../services').ILoyaltyProgram | null;
12
- banks: import('../../services').IBank[];
13
- allCards: import('../../services').ICard[];
14
- userCards: import('../../services').ICard[];
15
- };
16
- export {};
1
+ import { IWalletHook } from './useWallet.types';
2
+ export declare const useWallet: () => IWalletHook;
@@ -0,0 +1,50 @@
1
+ import { IBank, ICard, ILoyaltyProgram } from '../../services';
2
+ export interface ISetAwardPointsRequest {
3
+ mainProgram: string;
4
+ awardsAmount: number;
5
+ }
6
+ export interface IWalletHook {
7
+ /**
8
+ * All loyalty programs currently supported by Awayz.
9
+ */
10
+ allPrograms: ILoyaltyProgram[];
11
+ /**
12
+ * Supported loyalty programs related to hotels.
13
+ */
14
+ hotelPrograms: ILoyaltyProgram[];
15
+ /**
16
+ * Supported loyalty programs related to airlines.
17
+ */
18
+ airlinePrograms: ILoyaltyProgram[];
19
+ /**
20
+ * Supported loyalty programs related to banks.
21
+ */
22
+ bankPrograms: ILoyaltyProgram[];
23
+ /**
24
+ * Updates the points for a specific loyalty program.
25
+ * @param request - The request object containing the main program and the amount of points/miles.
26
+ */
27
+ updatePoints: (request: ISetAwardPointsRequest) => void;
28
+ /**
29
+ * List of banks currently supported by Awayz.
30
+ */
31
+ banks: IBank[];
32
+ /**
33
+ * All cards available in the system.
34
+ */
35
+ allCards: ICard[];
36
+ /**
37
+ * User's cards that are currently in the wallet.
38
+ */
39
+ userCards: ICard[];
40
+ /**
41
+ * Adds cards to the user's wallet.
42
+ * @param cardIds - The IDs of the cards to be added.
43
+ */
44
+ addCards: (cardIds: string[]) => void;
45
+ /**
46
+ * Removes cards from the user's wallet.
47
+ * @param cardIds - The IDs of the cards to be removed.
48
+ */
49
+ removeCards: (cardIds: string[]) => void;
50
+ }
@@ -5,6 +5,8 @@ declare class _WalletService {
5
5
  getBanks: () => Promise<IBank[]>;
6
6
  getCards: () => Promise<ICard[]>;
7
7
  getUserCards: () => Promise<ICard[]>;
8
+ addCardsToWallet: (cardIds: string[]) => Promise<any>;
9
+ removeCardsFromWallet: (cardIds: string[]) => Promise<any>;
8
10
  }
9
11
  export declare const WalletService: _WalletService;
10
12
  export {};
@@ -9,7 +9,7 @@ export interface IStatusLevels {
9
9
  export interface ILoyaltyProgram {
10
10
  id: string;
11
11
  mainProgram: string;
12
- category: ERewardProgramCategory;
12
+ category: ERewardProgramCategory[];
13
13
  statusLevels: IStatusLevels;
14
14
  displayProgram: string;
15
15
  awayzActive: string[];
@@ -55,11 +55,8 @@ export interface ICard {
55
55
  network: {
56
56
  name: string;
57
57
  };
58
- modified: string;
59
58
  colour: string;
60
59
  region: string;
61
60
  alternateRegions: string[];
62
- cardId: string;
63
- userId: string;
64
- activeCard: boolean;
61
+ logoUrl: string;
65
62
  }
package/dist/main.js CHANGED
@@ -1,41 +1,43 @@
1
- import { AwayzProvider as r } from "./providers/AwayzProvider.js";
2
- import { useAwayzContext as n } from "./hooks/useAwayzContext.js";
3
- import { useSearchLimit as i } from "./hooks/useSearchLimit.js";
1
+ import { AwayzProvider as e } from "./providers/AwayzProvider.js";
2
+ import { useAwayzContext as p } from "./hooks/useAwayzContext.js";
3
+ import { useSearchLimit as a } from "./hooks/useSearchLimit.js";
4
4
  import { useWallet as m } from "./hooks/useWallet/useWallet.js";
5
5
  import { useTripManagement as f, validateUpdateTripArgs as l } from "./hooks/useTripManagement/useTripManagement.js";
6
6
  import { useBookingManagement as c } from "./hooks/useBookingManagement/useBookingManagement.js";
7
7
  import { EAuthFlow as y } from "./types/EAuthFlow.js";
8
- import { EHotelCurrencyOption as A, currencySymbols as B } from "./types/ECurrency.js";
9
- import { c as E, i as T } from "./AccountService-D_6U8vP6.js";
8
+ import { EHotelCurrencyOption as C, currencySymbols as d } from "./types/ECurrency.js";
9
+ import { c as B, i as E } from "./AccountService-D_6U8vP6.js";
10
10
  import { clientNoRetryInstance as h } from "./services/noRetryInstance.js";
11
11
  import { CurrencyService as v } from "./services/currency/CurrencyService.js";
12
12
  import { EBookingType as z } from "./services/trips/TripService.types.js";
13
13
  import { awayzClient as S } from "./configs/awayzClient.js";
14
14
  import { CashValue as H } from "./components/CashValue/CashValue.js";
15
15
  import { EInvalidAmountDisplayOption as O, EToolTipPosition as P } from "./components/CashValue/CashValueTypes.js";
16
- import { FlightBooking as b } from "./components/Bookings/FlightBooking/FlightBooking.js";
17
- import { HotelBooking as L } from "./components/Bookings/HotelBooking/HotelBooking.js";
18
- import { getBaseUrl as R } from "./configs/baseUrl.js";
16
+ import { Card as b } from "./components/Wallet/Card/Card.js";
17
+ import { FlightBooking as L } from "./components/Bookings/FlightBooking/FlightBooking.js";
18
+ import { HotelBooking as R } from "./components/Bookings/HotelBooking/HotelBooking.js";
19
+ import { getBaseUrl as W } from "./configs/baseUrl.js";
19
20
  export {
20
- r as AwayzProvider,
21
+ e as AwayzProvider,
22
+ b as Card,
21
23
  H as CashValue,
22
24
  v as CurrencyService,
23
25
  y as EAuthFlow,
24
26
  z as EBookingType,
25
- A as EHotelCurrencyOption,
27
+ C as EHotelCurrencyOption,
26
28
  O as EInvalidAmountDisplayOption,
27
29
  P as EToolTipPosition,
28
- b as FlightBooking,
29
- L as HotelBooking,
30
+ L as FlightBooking,
31
+ R as HotelBooking,
30
32
  S as awayzClient,
31
- E as clientInstance,
33
+ B as clientInstance,
32
34
  h as clientNoRetryInstance,
33
- B as currencySymbols,
34
- R as getBaseUrl,
35
- T as instance,
36
- n as useAwayzContext,
35
+ d as currencySymbols,
36
+ W as getBaseUrl,
37
+ E as instance,
38
+ p as useAwayzContext,
37
39
  c as useBookingManagement,
38
- i as useSearchLimit,
40
+ a as useSearchLimit,
39
41
  f as useTripManagement,
40
42
  m as useWallet,
41
43
  l as validateUpdateTripArgs
@@ -8,12 +8,13 @@ import { setCustomBaseUrl as i, setBaseUrl as u } from "../configs/baseUrl.js";
8
8
  import { QueryClientProvider as d } from "@tanstack/react-query";
9
9
  import { awayzClient as p } from "../configs/awayzClient.js";
10
10
  import "../services/noRetryInstance.js";
11
- import '../assets/_styles4.css';import '../assets/_styles3.css';import '../assets/_styles2.css';import '../assets/_styles.css';/* empty css */
11
+ import '../assets/_styles5.css';import '../assets/_styles4.css';import '../assets/_styles3.css';import '../assets/_styles2.css';import '../assets/_styles.css';/* empty css */
12
+ /* empty css */
12
13
  /* empty css */
13
14
  /* empty css */
14
15
  /* empty css */
15
16
  import { defaultAwayzConfig as h } from "../configs/defaultAwayzConfig.js";
16
- const U = ({ children: o, config: e }) => {
17
+ const B = ({ children: o, config: e }) => {
17
18
  const s = l({
18
19
  authFlow: e.authFlow,
19
20
  onSuccess: e.onAuthSuccess,
@@ -41,5 +42,5 @@ const U = ({ children: o, config: e }) => {
41
42
  ) });
42
43
  };
43
44
  export {
44
- U as AwayzProvider
45
+ B as AwayzProvider
45
46
  };
@@ -1,4 +1,4 @@
1
- import '../../assets/_styles4.css';import '../../assets/_styles3.css';import '../../assets/_styles2.css';import '../../assets/_styles.css';var u = Object.defineProperty;
1
+ import '../../assets/_styles5.css';import '../../assets/_styles4.css';import '../../assets/_styles3.css';import '../../assets/_styles2.css';import '../../assets/_styles.css';var u = Object.defineProperty;
2
2
  var y = (t, r, e) => r in t ? u(t, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[r] = e;
3
3
  var n = (t, r, e) => y(t, typeof r != "symbol" ? r + "" : r, e);
4
4
  import "../../arrayExtensions-DlcBOj5a.js";
@@ -11,6 +11,7 @@ import { awayzClient as C } from "../../configs/awayzClient.js";
11
11
  import "@tanstack/react-query";
12
12
  import "../noRetryInstance.js";
13
13
  /* empty css */
14
+ /* empty css */
14
15
  /* empty css */
15
16
  /* empty css */
16
17
  /* empty css */
@@ -65,7 +66,7 @@ class E {
65
66
  });
66
67
  }
67
68
  }
68
- const K = new E();
69
+ const b = new E();
69
70
  export {
70
- K as CurrencyService
71
+ b as CurrencyService
71
72
  };
@@ -1,86 +1,66 @@
1
- var y = Object.defineProperty;
2
- var w = (e, a, t) => a in e ? y(e, a, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[a] = t;
3
- var s = (e, a, t) => w(e, typeof a != "symbol" ? a + "" : a, t);
1
+ var d = Object.defineProperty;
2
+ var i = (n, a, t) => a in n ? d(n, a, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[a] = t;
3
+ var s = (n, a, t) => i(n, typeof a != "symbol" ? a + "" : a, t);
4
4
  import "../../arrayExtensions-DlcBOj5a.js";
5
- import { a as o, c, b as n } from "../../AccountService-D_6U8vP6.js";
5
+ import { c as r, b as c } from "../../AccountService-D_6U8vP6.js";
6
6
  import "react";
7
- import { EWalletEndpoints as i } from "../../configs/endpoints.js";
8
- class E {
7
+ import { EWalletEndpoints as e } from "../../configs/endpoints.js";
8
+ class l {
9
9
  constructor() {
10
10
  s(this, "getAwards", async () => {
11
- var a, t, l;
12
- try {
13
- const m = [
14
- o.HOTEL,
15
- o.BANK,
16
- o.AIRLINE
17
- ], [
18
- { data: d },
19
- { data: g },
20
- { data: u }
21
- ] = await Promise.all(
22
- m.map(
23
- (r) => c.get(
24
- i.USER_AWARDS,
25
- {
26
- params: { category: r }
27
- }
28
- )
29
- )
30
- ), p = ((a = d.data) == null ? void 0 : a.map(
31
- (r) => n({
32
- ...r,
33
- ctegory: o.HOTEL
34
- })
35
- )) ?? [], A = ((t = g.data) == null ? void 0 : t.map(
36
- (r) => n({
37
- ...r,
38
- ctegory: o.BANK
39
- })
40
- )) ?? [], R = ((l = u.data) == null ? void 0 : l.map(
41
- (r) => n({
42
- ...r,
43
- ctegory: o.AIRLINE
44
- })
45
- )) ?? [];
46
- return [
47
- ...p,
48
- ...A,
49
- ...R
50
- ];
51
- } catch (m) {
52
- console.error(m);
53
- }
54
- return [];
11
+ const {
12
+ data: { data: a }
13
+ } = await r.get(
14
+ e.USER_AWARDS
15
+ );
16
+ return c(a);
55
17
  });
56
18
  s(this, "setAwardPoints", async (a, t) => {
57
- const { data: l } = await c.put(i.USER_AWARDS, {
19
+ const { data: o } = await r.put(e.USER_AWARDS, {
58
20
  main_program: a,
59
21
  amount: t
60
22
  });
61
- return l;
23
+ return o;
62
24
  });
63
25
  s(this, "getBanks", async () => {
64
- const { data: a } = await c.get(
65
- i.BANKS
26
+ const { data: a } = await r.get(
27
+ e.BANKS
66
28
  );
67
- return a.success ? a.data.map((t) => n(t)) : [];
29
+ return a.success ? a.data.map((t) => c(t)) : [];
68
30
  });
69
31
  s(this, "getCards", async () => {
70
- const { data: a } = await c.get(
71
- i.CARDS
32
+ const { data: a } = await r.get(
33
+ e.CARDS
72
34
  );
73
- return a.success ? a.data.map((t) => n(t)) : [];
35
+ return a.success ? a.data.map((t) => c(t)) : [];
74
36
  });
75
37
  s(this, "getUserCards", async () => {
76
- const { data: a } = await c.get(
77
- i.USER_CARDS
38
+ const { data: a } = await r.get(
39
+ e.USER_CARDS
40
+ );
41
+ return a.success ? a.data.map((t) => c(t)) : [];
42
+ });
43
+ s(this, "addCardsToWallet", async (a) => {
44
+ const { data: t } = await r.post(
45
+ e.ADD_USER_CARDS,
46
+ {
47
+ card_ids: a
48
+ }
49
+ );
50
+ return t;
51
+ });
52
+ s(this, "removeCardsFromWallet", async (a) => {
53
+ const { data: t } = await r.post(
54
+ e.REMOVE_USER_CARDS,
55
+ {
56
+ card_ids: a
57
+ }
78
58
  );
79
- return a.success ? a.data.map((t) => n(t)) : [];
59
+ return t;
80
60
  });
81
61
  }
82
62
  }
83
- const W = new E();
63
+ const R = new l();
84
64
  export {
85
- W as WalletService
65
+ R as WalletService
86
66
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@odynn/awayz-core",
3
- "version": "0.3.11",
3
+ "version": "0.3.12",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"