@odynn/awayz-core 0.9.21 → 0.9.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.
- package/dist/{TripsService-GImsS17_.js → TripsService-CJxjOcrR.js} +21 -21
- package/dist/hooks/useTripManagement/useTripManagement.js +1 -1
- package/dist/hooks/useTripManagement/useTripManagement.test.js +1 -1
- package/dist/hooks/useWallet/useWallet.js +41 -41
- package/dist/services/trips/TripsService.js +1 -1
- package/package.json +1 -1
|
@@ -30,21 +30,21 @@ class O {
|
|
|
30
30
|
);
|
|
31
31
|
if (!(a != null && a.success))
|
|
32
32
|
return [];
|
|
33
|
-
const
|
|
33
|
+
const t = a.data.map((c) => ({
|
|
34
34
|
...c,
|
|
35
35
|
flightBookings: T(c.flight_bookings ?? []),
|
|
36
36
|
hotelBookings: b(c.hotel_bookings ?? [])
|
|
37
37
|
}));
|
|
38
|
-
return d(
|
|
38
|
+
return d(t);
|
|
39
39
|
});
|
|
40
40
|
n(this, "updateTrip", async (e, a) => {
|
|
41
|
-
const { data:
|
|
41
|
+
const { data: t } = await i.put(
|
|
42
42
|
`${o.TRIPS}/${e}`,
|
|
43
43
|
D(u(a))
|
|
44
44
|
);
|
|
45
|
-
return
|
|
45
|
+
return t != null && t.success ? {
|
|
46
46
|
success: !0,
|
|
47
|
-
data: d(
|
|
47
|
+
data: d(t.data),
|
|
48
48
|
message: "Trip updated successfully."
|
|
49
49
|
} : {
|
|
50
50
|
success: !1,
|
|
@@ -69,30 +69,30 @@ class O {
|
|
|
69
69
|
hotelBookings: []
|
|
70
70
|
};
|
|
71
71
|
});
|
|
72
|
-
n(this, "addBookingToTrip", async (e, a,
|
|
73
|
-
const { data:
|
|
72
|
+
n(this, "addBookingToTrip", async (e, a, t) => {
|
|
73
|
+
const { data: s } = await i.put(o.ADD_BOOKING, {
|
|
74
74
|
trip_id: e,
|
|
75
75
|
booking_id: a,
|
|
76
|
-
booking_type:
|
|
76
|
+
booking_type: t
|
|
77
77
|
});
|
|
78
|
-
return
|
|
78
|
+
return s.success;
|
|
79
79
|
});
|
|
80
|
-
n(this, "removeBookingFromTrip", async (e, a,
|
|
81
|
-
const { data:
|
|
80
|
+
n(this, "removeBookingFromTrip", async (e, a, t) => {
|
|
81
|
+
const { data: s } = await i.put(
|
|
82
82
|
o.REMOVE_BOOKING,
|
|
83
83
|
u({
|
|
84
84
|
trip_id: e,
|
|
85
85
|
booking_id: a,
|
|
86
|
-
booking_type:
|
|
86
|
+
booking_type: t
|
|
87
87
|
})
|
|
88
88
|
);
|
|
89
|
-
return
|
|
89
|
+
return s.success;
|
|
90
90
|
});
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
const T = (r) => r.map((e) => {
|
|
94
94
|
var c, l, _, g;
|
|
95
|
-
const a = e.slices.length > 1,
|
|
95
|
+
const a = e.slices.length > 1, t = e.slices[0], s = a ? e.slices.getLast() : void 0;
|
|
96
96
|
return d({
|
|
97
97
|
id: e._id,
|
|
98
98
|
reference: e.booking_reference,
|
|
@@ -107,24 +107,24 @@ const T = (r) => r.map((e) => {
|
|
|
107
107
|
};
|
|
108
108
|
}),
|
|
109
109
|
arrival: {
|
|
110
|
-
airportCode:
|
|
110
|
+
airportCode: t.destination,
|
|
111
111
|
location: ""
|
|
112
112
|
},
|
|
113
113
|
departure: {
|
|
114
|
-
airportCode:
|
|
114
|
+
airportCode: t.origin,
|
|
115
115
|
location: ""
|
|
116
116
|
},
|
|
117
|
-
class:
|
|
117
|
+
class: t.fare_brand_name,
|
|
118
118
|
passengers: e.passengers.length,
|
|
119
119
|
hasAirlineChanges: !1,
|
|
120
120
|
orderId: e.order_id,
|
|
121
121
|
type: e.type,
|
|
122
122
|
cancelledAt: e.cancelled_at,
|
|
123
123
|
isRoundTrip: a,
|
|
124
|
-
outboundArrivalDate: (l = (c =
|
|
125
|
-
inboundDepartureDate:
|
|
126
|
-
inboundDeparture:
|
|
127
|
-
inboundArrival:
|
|
124
|
+
outboundArrivalDate: t.arriving_at ?? ((l = (c = t.segments) == null ? void 0 : c.getLast()) == null ? void 0 : l.arriving_at),
|
|
125
|
+
inboundDepartureDate: s ? s.departing_at ?? ((g = (_ = s.segments) == null ? void 0 : _[0]) == null ? void 0 : g.departing_at) : void 0,
|
|
126
|
+
inboundDeparture: s ? { airportCode: s.origin, location: "" } : void 0,
|
|
127
|
+
inboundArrival: s ? { airportCode: s.destination, location: "" } : void 0
|
|
128
128
|
});
|
|
129
129
|
}), b = (r) => r.map(
|
|
130
130
|
(e) => d({
|
|
@@ -13,7 +13,7 @@ import { awayzClient as o } from "../../configs/awayzClient.js";
|
|
|
13
13
|
import "../../index-Cv-wvFlM.js";
|
|
14
14
|
import "../../context/AwayzContext.js";
|
|
15
15
|
/* empty css */
|
|
16
|
-
import { T as n } from "../../TripsService-
|
|
16
|
+
import { T as n } from "../../TripsService-CJxjOcrR.js";
|
|
17
17
|
const b = ({
|
|
18
18
|
tripId: t,
|
|
19
19
|
tripDetails: s
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { h as p } from "../../arrayExtensions-DlcBOj5a.js";
|
|
2
|
-
import { D as f } from "../../TripsService-
|
|
2
|
+
import { D as f } from "../../TripsService-CJxjOcrR.js";
|
|
3
3
|
import "react";
|
|
4
4
|
import { renderHook as o, waitFor as i } from "../../tests/TestWrapper.js";
|
|
5
5
|
import { EMyTripsEndpoints as c } from "../../configs/endpoints.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useQuery as n, useMutation as s } from "@tanstack/react-query";
|
|
2
2
|
import "../../arrayExtensions-DlcBOj5a.js";
|
|
3
|
-
import { E as a, d as
|
|
3
|
+
import { E as a, d as m } from "../../noRetryInstance-DKhe8ju0.js";
|
|
4
4
|
import "react";
|
|
5
5
|
import "react/jsx-runtime";
|
|
6
6
|
import "react-i18next";
|
|
@@ -11,25 +11,25 @@ import { awayzClient as i } from "../../configs/awayzClient.js";
|
|
|
11
11
|
/* empty css */
|
|
12
12
|
/* empty css */
|
|
13
13
|
import "../../index-Cv-wvFlM.js";
|
|
14
|
-
import { useAwayzContext as
|
|
14
|
+
import { useAwayzContext as c } from "../useAwayzContext.js";
|
|
15
15
|
/* empty css */
|
|
16
16
|
import "../../context/AwayzContext.js";
|
|
17
17
|
import { WalletService as o } from "../../services/wallet/WalletService.js";
|
|
18
|
-
const
|
|
19
|
-
const { user:
|
|
18
|
+
const x = () => {
|
|
19
|
+
const { user: e } = c(), { data: t } = n({
|
|
20
20
|
queryKey: [a.PROGRAMS],
|
|
21
21
|
queryFn: o.getAwards,
|
|
22
22
|
placeholderData: []
|
|
23
|
-
}), { data:
|
|
24
|
-
queryKey: [a.USER_PROGRAMS,
|
|
25
|
-
queryFn: () =>
|
|
23
|
+
}), { data: l } = n({
|
|
24
|
+
queryKey: [a.USER_PROGRAMS, e == null ? void 0 : e.id],
|
|
25
|
+
queryFn: () => e != null && e.id ? o.getUserAwards(e.id) : [],
|
|
26
26
|
placeholderData: [],
|
|
27
|
-
enabled: !!(
|
|
27
|
+
enabled: !!(e != null && e.id)
|
|
28
28
|
}), { data: y } = n({
|
|
29
|
-
queryKey: [a.LINKED_USER_PROGRAMS,
|
|
30
|
-
queryFn: () =>
|
|
29
|
+
queryKey: [a.LINKED_USER_PROGRAMS, e == null ? void 0 : e.id],
|
|
30
|
+
queryFn: () => e != null && e.id ? o.getLinkedUserAwards(e.id) : [],
|
|
31
31
|
placeholderData: [],
|
|
32
|
-
enabled: !!(
|
|
32
|
+
enabled: !!(e != null && e.id)
|
|
33
33
|
}), { data: A } = n({
|
|
34
34
|
queryKey: [a.BANKS],
|
|
35
35
|
queryFn: o.getBanks,
|
|
@@ -42,55 +42,55 @@ const T = () => {
|
|
|
42
42
|
queryKey: [a.USER_CARDS],
|
|
43
43
|
queryFn: o.getUserCards,
|
|
44
44
|
placeholderData: []
|
|
45
|
-
}), { featureFlags: R, featureFlagsLoaded: S } =
|
|
45
|
+
}), { featureFlags: R, featureFlagsLoaded: S, isAuthenticated: p } = c(), { data: C } = n({
|
|
46
46
|
queryKey: [a.POINTS_AS_CASH],
|
|
47
47
|
queryFn: o.getPointsAsCash,
|
|
48
48
|
placeholderData: { availablePoints: 0, valuePerPoint: 0, currency: "" },
|
|
49
|
-
enabled: S && R.usePointsAsCashFeature
|
|
50
|
-
}), { mutate:
|
|
51
|
-
mutationFn: async (
|
|
52
|
-
const { mainProgram:
|
|
53
|
-
await o.addAwardProgram(
|
|
49
|
+
enabled: S && R.usePointsAsCashFeature && p
|
|
50
|
+
}), { mutate: E } = s({
|
|
51
|
+
mutationFn: async (r) => {
|
|
52
|
+
const { mainProgram: u, awardsAmount: d } = typeof r == "string" ? { mainProgram: r, awardsAmount: 0 } : r;
|
|
53
|
+
await o.addAwardProgram(u, d);
|
|
54
54
|
},
|
|
55
55
|
onSuccess: () => {
|
|
56
56
|
i.invalidateQueries({
|
|
57
57
|
queryKey: [a.LINKED_USER_PROGRAMS]
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
|
-
}), { mutate:
|
|
61
|
-
mutationFn: async (
|
|
62
|
-
await o.removeAwardProgram(
|
|
60
|
+
}), { mutate: K } = s({
|
|
61
|
+
mutationFn: async (r) => {
|
|
62
|
+
await o.removeAwardProgram(r);
|
|
63
63
|
},
|
|
64
64
|
onSuccess: () => {
|
|
65
65
|
i.invalidateQueries({
|
|
66
66
|
queryKey: [a.LINKED_USER_PROGRAMS]
|
|
67
67
|
});
|
|
68
68
|
}
|
|
69
|
-
}), { mutateAsync:
|
|
70
|
-
mutationFn: async ({ mainProgram:
|
|
71
|
-
const d = t == null ? void 0 : t.find((
|
|
69
|
+
}), { mutateAsync: f } = s({
|
|
70
|
+
mutationFn: async ({ mainProgram: r, awardsAmount: u }) => {
|
|
71
|
+
const d = t == null ? void 0 : t.find((h) => h.mainProgram === r);
|
|
72
72
|
if (!d)
|
|
73
73
|
throw new Error("Program not found");
|
|
74
|
-
return o.setAwardPoints(d.mainProgram,
|
|
74
|
+
return o.setAwardPoints(d.mainProgram, u);
|
|
75
75
|
},
|
|
76
76
|
onSuccess: () => {
|
|
77
77
|
[
|
|
78
78
|
a.LINKED_USER_PROGRAMS,
|
|
79
79
|
a.USER_PROGRAMS,
|
|
80
80
|
a.PROGRAMS
|
|
81
|
-
].forEach((
|
|
82
|
-
i.invalidateQueries({ queryKey: [
|
|
81
|
+
].forEach((r) => {
|
|
82
|
+
i.invalidateQueries({ queryKey: [r] });
|
|
83
83
|
});
|
|
84
84
|
}
|
|
85
|
-
}), { mutateAsync:
|
|
86
|
-
mutationFn: async (
|
|
85
|
+
}), { mutateAsync: q } = s({
|
|
86
|
+
mutationFn: async (r) => o.addCardsToWallet(r),
|
|
87
87
|
onSuccess: () => {
|
|
88
88
|
i.invalidateQueries({
|
|
89
89
|
queryKey: [a.USER_CARDS]
|
|
90
90
|
});
|
|
91
91
|
}
|
|
92
|
-
}), { mutateAsync:
|
|
93
|
-
mutationFn: async (
|
|
92
|
+
}), { mutateAsync: F } = s({
|
|
93
|
+
mutationFn: async (r) => o.removeCardsFromWallet(r),
|
|
94
94
|
onSuccess: () => {
|
|
95
95
|
i.invalidateQueries({
|
|
96
96
|
queryKey: [a.USER_CARDS]
|
|
@@ -100,27 +100,27 @@ const T = () => {
|
|
|
100
100
|
return {
|
|
101
101
|
// Program Management
|
|
102
102
|
allPrograms: t || [],
|
|
103
|
-
userPrograms:
|
|
103
|
+
userPrograms: l || [],
|
|
104
104
|
linkedUserPrograms: y || [],
|
|
105
105
|
hotelPrograms: (t == null ? void 0 : t.filter(
|
|
106
|
-
(
|
|
106
|
+
(r) => r.category.includes(m.HOTEL)
|
|
107
107
|
)) || [],
|
|
108
108
|
airlinePrograms: (t == null ? void 0 : t.filter(
|
|
109
|
-
(
|
|
109
|
+
(r) => r.category.includes(m.AIRLINE)
|
|
110
110
|
)) || [],
|
|
111
111
|
bankPrograms: (t == null ? void 0 : t.filter(
|
|
112
|
-
(
|
|
112
|
+
(r) => r.category.includes(m.BANK)
|
|
113
113
|
)) || [],
|
|
114
|
-
updatePoints:
|
|
115
|
-
addAwardProgram:
|
|
116
|
-
removeAwardProgram:
|
|
114
|
+
updatePoints: f,
|
|
115
|
+
addAwardProgram: E,
|
|
116
|
+
removeAwardProgram: K,
|
|
117
117
|
// Card Management
|
|
118
118
|
banks: A || [],
|
|
119
119
|
allCards: P || [],
|
|
120
120
|
userCards: g || [],
|
|
121
|
-
addCards:
|
|
122
|
-
removeCards:
|
|
123
|
-
pointsAsCash:
|
|
121
|
+
addCards: q,
|
|
122
|
+
removeCards: F,
|
|
123
|
+
pointsAsCash: C || {
|
|
124
124
|
availablePoints: 0,
|
|
125
125
|
valuePerPoint: 0,
|
|
126
126
|
currency: ""
|
|
@@ -128,5 +128,5 @@ const T = () => {
|
|
|
128
128
|
};
|
|
129
129
|
};
|
|
130
130
|
export {
|
|
131
|
-
|
|
131
|
+
x as useWallet
|
|
132
132
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "../../arrayExtensions-DlcBOj5a.js";
|
|
2
2
|
import "../../noRetryInstance-DKhe8ju0.js";
|
|
3
|
-
import { T } from "../../TripsService-
|
|
3
|
+
import { T } from "../../TripsService-CJxjOcrR.js";
|
|
4
4
|
import "react";
|
|
5
5
|
import "../../configs/defaultAwayzConfig.js";
|
|
6
6
|
import "../../configs/endpoints.js";
|