@odynn/awayz-core 0.6.38 → 0.6.41
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,9 +1,9 @@
|
|
|
1
|
-
import { useQuery as n, useMutation as
|
|
1
|
+
import { useQuery as n, useMutation as s } from "@tanstack/react-query";
|
|
2
2
|
import "../../arrayExtensions-DlcBOj5a.js";
|
|
3
|
-
import { E as a, b as
|
|
3
|
+
import { E as a, b as m } from "../../AccountService-DHR8seWS.js";
|
|
4
4
|
import "react";
|
|
5
5
|
import "react/jsx-runtime";
|
|
6
|
-
import { awayzClient as
|
|
6
|
+
import { awayzClient as i } from "../../configs/awayzClient.js";
|
|
7
7
|
import '../../assets/_styles4.css';import '../../assets/_styles3.css';import '../../assets/_styles2.css';import '../../assets/_styles.css';import '../../assets/_styles5.css';/* empty css */
|
|
8
8
|
/* empty css */
|
|
9
9
|
import "react-i18next";
|
|
@@ -15,20 +15,20 @@ import "../../context/AwayzContext.js";
|
|
|
15
15
|
import "../../services/noRetryInstance.js";
|
|
16
16
|
import { WalletService as o } from "../../services/wallet/WalletService.js";
|
|
17
17
|
const B = () => {
|
|
18
|
-
const { user:
|
|
18
|
+
const { user: r } = l(), { data: t } = n({
|
|
19
19
|
queryKey: [a.PROGRAMS],
|
|
20
20
|
queryFn: o.getAwards,
|
|
21
21
|
placeholderData: []
|
|
22
22
|
}), { data: c } = n({
|
|
23
|
-
queryKey: [a.USER_PROGRAMS,
|
|
24
|
-
queryFn: () =>
|
|
23
|
+
queryKey: [a.USER_PROGRAMS, r == null ? void 0 : r.id],
|
|
24
|
+
queryFn: () => r != null && r.id ? o.getUserAwards(r.id) : [],
|
|
25
25
|
placeholderData: [],
|
|
26
|
-
enabled: !!(
|
|
26
|
+
enabled: !!(r != null && r.id)
|
|
27
27
|
}), { data: y } = n({
|
|
28
|
-
queryKey: [a.LINKED_USER_PROGRAMS,
|
|
29
|
-
queryFn: () =>
|
|
28
|
+
queryKey: [a.LINKED_USER_PROGRAMS, r == null ? void 0 : r.id],
|
|
29
|
+
queryFn: () => r != null && r.id ? o.getLinkedUserAwards(r.id) : [],
|
|
30
30
|
placeholderData: [],
|
|
31
|
-
enabled: !!(
|
|
31
|
+
enabled: !!(r != null && r.id)
|
|
32
32
|
}), { data: A } = n({
|
|
33
33
|
queryKey: [a.BANKS],
|
|
34
34
|
queryFn: o.getBanks,
|
|
@@ -46,56 +46,52 @@ const B = () => {
|
|
|
46
46
|
queryFn: o.getPointsAsCash,
|
|
47
47
|
placeholderData: { availablePoints: 0, valuePerPoint: 0, currency: "" },
|
|
48
48
|
enabled: S && R.usePointsAsCashFeature
|
|
49
|
-
}), { mutate: C } =
|
|
50
|
-
mutationFn: async (
|
|
51
|
-
const { mainProgram:
|
|
52
|
-
await o.addAwardProgram(
|
|
49
|
+
}), { mutate: C } = s({
|
|
50
|
+
mutationFn: async (e) => {
|
|
51
|
+
const { mainProgram: u, awardsAmount: d } = typeof e == "string" ? { mainProgram: e, awardsAmount: 0 } : e;
|
|
52
|
+
await o.addAwardProgram(u, d);
|
|
53
53
|
},
|
|
54
54
|
onSuccess: () => {
|
|
55
|
-
|
|
55
|
+
i.invalidateQueries({
|
|
56
56
|
queryKey: [a.LINKED_USER_PROGRAMS]
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
|
-
}), { mutate: E } =
|
|
60
|
-
mutationFn: async (
|
|
61
|
-
await o.removeAwardProgram(
|
|
59
|
+
}), { mutate: E } = s({
|
|
60
|
+
mutationFn: async (e) => {
|
|
61
|
+
await o.removeAwardProgram(e);
|
|
62
62
|
},
|
|
63
63
|
onSuccess: () => {
|
|
64
|
-
|
|
64
|
+
i.invalidateQueries({
|
|
65
65
|
queryKey: [a.LINKED_USER_PROGRAMS]
|
|
66
66
|
});
|
|
67
67
|
}
|
|
68
|
-
}), { mutateAsync: K } =
|
|
69
|
-
mutationFn: async ({ mainProgram:
|
|
70
|
-
const d = t == null ? void 0 : t.find((F) => F.mainProgram ===
|
|
68
|
+
}), { mutateAsync: K } = s({
|
|
69
|
+
mutationFn: async ({ mainProgram: e, awardsAmount: u }) => {
|
|
70
|
+
const d = t == null ? void 0 : t.find((F) => F.mainProgram === e);
|
|
71
71
|
if (!d)
|
|
72
72
|
throw new Error("Program not found");
|
|
73
|
-
return o.setAwardPoints(d.mainProgram,
|
|
73
|
+
return o.setAwardPoints(d.mainProgram, u);
|
|
74
74
|
},
|
|
75
75
|
onSuccess: () => {
|
|
76
76
|
[
|
|
77
77
|
a.LINKED_USER_PROGRAMS,
|
|
78
78
|
a.USER_PROGRAMS,
|
|
79
79
|
a.PROGRAMS
|
|
80
|
-
].forEach((
|
|
81
|
-
|
|
80
|
+
].forEach((e) => {
|
|
81
|
+
i.invalidateQueries({ queryKey: [e] });
|
|
82
82
|
});
|
|
83
83
|
}
|
|
84
|
-
}), {
|
|
85
|
-
mutationFn: async (
|
|
86
|
-
await o.addCardsToWallet(r);
|
|
87
|
-
},
|
|
84
|
+
}), { mutateAsync: f } = s({
|
|
85
|
+
mutationFn: async (e) => o.addCardsToWallet(e),
|
|
88
86
|
onSuccess: () => {
|
|
89
|
-
|
|
87
|
+
i.invalidateQueries({
|
|
90
88
|
queryKey: [a.USER_CARDS]
|
|
91
89
|
});
|
|
92
90
|
}
|
|
93
|
-
}), {
|
|
94
|
-
mutationFn: async (
|
|
95
|
-
await o.removeCardsFromWallet(r);
|
|
96
|
-
},
|
|
91
|
+
}), { mutateAsync: q } = s({
|
|
92
|
+
mutationFn: async (e) => o.removeCardsFromWallet(e),
|
|
97
93
|
onSuccess: () => {
|
|
98
|
-
|
|
94
|
+
i.invalidateQueries({
|
|
99
95
|
queryKey: [a.USER_CARDS]
|
|
100
96
|
});
|
|
101
97
|
}
|
|
@@ -106,13 +102,13 @@ const B = () => {
|
|
|
106
102
|
userPrograms: c || [],
|
|
107
103
|
linkedUserPrograms: y || [],
|
|
108
104
|
hotelPrograms: (t == null ? void 0 : t.filter(
|
|
109
|
-
(
|
|
105
|
+
(e) => e.category.includes(m.HOTEL)
|
|
110
106
|
)) || [],
|
|
111
107
|
airlinePrograms: (t == null ? void 0 : t.filter(
|
|
112
|
-
(
|
|
108
|
+
(e) => e.category.includes(m.AIRLINE)
|
|
113
109
|
)) || [],
|
|
114
110
|
bankPrograms: (t == null ? void 0 : t.filter(
|
|
115
|
-
(
|
|
111
|
+
(e) => e.category.includes(m.BANK)
|
|
116
112
|
)) || [],
|
|
117
113
|
updatePoints: K,
|
|
118
114
|
addAwardProgram: C,
|
|
@@ -60,12 +60,12 @@ export interface IWalletHook {
|
|
|
60
60
|
* Adds cards to the user's wallet.
|
|
61
61
|
* @param cardIds - The IDs of the cards to be added.
|
|
62
62
|
*/
|
|
63
|
-
addCards: (cardIds: string[]) => void
|
|
63
|
+
addCards: (cardIds: string[]) => Promise<void>;
|
|
64
64
|
/**
|
|
65
65
|
* Removes cards from the user's wallet.
|
|
66
66
|
* @param cardIds - The IDs of the cards to be removed.
|
|
67
67
|
*/
|
|
68
|
-
removeCards: (cardIds: string[]) => void
|
|
68
|
+
removeCards: (cardIds: string[]) => Promise<void>;
|
|
69
69
|
/**
|
|
70
70
|
* Points as cash value object containing available points and dollar per point value.
|
|
71
71
|
*/
|
|
@@ -37,6 +37,15 @@ export interface IHotelBookingDetails {
|
|
|
37
37
|
coordinates: ICoordinates;
|
|
38
38
|
cancellationTimeline: ICancellationTimeline[];
|
|
39
39
|
pointsAsCash?: IPointsAsCash;
|
|
40
|
+
rooms: {
|
|
41
|
+
beds: IBed[];
|
|
42
|
+
totalAmount: number;
|
|
43
|
+
name: string;
|
|
44
|
+
}[];
|
|
45
|
+
}
|
|
46
|
+
export interface IBed {
|
|
47
|
+
type: string;
|
|
48
|
+
count: number;
|
|
40
49
|
}
|
|
41
50
|
export interface IPointsAsCash {
|
|
42
51
|
authCode: string;
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var c = (
|
|
1
|
+
var p = Object.defineProperty;
|
|
2
|
+
var g = (i, e, a) => e in i ? p(i, e, { enumerable: !0, configurable: !0, writable: !0, value: a }) : i[e] = a;
|
|
3
|
+
var c = (i, e, a) => g(i, typeof e != "symbol" ? e + "" : e, a);
|
|
4
4
|
import "../../arrayExtensions-DlcBOj5a.js";
|
|
5
|
-
import { c as r, a as
|
|
5
|
+
import { c as r, a as u } from "../../AccountService-DHR8seWS.js";
|
|
6
6
|
import "react";
|
|
7
|
-
import { EBookingEndpoints as
|
|
8
|
-
const
|
|
9
|
-
const e = /P((\d+)D)?T((\d+)H)?((\d+)M)?/, a =
|
|
7
|
+
import { EBookingEndpoints as s } from "../../configs/endpoints.js";
|
|
8
|
+
const f = (i) => {
|
|
9
|
+
const e = /P((\d+)D)?T((\d+)H)?((\d+)M)?/, a = i.match(e);
|
|
10
10
|
if (a) {
|
|
11
|
-
const o = a[2] ? `${a[2]}d ` : "", t = a[4] ? `${a[4]}h ` : "",
|
|
12
|
-
return `${o}${t}${
|
|
11
|
+
const o = a[2] ? `${a[2]}d ` : "", t = a[4] ? `${a[4]}h ` : "", _ = a[6] ? `${a[6]}m` : "";
|
|
12
|
+
return `${o}${t}${_}`.trim();
|
|
13
13
|
} else
|
|
14
|
-
return
|
|
14
|
+
return i;
|
|
15
15
|
};
|
|
16
|
-
class
|
|
16
|
+
class y {
|
|
17
17
|
constructor() {
|
|
18
18
|
c(this, "getHotelBooking", async (e) => {
|
|
19
|
-
var
|
|
19
|
+
var _, m;
|
|
20
20
|
const { data: a } = await r.get(
|
|
21
|
-
`${
|
|
21
|
+
`${s.USER_HOTEL_BOOKINGS}/${e}`
|
|
22
22
|
), o = a.data.accommodation.rooms[0].rates[0];
|
|
23
23
|
return {
|
|
24
24
|
id: a.data._id,
|
|
@@ -50,33 +50,44 @@ class f {
|
|
|
50
50
|
latitude: a.data.accommodation.location.geographic_coordinates.latitude,
|
|
51
51
|
longitude: a.data.accommodation.location.geographic_coordinates.longitude
|
|
52
52
|
},
|
|
53
|
-
images: a.data.accommodation.photos.map((
|
|
54
|
-
guests: a.data.guests.map((
|
|
55
|
-
var
|
|
53
|
+
images: a.data.accommodation.photos.map((n) => n.url),
|
|
54
|
+
guests: a.data.guests.map((n, l) => {
|
|
55
|
+
var d;
|
|
56
56
|
return {
|
|
57
|
-
familyName:
|
|
58
|
-
givenName:
|
|
59
|
-
type: (
|
|
57
|
+
familyName: n.family_name,
|
|
58
|
+
givenName: n.given_name,
|
|
59
|
+
type: (d = a.data.guest_types[l]) == null ? void 0 : d.type
|
|
60
60
|
};
|
|
61
61
|
}),
|
|
62
|
-
numberOfRooms: (
|
|
62
|
+
numberOfRooms: (_ = a.data.rooms) == null ? void 0 : _.length,
|
|
63
63
|
cancellationTimeline: o.cancellation_timeline.map(
|
|
64
|
-
(
|
|
65
|
-
refundAmount: parseFloat(
|
|
66
|
-
currency:
|
|
67
|
-
before:
|
|
64
|
+
(n) => ({
|
|
65
|
+
refundAmount: parseFloat(n.refund_amount),
|
|
66
|
+
currency: n.currency,
|
|
67
|
+
before: n.before
|
|
68
68
|
})
|
|
69
69
|
),
|
|
70
70
|
pointsAsCash: a.data.points_as_cash ? {
|
|
71
71
|
authCode: a.data.points_as_cash.auth_code,
|
|
72
72
|
points: a.data.points_as_cash.points,
|
|
73
73
|
pointsValue: a.data.points_as_cash.points_value
|
|
74
|
-
} : void 0
|
|
74
|
+
} : void 0,
|
|
75
|
+
rooms: (m = a.data.rooms) == null ? void 0 : m.map((n) => {
|
|
76
|
+
var l;
|
|
77
|
+
return {
|
|
78
|
+
beds: (l = n.beds) == null ? void 0 : l.map((d) => ({
|
|
79
|
+
type: d.type,
|
|
80
|
+
count: d.count
|
|
81
|
+
})),
|
|
82
|
+
totalAmount: parseFloat(n.rates[0].total_amount),
|
|
83
|
+
name: n.name
|
|
84
|
+
};
|
|
85
|
+
})
|
|
75
86
|
};
|
|
76
87
|
});
|
|
77
88
|
c(this, "getFlightBooking", async (e) => {
|
|
78
89
|
const { data: a } = await r.get(
|
|
79
|
-
`${
|
|
90
|
+
`${s.USER_FLIGHT_BOOKINGS}/${e}`
|
|
80
91
|
);
|
|
81
92
|
return {
|
|
82
93
|
id: a.data._id,
|
|
@@ -125,12 +136,12 @@ class f {
|
|
|
125
136
|
arrivingAt: t.segments.getLast().arriving_at,
|
|
126
137
|
numberOfStops: t.segments.length - 1,
|
|
127
138
|
reference: a.data.booking_reference,
|
|
128
|
-
durationInMinutes:
|
|
129
|
-
origin:
|
|
130
|
-
destination:
|
|
139
|
+
durationInMinutes: f(t.duration),
|
|
140
|
+
origin: u(t.origin),
|
|
141
|
+
destination: u(t.destination)
|
|
131
142
|
})),
|
|
132
143
|
availableActions: a.data.available_actions,
|
|
133
|
-
airlineInitiatedChanges:
|
|
144
|
+
airlineInitiatedChanges: u(a.data.airline_initiated_changes) || [],
|
|
134
145
|
pointsAsCash: a.data.points_as_cash ? {
|
|
135
146
|
authCode: a.data.points_as_cash.auth_code,
|
|
136
147
|
points: a.data.points_as_cash.points,
|
|
@@ -140,19 +151,19 @@ class f {
|
|
|
140
151
|
});
|
|
141
152
|
c(this, "initiateCancelFlightBooking", async (e) => {
|
|
142
153
|
const { data: a } = await r.put(
|
|
143
|
-
`${
|
|
154
|
+
`${s.INITIATE_FLIGHT_CANCEL}/${e}`
|
|
144
155
|
);
|
|
145
156
|
return a.success;
|
|
146
157
|
});
|
|
147
158
|
c(this, "confirmCancelFlightBooking", async (e) => {
|
|
148
159
|
const { data: a } = await r.put(
|
|
149
|
-
`${
|
|
160
|
+
`${s.CONFIRM_FLIGHT_CANCEL}/${e}`
|
|
150
161
|
);
|
|
151
162
|
return a.success;
|
|
152
163
|
});
|
|
153
164
|
c(this, "cancelHotelBooking", async (e) => {
|
|
154
165
|
const { data: a } = await r.post(
|
|
155
|
-
`${
|
|
166
|
+
`${s.CANCEL_HOTEL_BOOKING}/${e}`
|
|
156
167
|
);
|
|
157
168
|
return a.success;
|
|
158
169
|
});
|
|
@@ -162,7 +173,7 @@ class f {
|
|
|
162
173
|
aicId: o
|
|
163
174
|
}) => {
|
|
164
175
|
const { data: t } = await r.post(
|
|
165
|
-
|
|
176
|
+
s.ACTION_AIRLINE_CHANGES,
|
|
166
177
|
{
|
|
167
178
|
booking_id: e,
|
|
168
179
|
action_taken: a ? "accepted" : "cancelled",
|
|
@@ -173,7 +184,7 @@ class f {
|
|
|
173
184
|
});
|
|
174
185
|
}
|
|
175
186
|
}
|
|
176
|
-
const
|
|
187
|
+
const F = new y();
|
|
177
188
|
export {
|
|
178
|
-
|
|
189
|
+
F as BookingService
|
|
179
190
|
};
|