@odynn/awayz-core 0.3.7 → 0.3.8
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-w7U0Clec.js → TripsService-DvAgBZGs.js} +29 -29
- package/dist/hooks/useTripManagement/useTripManagement.js +52 -48
- package/dist/hooks/useTripManagement/useTripManagement.test.js +19 -19
- package/dist/lib/services/bookings/BookingService.types.d.ts +6 -1
- package/dist/services/bookings/BookingService.js +48 -47
- package/dist/services/trips/TripsService.js +1 -1
- package/package.json +1 -1
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
var _ = Object.defineProperty;
|
|
2
|
-
var
|
|
3
|
-
var t = (a, e, s) =>
|
|
4
|
-
import { c as n, j as
|
|
5
|
-
import { EBookingType as
|
|
2
|
+
var g = (a, e, s) => e in a ? _(a, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : a[e] = s;
|
|
3
|
+
var t = (a, e, s) => g(a, typeof e != "symbol" ? e + "" : e, s);
|
|
4
|
+
import { c as n, j as p, b as o, r as T } from "./AccountService-D_6U8vP6.js";
|
|
5
|
+
import { EBookingType as l } from "./services/trips/TripService.types.js";
|
|
6
6
|
import { EMyTripsEndpoints as i } from "./configs/endpoints.js";
|
|
7
|
-
import
|
|
7
|
+
import "./arrayExtensions-DlcBOj5a.js";
|
|
8
8
|
import "react";
|
|
9
|
-
const
|
|
10
|
-
class
|
|
9
|
+
const y = "https://assets.duffel.com/img/airlines/for-light-background/full-color-lockup/";
|
|
10
|
+
class b {
|
|
11
11
|
constructor() {
|
|
12
12
|
t(this, "createTrip", async (e) => {
|
|
13
13
|
const { data: s } = await n.post(
|
|
14
14
|
i.TRIPS,
|
|
15
|
-
|
|
15
|
+
p({
|
|
16
16
|
...e,
|
|
17
17
|
hotel_bookings: [],
|
|
18
18
|
flight_bookings: []
|
|
@@ -29,17 +29,17 @@ class f {
|
|
|
29
29
|
);
|
|
30
30
|
if (!(s != null && s.success))
|
|
31
31
|
return [];
|
|
32
|
-
const r = s.data.map((
|
|
33
|
-
...
|
|
34
|
-
flightBookings:
|
|
35
|
-
hotelBookings:
|
|
32
|
+
const r = s.data.map((d) => ({
|
|
33
|
+
...d,
|
|
34
|
+
flightBookings: u(d.flight_bookings ?? []),
|
|
35
|
+
hotelBookings: m(d.hotel_bookings ?? [])
|
|
36
36
|
}));
|
|
37
37
|
return o(r);
|
|
38
38
|
});
|
|
39
39
|
t(this, "updateTrip", async (e, s) => {
|
|
40
40
|
const { data: r } = await n.put(
|
|
41
41
|
`${i.TRIPS}/${e}`,
|
|
42
|
-
|
|
42
|
+
T(p(s))
|
|
43
43
|
);
|
|
44
44
|
return r != null && r.success ? {
|
|
45
45
|
success: !0,
|
|
@@ -61,32 +61,32 @@ class f {
|
|
|
61
61
|
i.UNCATEGORISED_BOOKINGS
|
|
62
62
|
);
|
|
63
63
|
return e != null && e.success ? {
|
|
64
|
-
flightBookings:
|
|
65
|
-
hotelBookings:
|
|
64
|
+
flightBookings: u(e.data.flight_bookings ?? []),
|
|
65
|
+
hotelBookings: m(e.data.hotel_bookings ?? [])
|
|
66
66
|
} : {
|
|
67
67
|
flightBookings: [],
|
|
68
68
|
hotelBookings: []
|
|
69
69
|
};
|
|
70
70
|
});
|
|
71
71
|
t(this, "addBookingToTrip", async (e, s, r) => {
|
|
72
|
-
const { data:
|
|
72
|
+
const { data: c } = await n.put(i.ADD_BOOKING, {
|
|
73
73
|
trip_id: e,
|
|
74
74
|
booking_id: s,
|
|
75
75
|
booking_type: r
|
|
76
76
|
});
|
|
77
|
-
return
|
|
77
|
+
return c.success;
|
|
78
78
|
});
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
|
-
const
|
|
81
|
+
const u = (a) => a.map(
|
|
82
82
|
(e) => o({
|
|
83
83
|
id: e._id,
|
|
84
84
|
reference: e.booking_reference,
|
|
85
|
-
startDate:
|
|
86
|
-
endDate:
|
|
87
|
-
bookingType:
|
|
85
|
+
startDate: e.departure_date,
|
|
86
|
+
endDate: e.arrival_date,
|
|
87
|
+
bookingType: l.FLIGHT,
|
|
88
88
|
airlines: e.slices.map((s) => ({
|
|
89
|
-
logo:
|
|
89
|
+
logo: y + ".svg",
|
|
90
90
|
name: s.carriers.operating[0]
|
|
91
91
|
})),
|
|
92
92
|
arrival: {
|
|
@@ -103,13 +103,13 @@ const m = (a) => a.map(
|
|
|
103
103
|
orderId: e.order_id,
|
|
104
104
|
type: e.type
|
|
105
105
|
})
|
|
106
|
-
),
|
|
106
|
+
), m = (a) => a.map(
|
|
107
107
|
(e) => o({
|
|
108
108
|
id: e._id,
|
|
109
109
|
reference: e.reference,
|
|
110
|
-
startDate:
|
|
111
|
-
endDate:
|
|
112
|
-
bookingType:
|
|
110
|
+
startDate: e.check_in_date,
|
|
111
|
+
endDate: e.check_out_date,
|
|
112
|
+
bookingType: l.HOTEL,
|
|
113
113
|
name: e.rooms[0].name,
|
|
114
114
|
image: e.images[0],
|
|
115
115
|
guests: e.number_of_guests,
|
|
@@ -117,8 +117,8 @@ const m = (a) => a.map(
|
|
|
117
117
|
rooms: e.rooms.length,
|
|
118
118
|
bookingId: e.booking_id
|
|
119
119
|
})
|
|
120
|
-
),
|
|
120
|
+
), w = new b();
|
|
121
121
|
export {
|
|
122
|
-
|
|
123
|
-
|
|
122
|
+
y as D,
|
|
123
|
+
w as T
|
|
124
124
|
};
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { useQuery as
|
|
1
|
+
import { useQuery as u, useMutation as p } from "@tanstack/react-query";
|
|
2
2
|
import { h as c } from "../../arrayExtensions-DlcBOj5a.js";
|
|
3
3
|
import { E as e } from "../../AccountService-D_6U8vP6.js";
|
|
4
4
|
import "react";
|
|
5
|
-
import { T as o } from "../../TripsService-
|
|
5
|
+
import { T as o } from "../../TripsService-DvAgBZGs.js";
|
|
6
6
|
import "react/jsx-runtime";
|
|
7
7
|
import "../../context/AwayzContext.js";
|
|
8
|
-
import { awayzClient as
|
|
8
|
+
import { awayzClient as i } from "../../configs/awayzClient.js";
|
|
9
9
|
import "../../services/noRetryInstance.js";
|
|
10
10
|
import '../../assets/_styles4.css';import '../../assets/_styles3.css';import '../../assets/_styles2.css';import '../../assets/_styles.css';/* empty css */
|
|
11
11
|
/* empty css */
|
|
12
12
|
/* empty css */
|
|
13
13
|
/* empty css */
|
|
14
|
-
const
|
|
14
|
+
const F = ({
|
|
15
15
|
tripId: s,
|
|
16
16
|
tripDetails: n
|
|
17
17
|
}) => {
|
|
@@ -20,7 +20,7 @@ const U = ({
|
|
|
20
20
|
if (!n || Object.keys(n).length === 0)
|
|
21
21
|
throw new Error("Trip details must be provided for update");
|
|
22
22
|
}, J = () => {
|
|
23
|
-
const { data: s = [] } =
|
|
23
|
+
const { data: s = [] } = u({
|
|
24
24
|
queryKey: [
|
|
25
25
|
e.TRIPS,
|
|
26
26
|
"past"
|
|
@@ -30,7 +30,7 @@ const U = ({
|
|
|
30
30
|
"past"
|
|
31
31
|
/* PAST */
|
|
32
32
|
)
|
|
33
|
-
}), { data: n = [] } =
|
|
33
|
+
}), { data: n = [] } = u({
|
|
34
34
|
queryKey: [
|
|
35
35
|
e.TRIPS,
|
|
36
36
|
"upcoming"
|
|
@@ -40,24 +40,24 @@ const U = ({
|
|
|
40
40
|
"upcoming"
|
|
41
41
|
/* UPCOMING */
|
|
42
42
|
)
|
|
43
|
-
}), { data: a } =
|
|
43
|
+
}), { data: a } = u({
|
|
44
44
|
queryKey: [e.UNCATEGORISED_BOOKINGS],
|
|
45
45
|
queryFn: () => o.getUncategorisedBookings()
|
|
46
46
|
}), {
|
|
47
|
-
mutate:
|
|
48
|
-
isPending:
|
|
47
|
+
mutate: y,
|
|
48
|
+
isPending: m,
|
|
49
49
|
isError: g,
|
|
50
50
|
error: E
|
|
51
51
|
} = p({
|
|
52
|
-
mutationFn: async ({ tripId: r, tripDetails:
|
|
52
|
+
mutationFn: async ({ tripId: r, tripDetails: t }) => (F({ tripId: r, tripDetails: t }), await o.updateTrip(r, t)),
|
|
53
53
|
onSuccess: () => {
|
|
54
|
-
|
|
54
|
+
i.invalidateQueries({
|
|
55
55
|
queryKey: [
|
|
56
56
|
e.TRIPS,
|
|
57
57
|
"past"
|
|
58
58
|
/* PAST */
|
|
59
59
|
]
|
|
60
|
-
}),
|
|
60
|
+
}), i.invalidateQueries({
|
|
61
61
|
queryKey: [
|
|
62
62
|
e.TRIPS,
|
|
63
63
|
"upcoming"
|
|
@@ -67,9 +67,9 @@ const U = ({
|
|
|
67
67
|
}
|
|
68
68
|
}), {
|
|
69
69
|
mutate: l,
|
|
70
|
-
isPending:
|
|
70
|
+
isPending: S,
|
|
71
71
|
isError: q,
|
|
72
|
-
error:
|
|
72
|
+
error: w
|
|
73
73
|
} = p({
|
|
74
74
|
mutationFn: async (r) => {
|
|
75
75
|
if (!r)
|
|
@@ -79,13 +79,13 @@ const U = ({
|
|
|
79
79
|
return await o.createTrip(r);
|
|
80
80
|
},
|
|
81
81
|
onSuccess: () => {
|
|
82
|
-
|
|
82
|
+
i.invalidateQueries({
|
|
83
83
|
queryKey: [
|
|
84
84
|
e.TRIPS,
|
|
85
85
|
"past"
|
|
86
86
|
/* PAST */
|
|
87
87
|
]
|
|
88
|
-
}),
|
|
88
|
+
}), i.invalidateQueries({
|
|
89
89
|
queryKey: [
|
|
90
90
|
e.TRIPS,
|
|
91
91
|
"upcoming"
|
|
@@ -95,9 +95,9 @@ const U = ({
|
|
|
95
95
|
}
|
|
96
96
|
}), {
|
|
97
97
|
mutate: P,
|
|
98
|
-
isPending:
|
|
99
|
-
isError:
|
|
100
|
-
error:
|
|
98
|
+
isPending: K,
|
|
99
|
+
isError: f,
|
|
100
|
+
error: I
|
|
101
101
|
} = p({
|
|
102
102
|
mutationFn: async (r) => {
|
|
103
103
|
if (!r)
|
|
@@ -105,89 +105,93 @@ const U = ({
|
|
|
105
105
|
await o.deleteTrip(r);
|
|
106
106
|
},
|
|
107
107
|
onSuccess: () => {
|
|
108
|
-
|
|
108
|
+
i.invalidateQueries({
|
|
109
109
|
queryKey: [
|
|
110
110
|
e.TRIPS,
|
|
111
111
|
"past"
|
|
112
112
|
/* PAST */
|
|
113
113
|
]
|
|
114
|
-
}),
|
|
114
|
+
}), i.invalidateQueries({
|
|
115
115
|
queryKey: [
|
|
116
116
|
e.TRIPS,
|
|
117
117
|
"upcoming"
|
|
118
118
|
/* UPCOMING */
|
|
119
119
|
]
|
|
120
|
+
}), i.invalidateQueries({
|
|
121
|
+
queryKey: [e.UNCATEGORISED_BOOKINGS]
|
|
120
122
|
});
|
|
121
123
|
}
|
|
122
124
|
}), {
|
|
123
|
-
mutate:
|
|
124
|
-
isPending:
|
|
125
|
-
isError:
|
|
126
|
-
error:
|
|
125
|
+
mutate: B,
|
|
126
|
+
isPending: h,
|
|
127
|
+
isError: v,
|
|
128
|
+
error: R
|
|
127
129
|
} = p({
|
|
128
130
|
mutationFn: async ({
|
|
129
131
|
tripId: r,
|
|
130
|
-
booking:
|
|
132
|
+
booking: t
|
|
131
133
|
}) => {
|
|
132
134
|
if (!r)
|
|
133
135
|
throw new Error("Trip ID is required to add a booking");
|
|
134
|
-
if (!
|
|
136
|
+
if (!t)
|
|
135
137
|
throw new Error("Booking is required to add a booking");
|
|
136
138
|
return await o.addBookingToTrip(
|
|
137
139
|
r,
|
|
138
|
-
|
|
139
|
-
|
|
140
|
+
t.id,
|
|
141
|
+
t.bookingType
|
|
140
142
|
);
|
|
141
143
|
},
|
|
142
144
|
onSuccess: () => {
|
|
143
|
-
|
|
145
|
+
i.invalidateQueries({
|
|
144
146
|
queryKey: [
|
|
145
147
|
e.TRIPS,
|
|
146
148
|
"past"
|
|
147
149
|
/* PAST */
|
|
148
150
|
]
|
|
149
|
-
}),
|
|
151
|
+
}), i.invalidateQueries({
|
|
150
152
|
queryKey: [
|
|
151
153
|
e.TRIPS,
|
|
152
154
|
"upcoming"
|
|
153
155
|
/* UPCOMING */
|
|
154
156
|
]
|
|
157
|
+
}), i.invalidateQueries({
|
|
158
|
+
queryKey: [e.UNCATEGORISED_BOOKINGS]
|
|
155
159
|
});
|
|
156
160
|
}
|
|
157
|
-
}),
|
|
158
|
-
...
|
|
161
|
+
}), k = [...s, ...n], d = (a == null ? void 0 : a.flightBookings) || [], T = (a == null ? void 0 : a.hotelBookings) || [], Q = [
|
|
162
|
+
...d,
|
|
159
163
|
...T
|
|
160
|
-
].sort((r,
|
|
164
|
+
].sort((r, t) => c(r.startDate).diff(c(t.startDate)));
|
|
161
165
|
return {
|
|
162
166
|
// Trips
|
|
163
|
-
allTrips:
|
|
167
|
+
allTrips: k,
|
|
164
168
|
pastTrips: s,
|
|
165
169
|
upcomingTrips: n,
|
|
166
170
|
// Bookings
|
|
167
171
|
allUncategorisedBookings: Q,
|
|
168
|
-
uncategorisedFlightBookings:
|
|
172
|
+
uncategorisedFlightBookings: d,
|
|
169
173
|
uncategorisedHotelBookings: T,
|
|
170
174
|
// Trip Management
|
|
171
175
|
createTrip: l,
|
|
172
|
-
isCreateTripPending:
|
|
176
|
+
isCreateTripPending: S,
|
|
173
177
|
isCreateTripError: q,
|
|
174
|
-
createTripError:
|
|
175
|
-
updateTrip:
|
|
176
|
-
isUpdateTripPending:
|
|
178
|
+
createTripError: w,
|
|
179
|
+
updateTrip: y,
|
|
180
|
+
isUpdateTripPending: m,
|
|
177
181
|
isUpdateTripError: g,
|
|
178
182
|
updateTripError: E,
|
|
179
183
|
deleteTrip: P,
|
|
180
|
-
isDeleteTripPending:
|
|
181
|
-
isDeleteTripError:
|
|
182
|
-
deleteTripError:
|
|
184
|
+
isDeleteTripPending: K,
|
|
185
|
+
isDeleteTripError: f,
|
|
186
|
+
deleteTripError: I,
|
|
183
187
|
// Booking Management
|
|
184
|
-
addBookingToTrip:
|
|
185
|
-
isAddBookingToTripPending:
|
|
186
|
-
isAddBookingToTripError:
|
|
187
|
-
addBookingToTripError:
|
|
188
|
+
addBookingToTrip: B,
|
|
189
|
+
isAddBookingToTripPending: h,
|
|
190
|
+
isAddBookingToTripError: v,
|
|
191
|
+
addBookingToTripError: R
|
|
188
192
|
};
|
|
189
193
|
};
|
|
190
194
|
export {
|
|
191
195
|
J as useTripManagement,
|
|
192
|
-
|
|
196
|
+
F as validateUpdateTripArgs
|
|
193
197
|
};
|
|
@@ -4,7 +4,7 @@ import { useTripManagement as n } from "./useTripManagement.js";
|
|
|
4
4
|
import "react/jsx-runtime";
|
|
5
5
|
import "react";
|
|
6
6
|
import "../../context/AwayzContext.js";
|
|
7
|
-
import { D as f } from "../../TripsService-
|
|
7
|
+
import { D as f } from "../../TripsService-DvAgBZGs.js";
|
|
8
8
|
import { c as d } from "../../AccountService-D_6U8vP6.js";
|
|
9
9
|
import { EMyTripsEndpoints as c } from "../../configs/endpoints.js";
|
|
10
10
|
import "../../configs/awayzClient.js";
|
|
@@ -15,21 +15,21 @@ import '../../assets/_styles4.css';import '../../assets/_styles3.css';import '..
|
|
|
15
15
|
/* empty css */
|
|
16
16
|
/* empty css */
|
|
17
17
|
/* empty css */
|
|
18
|
-
import { UncategorisedBookings200 as
|
|
18
|
+
import { UncategorisedBookings200 as y, PastTrip200 as B, UpcomingTrip200 as b, UpdatedTrip200 as k } from "./mocks/index.js";
|
|
19
19
|
import { d as u, v as T, b as D, t as s, g as e } from "../../vi.ClIskdbk-k6t29WRA.js";
|
|
20
|
-
let
|
|
21
|
-
past: [...
|
|
22
|
-
upcoming: [...
|
|
20
|
+
let g = {
|
|
21
|
+
past: [...B.data],
|
|
22
|
+
upcoming: [...b.data].concat(k.data)
|
|
23
23
|
};
|
|
24
24
|
u("useTripManagement", () => {
|
|
25
25
|
T.mocked(d.get).mockImplementation((t, r) => {
|
|
26
|
-
var a,
|
|
26
|
+
var a, l;
|
|
27
27
|
return t === c.UNCATEGORISED_BOOKINGS ? Promise.resolve({
|
|
28
|
-
data:
|
|
28
|
+
data: y
|
|
29
29
|
}) : ((a = r == null ? void 0 : r.params) == null ? void 0 : a.status) === "past" ? Promise.resolve({
|
|
30
|
-
data: { ...
|
|
31
|
-
}) : ((
|
|
32
|
-
data: { ...
|
|
30
|
+
data: { ...B, data: g.past }
|
|
31
|
+
}) : ((l = r == null ? void 0 : r.params) == null ? void 0 : l.status) === "upcoming" ? Promise.resolve({
|
|
32
|
+
data: { ...b, data: g.upcoming }
|
|
33
33
|
}) : Promise.resolve({ data: {} });
|
|
34
34
|
}), T.mocked(d.put).mockImplementation((t) => {
|
|
35
35
|
if (t === `${c.TRIPS}/67fd23bc3a7cbcd0a8757cdc`) {
|
|
@@ -37,9 +37,9 @@ u("useTripManagement", () => {
|
|
|
37
37
|
...k.data,
|
|
38
38
|
name: "Updated Trip"
|
|
39
39
|
};
|
|
40
|
-
return
|
|
40
|
+
return g.past = g.past.map(
|
|
41
41
|
(a) => a._id === "67fd23bc3a7cbcd0a8757cdc" ? r : a
|
|
42
|
-
),
|
|
42
|
+
), g.upcoming = g.upcoming.map(
|
|
43
43
|
(a) => a._id === "67fd23bc3a7cbcd0a8757cdc" ? r : a
|
|
44
44
|
), Promise.resolve({
|
|
45
45
|
data: k
|
|
@@ -68,16 +68,16 @@ u("useTripManagement", () => {
|
|
|
68
68
|
}), s("Has correct flight booking structure", async () => {
|
|
69
69
|
const { result: t } = o(() => n());
|
|
70
70
|
await i(() => {
|
|
71
|
-
const r = t.current.uncategorisedFlightBookings[0], a =
|
|
71
|
+
const r = t.current.uncategorisedFlightBookings[0], a = y.data.flight_bookings[0];
|
|
72
72
|
e(r).toMatchObject({
|
|
73
73
|
id: a._id,
|
|
74
74
|
reference: a.booking_reference,
|
|
75
|
-
startDate: e.any(
|
|
76
|
-
endDate: e.any(
|
|
75
|
+
startDate: e.any(String),
|
|
76
|
+
endDate: e.any(String),
|
|
77
77
|
bookingType: m.FLIGHT,
|
|
78
|
-
airlines: a.slices.map((
|
|
78
|
+
airlines: a.slices.map((l) => ({
|
|
79
79
|
logo: f + ".svg",
|
|
80
|
-
name:
|
|
80
|
+
name: l.carriers.operating[0]
|
|
81
81
|
})),
|
|
82
82
|
arrival: {
|
|
83
83
|
airportCode: a.slices[0].origin,
|
|
@@ -101,8 +101,8 @@ u("useTripManagement", () => {
|
|
|
101
101
|
console.log("Hotel Booking:", r), e(r).toMatchObject({
|
|
102
102
|
id: e.any(String),
|
|
103
103
|
reference: e.any(String),
|
|
104
|
-
startDate: e.any(
|
|
105
|
-
endDate: e.any(
|
|
104
|
+
startDate: e.any(String),
|
|
105
|
+
endDate: e.any(String),
|
|
106
106
|
bookingType: m.HOTEL,
|
|
107
107
|
name: e.any(String),
|
|
108
108
|
image: e.any(String),
|
|
@@ -71,8 +71,13 @@ export interface IFlightBookingDetails {
|
|
|
71
71
|
gender: string;
|
|
72
72
|
phoneNumber: string;
|
|
73
73
|
}[];
|
|
74
|
-
airlines:
|
|
74
|
+
airlines: {
|
|
75
|
+
name: string;
|
|
76
|
+
code: string;
|
|
77
|
+
logo: string;
|
|
78
|
+
}[];
|
|
75
79
|
flights: IFlight[];
|
|
80
|
+
availableActions: string[];
|
|
76
81
|
}
|
|
77
82
|
export interface IFlight {
|
|
78
83
|
origin: IAirport;
|
|
@@ -1,53 +1,53 @@
|
|
|
1
1
|
var m = Object.defineProperty;
|
|
2
|
-
var l = (n,
|
|
3
|
-
var o = (n,
|
|
2
|
+
var l = (n, t, a) => t in n ? m(n, t, { enumerable: !0, configurable: !0, writable: !0, value: a }) : n[t] = a;
|
|
3
|
+
var o = (n, t, a) => l(n, typeof t != "symbol" ? t + "" : t, a);
|
|
4
4
|
import "../../arrayExtensions-DlcBOj5a.js";
|
|
5
5
|
import { c as i, b as d } from "../../AccountService-D_6U8vP6.js";
|
|
6
6
|
import "react";
|
|
7
7
|
import { EBookingEndpoints as s } from "../../configs/endpoints.js";
|
|
8
8
|
const u = (n) => {
|
|
9
|
-
const
|
|
10
|
-
if (
|
|
11
|
-
const r =
|
|
9
|
+
const t = /P((\d+)D)?T((\d+)H)?((\d+)M)?/, a = n.match(t);
|
|
10
|
+
if (a) {
|
|
11
|
+
const r = a[2] ? `${a[2]}d ` : "", e = a[4] ? `${a[4]}h ` : "", c = a[6] ? `${a[6]}m` : "";
|
|
12
12
|
return `${r}${e}${c}`.trim();
|
|
13
13
|
} else
|
|
14
14
|
return n;
|
|
15
15
|
};
|
|
16
16
|
class _ {
|
|
17
17
|
constructor() {
|
|
18
|
-
o(this, "getHotelBooking", async (
|
|
19
|
-
const { data:
|
|
20
|
-
`${s.USER_HOTEL_BOOKINGS}/${
|
|
18
|
+
o(this, "getHotelBooking", async (t) => {
|
|
19
|
+
const { data: a } = await i.get(
|
|
20
|
+
`${s.USER_HOTEL_BOOKINGS}/${t}`
|
|
21
21
|
);
|
|
22
22
|
return d({
|
|
23
|
-
...
|
|
24
|
-
total_amount: parseFloat(
|
|
25
|
-
fee_amount: parseFloat(
|
|
26
|
-
tax_amount: parseFloat(
|
|
27
|
-
base_amount: parseFloat(
|
|
23
|
+
...a.data,
|
|
24
|
+
total_amount: parseFloat(a.data.total_amount),
|
|
25
|
+
fee_amount: parseFloat(a.data.fee_amount),
|
|
26
|
+
tax_amount: parseFloat(a.data.tax_amount),
|
|
27
|
+
base_amount: parseFloat(a.data.base_amount)
|
|
28
28
|
});
|
|
29
29
|
});
|
|
30
|
-
o(this, "getFlightBooking", async (
|
|
31
|
-
const { data:
|
|
32
|
-
`${s.USER_FLIGHT_BOOKINGS}/${
|
|
30
|
+
o(this, "getFlightBooking", async (t) => {
|
|
31
|
+
const { data: a } = await i.get(
|
|
32
|
+
`${s.USER_FLIGHT_BOOKINGS}/${t}`
|
|
33
33
|
);
|
|
34
34
|
return {
|
|
35
|
-
id:
|
|
36
|
-
taxAmount: parseFloat(
|
|
37
|
-
extrasAmount: parseFloat(
|
|
38
|
-
baseAmount: parseFloat(
|
|
39
|
-
feeAmount: parseFloat(
|
|
40
|
-
totalAmount: parseFloat(
|
|
41
|
-
currency:
|
|
42
|
-
status:
|
|
43
|
-
conditions:
|
|
44
|
-
class:
|
|
45
|
-
flightOfferId:
|
|
46
|
-
cancelledAt:
|
|
47
|
-
airlines:
|
|
35
|
+
id: a.data._id,
|
|
36
|
+
taxAmount: parseFloat(a.data.tax_amount),
|
|
37
|
+
extrasAmount: parseFloat(a.data.extras_amount),
|
|
38
|
+
baseAmount: parseFloat(a.data.base_amount),
|
|
39
|
+
feeAmount: parseFloat(a.data.fee_amount),
|
|
40
|
+
totalAmount: parseFloat(a.data.total_amount),
|
|
41
|
+
currency: a.data.total_currency,
|
|
42
|
+
status: a.data.status,
|
|
43
|
+
conditions: a.data.conditions,
|
|
44
|
+
class: a.data.data.slices[0].fare_brand_name,
|
|
45
|
+
flightOfferId: a.data.flight_offer_id,
|
|
46
|
+
cancelledAt: a.data.cancelled_at,
|
|
47
|
+
airlines: a.data.data.slices[0].segments.map(
|
|
48
48
|
(e) => e.operating_carrier.name
|
|
49
49
|
),
|
|
50
|
-
passengers:
|
|
50
|
+
passengers: a.data.data.passengers.map((e) => ({
|
|
51
51
|
id: e.id,
|
|
52
52
|
givenName: e.given_ame,
|
|
53
53
|
familyName: e.family_name,
|
|
@@ -57,38 +57,39 @@ class _ {
|
|
|
57
57
|
gender: e.gender,
|
|
58
58
|
phoneNumber: e.phone_number
|
|
59
59
|
})),
|
|
60
|
-
flights:
|
|
60
|
+
flights: a.data.data.slices.map((e) => ({
|
|
61
61
|
departingAt: e.segments[0].departing_at,
|
|
62
62
|
arrivingAt: e.segments.getLast().arriving_at,
|
|
63
63
|
numberOfStops: e.segments.length - 1,
|
|
64
|
-
reference:
|
|
64
|
+
reference: a.data.booking_reference,
|
|
65
65
|
durationInMinutes: u(e.duration),
|
|
66
66
|
origin: d(e.origin),
|
|
67
67
|
destination: d(e.destination)
|
|
68
|
-
}))
|
|
68
|
+
})),
|
|
69
|
+
availableActions: a.data.available_actions
|
|
69
70
|
};
|
|
70
71
|
});
|
|
71
|
-
o(this, "initiateCancelFlightBooking", async (
|
|
72
|
-
const { data:
|
|
73
|
-
`${s.INITIATE_FLIGHT_CANCEL}/${
|
|
72
|
+
o(this, "initiateCancelFlightBooking", async (t) => {
|
|
73
|
+
const { data: a } = await i.put(
|
|
74
|
+
`${s.INITIATE_FLIGHT_CANCEL}/${t}`
|
|
74
75
|
);
|
|
75
|
-
return
|
|
76
|
+
return a.success;
|
|
76
77
|
});
|
|
77
|
-
o(this, "confirmCancelFlightBooking", async (
|
|
78
|
-
const { data:
|
|
79
|
-
`${s.CONFIRM_FLIGHT_CANCEL}/${
|
|
78
|
+
o(this, "confirmCancelFlightBooking", async (t) => {
|
|
79
|
+
const { data: a } = await i.put(
|
|
80
|
+
`${s.CONFIRM_FLIGHT_CANCEL}/${t}`
|
|
80
81
|
);
|
|
81
|
-
return
|
|
82
|
+
return a.success;
|
|
82
83
|
});
|
|
83
|
-
o(this, "cancelHotelBooking", async (
|
|
84
|
-
const { data:
|
|
85
|
-
`${s.CANCEL_HOTEL_BOOKING}/${
|
|
84
|
+
o(this, "cancelHotelBooking", async (t) => {
|
|
85
|
+
const { data: a } = await i.post(
|
|
86
|
+
`${s.CANCEL_HOTEL_BOOKING}/${t}`
|
|
86
87
|
);
|
|
87
|
-
return
|
|
88
|
+
return a.success;
|
|
88
89
|
});
|
|
89
90
|
}
|
|
90
91
|
}
|
|
91
|
-
const
|
|
92
|
+
const $ = new _();
|
|
92
93
|
export {
|
|
93
|
-
|
|
94
|
+
$ as BookingService
|
|
94
95
|
};
|
|
@@ -2,7 +2,7 @@ import "../../AccountService-D_6U8vP6.js";
|
|
|
2
2
|
import "./TripService.types.js";
|
|
3
3
|
import "../../configs/endpoints.js";
|
|
4
4
|
import "../../arrayExtensions-DlcBOj5a.js";
|
|
5
|
-
import { T as s } from "../../TripsService-
|
|
5
|
+
import { T as s } from "../../TripsService-DvAgBZGs.js";
|
|
6
6
|
import "react";
|
|
7
7
|
export {
|
|
8
8
|
s as TripsService
|