@odynn/awayz-core 0.2.30 → 0.2.31

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.
@@ -2,7 +2,7 @@ import { jsx as x, Fragment as yn, jsxs as K } from "react/jsx-runtime";
2
2
  import * as f from "react";
3
3
  import ne, { useLayoutEffect as vn, useEffect as wn, useMemo as xn } from "react";
4
4
  import { r as bt, R as bn } from "../../index-B7QVGqcx.js";
5
- import { E as Cn } from "../../AccountService-BLoJ4G-f.js";
5
+ import { E as Cn } from "../../AccountService-8OR0UkZ6.js";
6
6
  import { useQuery as En } from "@tanstack/react-query";
7
7
  import { CurrencyService as Pn } from "../../services/currency/CurrencyService.js";
8
8
  import '../../assets/_styles.css';/* empty css */
@@ -3,7 +3,7 @@ import { CashValue as r } 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 "../../AccountService-BLoJ4G-f.js";
6
+ import "../../AccountService-8OR0UkZ6.js";
7
7
  import "../../configs/awayzClient.js";
8
8
  import "@tanstack/react-query";
9
9
  import { EAuthFlow as s } from "../../types/EAuthFlow.js";
@@ -1,6 +1,6 @@
1
- var r = /* @__PURE__ */ ((e) => (e.SIGN_IN = "auth/user-login", e.SIGN_UP = "auth/sign-up", e.ME = "user", e.RESEND_VERIFICATION_EMAIL = "auth/resend-verification-email", e.UPDATE_USER_DETAILS = "account/update/user", e.CONFIRM_EMAIL = "account/verifyAccount", e.FORGOT_PASSWORD = "email/sendVeri", e.RESEND_OTP = "email/sendForgotPasswordVerification", e.RESET_PASSWORD = "account/updateUserPassword", e.REQUEST_LIMIT = "user/request-limit", e.APPLE_SOCIAL_SIGN_UP = "tp/apple/get/user", e.GOOGLE_SOCIAL_SIGN_UP = "tp/google/get/user", e.UPDATE_USER = "account/details/addUserDetails", e.ACKNOWLEDGEMENT = "account/update/userAcknowledgement", e.REGIONS = "user/region", e.UPDATE_USER_REGION = "/account/update/userRegion", e.UPDATE_PASSENGER_DETAILS = "/account/awayz", e.REFRESH_TOKEN = "auth/refresh-token", e.EXCHANGE_TOKEN = "user/exchange-token", e.REFRESH_EMBED_TOKEN = "user/refresh-token", e.OAUTH_INITIATE = "user/oauth2/initiate", e.OAUTH_CALLBACK = "user/oauth2/callback", e))(r || {}), a = /* @__PURE__ */ ((e) => (e.CURRENCY_CONVERSION = "currency/convert", e))(a || {}), _ = /* @__PURE__ */ ((e) => (e.USER_AWARDS = "user/rewards", e.BANKS = "banks", e.CARDS = "cards", e))(_ || {});
1
+ var r = /* @__PURE__ */ ((e) => (e.SIGN_IN = "auth/user-login", e.SIGN_UP = "auth/sign-up", e.ME = "user", e.RESEND_VERIFICATION_EMAIL = "auth/resend-verification-email", e.UPDATE_USER_DETAILS = "account/update/user", e.CONFIRM_EMAIL = "account/verifyAccount", e.FORGOT_PASSWORD = "email/sendVeri", e.RESEND_OTP = "email/sendForgotPasswordVerification", e.RESET_PASSWORD = "account/updateUserPassword", e.REQUEST_LIMIT = "user/request-limit", e.APPLE_SOCIAL_SIGN_UP = "tp/apple/get/user", e.GOOGLE_SOCIAL_SIGN_UP = "tp/google/get/user", e.UPDATE_USER = "account/details/addUserDetails", e.ACKNOWLEDGEMENT = "account/update/userAcknowledgement", e.REGIONS = "user/region", e.UPDATE_USER_REGION = "/account/update/userRegion", e.UPDATE_PASSENGER_DETAILS = "/account/awayz", e.REFRESH_TOKEN = "auth/refresh-token", e.EXCHANGE_TOKEN = "user/exchange-token", e.REFRESH_EMBED_TOKEN = "user/refresh-token", e.OAUTH_INITIATE = "user/oauth2/initiate", e.OAUTH_CALLBACK = "user/oauth2/callback", e))(r || {}), a = /* @__PURE__ */ ((e) => (e.CURRENCY_CONVERSION = "currency/convert", e))(a || {}), S = /* @__PURE__ */ ((e) => (e.USER_AWARDS = "user/rewards", e.USER_CARDS = "user/cards", e.BANKS = "banks", e.CARDS = "cards", e))(S || {});
2
2
  export {
3
3
  r as EAuthEndpoints,
4
4
  a as ECurrencyEndpoints,
5
- _ as EWalletEndpoints
5
+ S as EWalletEndpoints
6
6
  };
@@ -1,4 +1,4 @@
1
- import { A as U, d as r, e as o, E as v } from "../../AccountService-BLoJ4G-f.js";
1
+ import { A as U, d as r, e as o, E as v } from "../../AccountService-8OR0UkZ6.js";
2
2
  import { useState as E, useCallback as R, useEffect as y } from "react";
3
3
  import { EAuthFlow as S } from "../../types/EAuthFlow.js";
4
4
  import { awayzClient as A } from "../../configs/awayzClient.js";
@@ -1,4 +1,4 @@
1
- import { E as s, e as i, b as n } from "../AccountService-BLoJ4G-f.js";
1
+ import { E as s, e as i, b as n } from "../AccountService-8OR0UkZ6.js";
2
2
  import { useQuery as u } from "@tanstack/react-query";
3
3
  import "react";
4
4
  import { useAwayzContext as c } from "./useAwayzContext.js";
@@ -1,58 +1,63 @@
1
- import { useQuery as m, useMutation as p } from "@tanstack/react-query";
2
- import { E as t, a as u } from "../../AccountService-BLoJ4G-f.js";
1
+ import { useQuery as a, useMutation as d } from "@tanstack/react-query";
2
+ import { E as o, a as m } from "../../AccountService-8OR0UkZ6.js";
3
3
  import "react";
4
- import { WalletService as n } from "../../services/wallet/WalletService.js";
4
+ import { WalletService as t } from "../../services/wallet/WalletService.js";
5
5
  import "react/jsx-runtime";
6
6
  import "../../context/AwayzContext.js";
7
- import { awayzClient as d } from "../../configs/awayzClient.js";
7
+ import { awayzClient as f } from "../../configs/awayzClient.js";
8
8
  import "../../services/noRetryInstance.js";
9
9
  import '../../assets/_styles.css';/* empty css */
10
- const B = () => {
11
- const { data: r } = m({
12
- queryKey: [t.PROGRAMS],
13
- queryFn: n.getAwards,
10
+ const F = () => {
11
+ const { data: r } = a({
12
+ queryKey: [o.PROGRAMS],
13
+ queryFn: t.getAwards,
14
14
  placeholderData: []
15
- }), { data: s } = m({
16
- queryKey: [t.BANKS],
17
- queryFn: n.getBanks,
15
+ }), { data: u } = a({
16
+ queryKey: [o.BANKS],
17
+ queryFn: t.getBanks,
18
18
  placeholderData: []
19
- }), { data: l } = m({
20
- queryKey: [t.CARDS],
21
- queryFn: n.getCards,
19
+ }), { data: l } = a({
20
+ queryKey: [o.CARDS],
21
+ queryFn: t.getCards,
22
22
  placeholderData: []
23
- }), { mutate: y } = p({
23
+ }), { data: y } = a({
24
+ queryKey: [o.USER_CARDS],
25
+ queryFn: t.getUserCards,
26
+ placeholderData: []
27
+ }), { mutate: c } = d({
24
28
  mutationFn: async (e) => {
25
- const { programId: o, awardsAmount: i } = e, a = r == null ? void 0 : r.find((g) => g.id === o);
26
- if (!a)
29
+ const { programId: n, awardsAmount: i } = e, s = r == null ? void 0 : r.find((p) => p.id === n);
30
+ if (!s)
27
31
  throw new Error("Program not found");
28
- await n.setAwardPoints(a.mainProgram, i);
32
+ await t.setAwardPoints(s.mainProgram, i);
29
33
  },
30
34
  onSuccess: () => {
31
- d.invalidateQueries({
32
- queryKey: [t.PROGRAMS]
35
+ f.invalidateQueries({
36
+ queryKey: [o.PROGRAMS]
33
37
  });
34
38
  }
35
- }), c = (e) => {
36
- const o = r == null ? void 0 : r.find((i) => i.id === e);
37
- return o || null;
39
+ }), g = (e) => {
40
+ const n = r == null ? void 0 : r.find((i) => i.id === e);
41
+ return n || null;
38
42
  };
39
43
  return {
40
44
  allPrograms: r || [],
41
45
  hotelPrograms: (r == null ? void 0 : r.filter(
42
- (e) => e.category === u.HOTEL
46
+ (e) => e.category === m.HOTEL
43
47
  )) || [],
44
48
  airlinePrograms: (r == null ? void 0 : r.filter(
45
- (e) => e.category === u.AIRLINE
49
+ (e) => e.category === m.AIRLINE
46
50
  )) || [],
47
51
  bankPrograms: (r == null ? void 0 : r.filter(
48
- (e) => e.category === u.BANK
52
+ (e) => e.category === m.BANK
49
53
  )) || [],
50
- updatePoints: y,
51
- getProgramById: c,
52
- banks: s,
53
- cards: l
54
+ updatePoints: c,
55
+ getProgramById: g,
56
+ banks: u,
57
+ allCards: l,
58
+ userCards: y
54
59
  };
55
60
  };
56
61
  export {
57
- B as useWallet
62
+ F as useWallet
58
63
  };
@@ -6,7 +6,7 @@ import { useWallet as mf } from "./useWallet.js";
6
6
  import "react/jsx-runtime";
7
7
  import "react";
8
8
  import "../../context/AwayzContext.js";
9
- import { c as gf } from "../../AccountService-BLoJ4G-f.js";
9
+ import { c as gf } from "../../AccountService-8OR0UkZ6.js";
10
10
  import { EWalletEndpoints as yf } from "../../configs/endpoints.js";
11
11
  import "../../configs/awayzClient.js";
12
12
  import "@tanstack/react-query";
@@ -12850,11 +12850,11 @@ const TS = [{ _id: "682c5c6f91cb31217e4bf851", name: "IHG Rewards Club Premier",
12850
12850
  success: vS
12851
12851
  };
12852
12852
  og("useWallet", () => {
12853
- hn.mocked(gf.get).mockImplementation((e) => e === yf.CARDS ? Promise.resolve({ data: $S }) : Promise.resolve({ data: {} })), rg("Retrieves user cards", async () => {
12853
+ hn.mocked(gf.get).mockImplementation((e) => e === yf.USER_CARDS ? Promise.resolve({ data: $S }) : Promise.resolve({ data: {} })), rg("Retrieves user cards", async () => {
12854
12854
  const { result: e } = df(() => mf());
12855
12855
  await pf(() => {
12856
12856
  var t;
12857
- Fo(e.current.cards).toBeDefined(), Fo((t = e.current.cards) == null ? void 0 : t.length).toBeGreaterThan(0);
12857
+ Fo(e.current.userCards).toBeDefined(), Fo((t = e.current.userCards) == null ? void 0 : t.length).toBeGreaterThan(0);
12858
12858
  });
12859
12859
  });
12860
12860
  });
@@ -27,6 +27,7 @@ export declare enum ECurrencyEndpoints {
27
27
  }
28
28
  export declare enum EWalletEndpoints {
29
29
  USER_AWARDS = "user/rewards",
30
+ USER_CARDS = "user/cards",
30
31
  BANKS = "banks",
31
32
  CARDS = "cards"
32
33
  }
@@ -10,6 +10,7 @@ export declare const useWallet: () => {
10
10
  updatePoints: import('@tanstack/react-query').UseMutateFunction<void, Error, ISetAwardPointsRequest, unknown>;
11
11
  getProgramById: (programId: string) => import('../../services').ILoyaltyProgram | null;
12
12
  banks: import('../../services').IBank[] | undefined;
13
- cards: import('../../services').ICard[] | undefined;
13
+ allCards: import('../../services').ICard[] | undefined;
14
+ userCards: import('../../services').ICard[] | undefined;
14
15
  };
15
16
  export {};
@@ -4,6 +4,7 @@ declare class _WalletService {
4
4
  setAwardPoints: (main_program: string, amount: number) => Promise<any>;
5
5
  getBanks: () => Promise<IBank[]>;
6
6
  getCards: () => Promise<ICard[]>;
7
+ getUserCards: () => Promise<ICard[]>;
7
8
  }
8
9
  export declare const WalletService: _WalletService;
9
10
  export {};
package/dist/main.js CHANGED
@@ -3,7 +3,7 @@ import { useAwayzContext as a } from "./hooks/useAwayzContext.js";
3
3
  import { useSearchLimit as n } from "./hooks/useSearchLimit.js";
4
4
  import { useWallet as m } from "./hooks/useWallet/useWallet.js";
5
5
  import { EAuthFlow as f } from "./types/EAuthFlow.js";
6
- import { c as l, i as c } from "./AccountService-BLoJ4G-f.js";
6
+ import { c as l, i as c } from "./AccountService-8OR0UkZ6.js";
7
7
  import { clientNoRetryInstance as y } from "./services/noRetryInstance.js";
8
8
  import { CurrencyService as A } from "./services/currency/CurrencyService.js";
9
9
  import { awayzClient as h } from "./configs/awayzClient.js";
@@ -1,7 +1,7 @@
1
1
  import { jsx as r } from "react/jsx-runtime";
2
2
  import { useEffect as s } from "react";
3
3
  import { AwayzContext as l } from "../context/AwayzContext.js";
4
- import { d as t } from "../AccountService-BLoJ4G-f.js";
4
+ import { d as t } from "../AccountService-8OR0UkZ6.js";
5
5
  import { useAwayzAuth as m } from "../hooks/useAwayzAuth/useAwayzAuth.js";
6
6
  import { setBaseUrl as u } from "../configs/baseUrl.js";
7
7
  import { QueryClientProvider as i } from "@tanstack/react-query";
@@ -1,4 +1,4 @@
1
- import { e as m } from "../../AccountService-BLoJ4G-f.js";
1
+ import { e as m } from "../../AccountService-8OR0UkZ6.js";
2
2
  import "react";
3
3
  import "../../configs/endpoints.js";
4
4
  import "../../configs/awayzClient.js";
@@ -1,7 +1,7 @@
1
1
  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 o = (t, r, e) => y(t, typeof r != "symbol" ? r + "" : r, e);
4
- import { e as p, E as C, c as a } from "../../AccountService-BLoJ4G-f.js";
4
+ import { e as p, E as C, c as a } from "../../AccountService-8OR0UkZ6.js";
5
5
  import "react";
6
6
  import { ECurrencyEndpoints as s } from "../../configs/endpoints.js";
7
7
  import "react/jsx-runtime";
@@ -1,4 +1,4 @@
1
- import { c as n, i as t } from "../AccountService-BLoJ4G-f.js";
1
+ import { c as n, i as t } from "../AccountService-8OR0UkZ6.js";
2
2
  import { clientNoRetryInstance as o } from "./noRetryInstance.js";
3
3
  import { CurrencyService as i } from "./currency/CurrencyService.js";
4
4
  export {
@@ -1,4 +1,4 @@
1
- import { c, i as e } from "../AccountService-BLoJ4G-f.js";
1
+ import { c, i as e } from "../AccountService-8OR0UkZ6.js";
2
2
  import "react";
3
3
  import "../configs/baseUrl.js";
4
4
  export {
@@ -1,4 +1,4 @@
1
- import { l as i, j as l, k as p, g as m, h as g, p as h } from "../AccountService-BLoJ4G-f.js";
1
+ import { l as i, j as l, k as p, g as m, h as g, p as h } from "../AccountService-8OR0UkZ6.js";
2
2
  import "../configs/baseUrl.js";
3
3
  import "react";
4
4
  import "../configs/endpoints.js";
@@ -1,4 +1,4 @@
1
- import { f as t, g as r, h as n } from "../AccountService-BLoJ4G-f.js";
1
+ import { f as t, g as r, h as n } from "../AccountService-8OR0UkZ6.js";
2
2
  const s = t.create();
3
3
  s.interceptors.request.use((e) => (e = r(e), e));
4
4
  const o = 1;
@@ -1,51 +1,51 @@
1
1
  import '../../assets/_styles.css';var y = Object.defineProperty;
2
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 o = (e, a, t) => w(e, typeof a != "symbol" ? a + "" : a, t);
4
- import { a as s, c as i, b as n } from "../../AccountService-BLoJ4G-f.js";
3
+ var s = (e, a, t) => w(e, typeof a != "symbol" ? a + "" : a, t);
4
+ import { a as o, c, b as n } from "../../AccountService-8OR0UkZ6.js";
5
5
  import "react";
6
6
  import "react/jsx-runtime";
7
7
  import "../../context/AwayzContext.js";
8
- import { EWalletEndpoints as m } from "../../configs/endpoints.js";
8
+ import { EWalletEndpoints as i } from "../../configs/endpoints.js";
9
9
  import "../../configs/awayzClient.js";
10
10
  import "@tanstack/react-query";
11
11
  import "../noRetryInstance.js";
12
12
  /* empty css */
13
13
  class E {
14
14
  constructor() {
15
- o(this, "getAwards", async () => {
16
- var a, t, c;
15
+ s(this, "getAwards", async () => {
16
+ var a, t, m;
17
17
  try {
18
18
  const l = [
19
- s.HOTEL,
20
- s.BANK,
21
- s.AIRLINE
19
+ o.HOTEL,
20
+ o.BANK,
21
+ o.AIRLINE
22
22
  ], [
23
- { data: p },
24
23
  { data: d },
24
+ { data: p },
25
25
  { data: g }
26
26
  ] = await Promise.all(
27
27
  l.map(
28
- (r) => i.get(
29
- m.USER_AWARDS,
28
+ (r) => c.get(
29
+ i.USER_AWARDS,
30
30
  {
31
31
  params: { category: r }
32
32
  }
33
33
  )
34
34
  )
35
- ), u = ((a = p.data) == null ? void 0 : a.map(
35
+ ), u = ((a = d.data) == null ? void 0 : a.map(
36
36
  (r) => n({
37
37
  ...r,
38
- ctegory: s.HOTEL
38
+ ctegory: o.HOTEL
39
39
  })
40
- )) ?? [], A = ((t = d.data) == null ? void 0 : t.map(
40
+ )) ?? [], A = ((t = p.data) == null ? void 0 : t.map(
41
41
  (r) => n({
42
42
  ...r,
43
- ctegory: s.BANK
43
+ ctegory: o.BANK
44
44
  })
45
- )) ?? [], R = ((c = g.data) == null ? void 0 : c.map(
45
+ )) ?? [], R = ((m = g.data) == null ? void 0 : m.map(
46
46
  (r) => n({
47
47
  ...r,
48
- ctegory: s.AIRLINE
48
+ ctegory: o.AIRLINE
49
49
  })
50
50
  )) ?? [];
51
51
  return [
@@ -58,28 +58,34 @@ class E {
58
58
  }
59
59
  return [];
60
60
  });
61
- o(this, "setAwardPoints", async (a, t) => {
62
- const { data: c } = await i.put(m.USER_AWARDS, {
61
+ s(this, "setAwardPoints", async (a, t) => {
62
+ const { data: m } = await c.put(i.USER_AWARDS, {
63
63
  main_program: a,
64
64
  amount: t
65
65
  });
66
- return c;
66
+ return m;
67
+ });
68
+ s(this, "getBanks", async () => {
69
+ const { data: a } = await c.get(
70
+ i.BANKS
71
+ );
72
+ return a.success ? a.data.map((t) => n(t)) : [];
67
73
  });
68
- o(this, "getBanks", async () => {
69
- const { data: a } = await i.get(
70
- m.BANKS
74
+ s(this, "getCards", async () => {
75
+ const { data: a } = await c.get(
76
+ i.CARDS
71
77
  );
72
78
  return a.success ? a.data.map((t) => n(t)) : [];
73
79
  });
74
- o(this, "getCards", async () => {
75
- const { data: a } = await i.get(
76
- m.CARDS
80
+ s(this, "getUserCards", async () => {
81
+ const { data: a } = await c.get(
82
+ i.USER_CARDS
77
83
  );
78
84
  return a.success ? a.data.map((t) => n(t)) : [];
79
85
  });
80
86
  }
81
87
  }
82
- const h = new E();
88
+ const U = new E();
83
89
  export {
84
- h as WalletService
90
+ U as WalletService
85
91
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@odynn/awayz-core",
3
- "version": "0.2.30",
3
+ "version": "0.2.31",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"