@odynn/awayz-core 0.2.22 → 0.2.24

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,7 +1,7 @@
1
1
  import { jsx as ze, Fragment as GO, jsxs as Jo } from "react/jsx-runtime";
2
2
  import * as I from "react";
3
3
  import Jl, { useLayoutEffect as XO, useEffect as qO, useMemo as KO } from "react";
4
- import { g as ZO, b as JO } from "../../AccountService-C0p4I_Ww.js";
4
+ import { g as ZO, a as JO } from "../../AccountService-BmvBvxkG.js";
5
5
  import { useQuery as e_ } from "@tanstack/react-query";
6
6
  import { CurrencyService as t_ } from "../../services/currency/CurrencyService.js";
7
7
  import '../../assets/_styles.css';/* empty css */
@@ -1,5 +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 || {});
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))(_ || {});
2
2
  export {
3
3
  r as EAuthEndpoints,
4
- a as ECurrencyEndpoints
4
+ a as ECurrencyEndpoints,
5
+ _ as EWalletEndpoints
5
6
  };
@@ -1,4 +1,4 @@
1
- import { A as U, E as r, a as o, b as v } from "../../AccountService-C0p4I_Ww.js";
1
+ import { A as U, E as r, e as o, a as v } from "../../AccountService-BmvBvxkG.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 { b as s, a as i, d as n } from "../AccountService-C0p4I_Ww.js";
1
+ import { a as s, e as i, d as n } from "../AccountService-BmvBvxkG.js";
2
2
  import { useQuery as u } from "@tanstack/react-query";
3
3
  import "react";
4
4
  import { useAwayzContext as c } from "./useAwayzContext.js";
@@ -0,0 +1,57 @@
1
+ import { useQuery as m, useMutation as p } from "@tanstack/react-query";
2
+ import { a as t, b as u } from "../AccountService-BmvBvxkG.js";
3
+ import "react";
4
+ import { WalletService as n } from "../services/wallet/WalletService.js";
5
+ import "react/jsx-runtime";
6
+ import "../context/AwayzContext.js";
7
+ import { awayzClient as d } from "../configs/awayzClient.js";
8
+ import '../assets/_styles.css';/* empty css */
9
+ const E = () => {
10
+ const { data: r } = m({
11
+ queryKey: [t.PROGRAMS],
12
+ queryFn: n.getAwards,
13
+ placeholderData: []
14
+ }), { data: s } = m({
15
+ queryKey: [t.BANKS],
16
+ queryFn: n.getBanks,
17
+ placeholderData: []
18
+ }), { data: l } = m({
19
+ queryKey: [t.CARDS],
20
+ queryFn: n.getCards,
21
+ placeholderData: []
22
+ }), { mutate: y } = p({
23
+ mutationFn: async (e) => {
24
+ const { programId: o, awardsAmount: i } = e, a = r == null ? void 0 : r.find((g) => g.id === o);
25
+ if (!a)
26
+ throw new Error("Program not found");
27
+ await n.setAwardPoints(a.mainProgram, i);
28
+ },
29
+ onSuccess: () => {
30
+ d.invalidateQueries({
31
+ queryKey: [t.PROGRAMS]
32
+ });
33
+ }
34
+ }), c = (e) => {
35
+ const o = r == null ? void 0 : r.find((i) => i.id === e);
36
+ return o || null;
37
+ };
38
+ return {
39
+ allPrograms: r || [],
40
+ hotelPrograms: (r == null ? void 0 : r.filter(
41
+ (e) => e.category === u.HOTEL
42
+ )) || [],
43
+ airlinePrograms: (r == null ? void 0 : r.filter(
44
+ (e) => e.category === u.AIRLINE
45
+ )) || [],
46
+ bankPrograms: (r == null ? void 0 : r.filter(
47
+ (e) => e.category === u.BANK
48
+ )) || [],
49
+ updatePoints: y,
50
+ getProgramById: c,
51
+ banks: s,
52
+ cards: l
53
+ };
54
+ };
55
+ export {
56
+ E as useWallet
57
+ };
@@ -25,3 +25,8 @@ export declare enum EAuthEndpoints {
25
25
  export declare enum ECurrencyEndpoints {
26
26
  CURRENCY_CONVERSION = "currency/convert"
27
27
  }
28
+ export declare enum EWalletEndpoints {
29
+ USER_AWARDS = "user/rewards",
30
+ BANKS = "banks",
31
+ CARDS = "cards"
32
+ }
@@ -0,0 +1,15 @@
1
+ interface ISetAwardPointsRequest {
2
+ programId: string;
3
+ awardsAmount: number;
4
+ }
5
+ export declare const useWallet: () => {
6
+ allPrograms: import('../services/wallet/WalletService.types').ILoyaltyProgram[];
7
+ hotelPrograms: import('../services/wallet/WalletService.types').ILoyaltyProgram[];
8
+ airlinePrograms: import('../services/wallet/WalletService.types').ILoyaltyProgram[];
9
+ bankPrograms: import('../services/wallet/WalletService.types').ILoyaltyProgram[];
10
+ updatePoints: import('@tanstack/react-query').UseMutateFunction<void, Error, ISetAwardPointsRequest, unknown>;
11
+ getProgramById: (programId: string) => import('../services/wallet/WalletService.types').ILoyaltyProgram | null;
12
+ banks: import('../services/wallet/WalletService.types').IBank[] | undefined;
13
+ cards: import('../services/wallet/WalletService.types').ICard[] | undefined;
14
+ };
15
+ export {};
@@ -1,6 +1,7 @@
1
1
  export * from './providers/AwayzProvider';
2
2
  export * from './hooks/useAwayzContext';
3
3
  export * from './hooks/useSearchLimit';
4
+ export * from './hooks/useWallet';
4
5
  export * from './types';
5
6
  export * from './services/instance';
6
7
  export * from './configs/awayzClient';
@@ -0,0 +1,9 @@
1
+ import { IBank, ICard, ILoyaltyProgram } from './WalletService.types';
2
+ declare class _WalletService {
3
+ getAwards: () => Promise<ILoyaltyProgram[]>;
4
+ setAwardPoints: (main_program: string, amount: number) => Promise<any>;
5
+ getBanks: () => Promise<IBank[]>;
6
+ getCards: () => Promise<ICard[]>;
7
+ }
8
+ export declare const WalletService: _WalletService;
9
+ export {};
@@ -0,0 +1,61 @@
1
+ import { ERewardProgramCategory } from '@type-op/shared';
2
+ export interface IStatusLevels {
3
+ level1: string;
4
+ level2: string;
5
+ level3: string;
6
+ level4: string;
7
+ level5: string;
8
+ }
9
+ export interface ILoyaltyProgram {
10
+ id: string;
11
+ mainProgram: string;
12
+ category: ERewardProgramCategory;
13
+ statusLevels: IStatusLevels;
14
+ displayProgram: string;
15
+ awayzActive: string[];
16
+ modified: string;
17
+ colour: string;
18
+ programLogo: string;
19
+ url: string;
20
+ faredropUrl: string;
21
+ categoryLogo: string;
22
+ alternateRegions: string[];
23
+ region: string;
24
+ totalAccumulatedPoints: number;
25
+ }
26
+ export interface IBank {
27
+ id: string;
28
+ created: string;
29
+ name: string;
30
+ code: string;
31
+ mxCode: string;
32
+ rank: number;
33
+ modified: string;
34
+ region: string;
35
+ alternateRegions: string[];
36
+ }
37
+ export interface ICard {
38
+ id: string;
39
+ name: string;
40
+ signupBonus: number;
41
+ cashBonus: number;
42
+ minimumSpend: number;
43
+ daysToSpend: number;
44
+ annualFee: number;
45
+ annualFeeWaived: boolean;
46
+ cashPerks: number;
47
+ bank: {
48
+ name: string;
49
+ };
50
+ rewardsCurrency: string;
51
+ bisCard: boolean;
52
+ chargeCard: boolean;
53
+ cardFamily: number;
54
+ websiteUrl: string;
55
+ network: {
56
+ name: string;
57
+ };
58
+ colour: string;
59
+ region: string;
60
+ alternateRegions: string[];
61
+ }
package/dist/main.js CHANGED
@@ -1,23 +1,25 @@
1
1
  import { AwayzProvider as e } from "./providers/AwayzProvider.js";
2
2
  import { useAwayzContext as a } from "./hooks/useAwayzContext.js";
3
- import { useSearchLimit as m } from "./hooks/useSearchLimit.js";
4
- import { EAuthFlow as x } from "./types/EAuthFlow.js";
5
- import { c as n, i as s } from "./AccountService-C0p4I_Ww.js";
6
- import { awayzClient as l } from "./configs/awayzClient.js";
7
- import { CashValue as w } from "./components/CashValue/CashValue.js";
8
- import { EToolTipPosition as C } from "./components/CashValue/CashValueTypes.js";
9
- import { CurrencyService as z } from "./services/currency/CurrencyService.js";
10
- import { getBaseUrl as v } from "./configs/baseUrl.js";
3
+ import { useSearchLimit as p } from "./hooks/useSearchLimit.js";
4
+ import { useWallet as f } from "./hooks/useWallet.js";
5
+ import { EAuthFlow as s } from "./types/EAuthFlow.js";
6
+ import { c as l, i as c } from "./AccountService-BmvBvxkG.js";
7
+ import { awayzClient as w } from "./configs/awayzClient.js";
8
+ import { CashValue as C } from "./components/CashValue/CashValue.js";
9
+ import { EToolTipPosition as z } from "./components/CashValue/CashValueTypes.js";
10
+ import { CurrencyService as v } from "./services/currency/CurrencyService.js";
11
+ import { getBaseUrl as P } from "./configs/baseUrl.js";
11
12
  export {
12
13
  e as AwayzProvider,
13
- w as CashValue,
14
- z as CurrencyService,
15
- x as EAuthFlow,
16
- C as EToolTipPosition,
17
- l as awayzClient,
18
- n as clientInstance,
19
- v as getBaseUrl,
20
- s as instance,
14
+ C as CashValue,
15
+ v as CurrencyService,
16
+ s as EAuthFlow,
17
+ z as EToolTipPosition,
18
+ w as awayzClient,
19
+ l as clientInstance,
20
+ P as getBaseUrl,
21
+ c as instance,
21
22
  a as useAwayzContext,
22
- m as useSearchLimit
23
+ p as useSearchLimit,
24
+ f as useWallet
23
25
  };
@@ -1,7 +1,7 @@
1
1
  import { jsx as t } from "react/jsx-runtime";
2
2
  import { useEffect as i } from "react";
3
3
  import { AwayzContext as m } from "../context/AwayzContext.js";
4
- import { E as e } from "../AccountService-C0p4I_Ww.js";
4
+ import { E as e } from "../AccountService-BmvBvxkG.js";
5
5
  import { useAwayzAuth as s } from "../hooks/useAwayzAuth/useAwayzAuth.js";
6
6
  import { setBaseUrl as l } from "../configs/baseUrl.js";
7
7
  import { QueryClientProvider as u } from "@tanstack/react-query";
@@ -1,7 +1,7 @@
1
- import { a as p } from "../../AccountService-C0p4I_Ww.js";
1
+ import { e as m } from "../../AccountService-BmvBvxkG.js";
2
2
  import "react";
3
3
  import "../../configs/endpoints.js";
4
4
  import "../../configs/awayzClient.js";
5
5
  export {
6
- p as AccountService
6
+ m as AccountService
7
7
  };
@@ -1,7 +1,7 @@
1
1
  import '../../assets/_styles.css';var i = Object.defineProperty;
2
2
  var y = (t, r, e) => r in t ? i(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 { a as p, b as C, c as a } from "../../AccountService-C0p4I_Ww.js";
4
+ import { e as p, a as C, c as a } from "../../AccountService-BmvBvxkG.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 p, i as a } from "../AccountService-C0p4I_Ww.js";
1
+ import { c as p, i as a } from "../AccountService-BmvBvxkG.js";
2
2
  import "react";
3
3
  import "../configs/endpoints.js";
4
4
  import "../configs/baseUrl.js";
@@ -0,0 +1,84 @@
1
+ import '../../assets/_styles.css';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 o = (e, a, t) => w(e, typeof a != "symbol" ? a + "" : a, t);
4
+ import { b as s, c as i, d as n } from "../../AccountService-BmvBvxkG.js";
5
+ import "react";
6
+ import "react/jsx-runtime";
7
+ import "../../context/AwayzContext.js";
8
+ import { EWalletEndpoints as m } from "../../configs/endpoints.js";
9
+ import "../../configs/awayzClient.js";
10
+ import "@tanstack/react-query";
11
+ /* empty css */
12
+ class E {
13
+ constructor() {
14
+ o(this, "getAwards", async () => {
15
+ var a, t, c;
16
+ try {
17
+ const l = [
18
+ s.HOTEL,
19
+ s.BANK,
20
+ s.AIRLINE
21
+ ], [
22
+ { data: d },
23
+ { data: p },
24
+ { data: g }
25
+ ] = await Promise.all(
26
+ l.map(
27
+ (r) => i.get(
28
+ m.USER_AWARDS,
29
+ {
30
+ params: { category: r }
31
+ }
32
+ )
33
+ )
34
+ ), u = ((a = d.data) == null ? void 0 : a.map(
35
+ (r) => n({
36
+ ...r,
37
+ ctegory: s.HOTEL
38
+ })
39
+ )) ?? [], A = ((t = p.data) == null ? void 0 : t.map(
40
+ (r) => n({
41
+ ...r,
42
+ ctegory: s.BANK
43
+ })
44
+ )) ?? [], R = ((c = g.data) == null ? void 0 : c.map(
45
+ (r) => n({
46
+ ...r,
47
+ ctegory: s.AIRLINE
48
+ })
49
+ )) ?? [];
50
+ return [
51
+ ...u,
52
+ ...A,
53
+ ...R
54
+ ];
55
+ } catch (l) {
56
+ console.error(l);
57
+ }
58
+ return [];
59
+ });
60
+ o(this, "setAwardPoints", async (a, t) => {
61
+ const { data: c } = await i.put(m.USER_AWARDS, {
62
+ main_program: a,
63
+ amount: t
64
+ });
65
+ return c;
66
+ });
67
+ o(this, "getBanks", async () => {
68
+ const { data: a } = await i.get(
69
+ m.BANKS
70
+ );
71
+ return a.success ? a.data.map((t) => n(t)) : [];
72
+ });
73
+ o(this, "getCards", async () => {
74
+ const { data: a } = await i.get(
75
+ m.CARDS
76
+ );
77
+ return a.success ? a.data.map((t) => n(t)) : [];
78
+ });
79
+ }
80
+ }
81
+ const b = new E();
82
+ export {
83
+ b as WalletService
84
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@odynn/awayz-core",
3
- "version": "0.2.22",
3
+ "version": "0.2.24",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"