@odynn/awayz-core 0.3.9 → 0.3.11
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-DvAgBZGs.js → TripsService-BbbkMtx6.js} +36 -23
- package/dist/configs/endpoints.js +3 -3
- package/dist/hooks/useTripManagement/useTripManagement.js +123 -76
- package/dist/hooks/useTripManagement/useTripManagement.test.js +1 -1
- package/dist/lib/configs/endpoints.d.ts +1 -0
- package/dist/lib/hooks/useTripManagement/useTripManagement.types.d.ts +32 -0
- package/dist/lib/services/bookings/BookingService.types.d.ts +14 -17
- package/dist/lib/services/trips/TripService.types.d.ts +5 -6
- package/dist/lib/services/trips/TripsService.d.ts +1 -0
- package/dist/services/bookings/BookingService.js +74 -43
- package/dist/services/trips/TripService.types.js +1 -1
- package/dist/services/trips/TripsService.js +1 -1
- package/package.json +1 -1
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
var _ = Object.defineProperty;
|
|
2
2
|
var g = (a, e, s) => e in a ? _(a, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : a[e] = s;
|
|
3
|
-
var
|
|
3
|
+
var r = (a, e, s) => g(a, typeof e != "symbol" ? e + "" : e, s);
|
|
4
4
|
import { c as n, j as p, b as o, r as T } from "./AccountService-D_6U8vP6.js";
|
|
5
|
-
import { EBookingType as
|
|
5
|
+
import { EBookingType as m } from "./services/trips/TripService.types.js";
|
|
6
6
|
import { EMyTripsEndpoints as i } from "./configs/endpoints.js";
|
|
7
7
|
import "./arrayExtensions-DlcBOj5a.js";
|
|
8
8
|
import "react";
|
|
9
9
|
const y = "https://assets.duffel.com/img/airlines/for-light-background/full-color-lockup/";
|
|
10
10
|
class b {
|
|
11
11
|
constructor() {
|
|
12
|
-
|
|
12
|
+
r(this, "createTrip", async (e) => {
|
|
13
13
|
const { data: s } = await n.post(
|
|
14
14
|
i.TRIPS,
|
|
15
15
|
p({
|
|
@@ -20,7 +20,7 @@ class b {
|
|
|
20
20
|
);
|
|
21
21
|
return s;
|
|
22
22
|
});
|
|
23
|
-
|
|
23
|
+
r(this, "getTripsByStatus", async (e) => {
|
|
24
24
|
const { data: s } = await n.get(
|
|
25
25
|
i.TRIPS,
|
|
26
26
|
{
|
|
@@ -29,53 +29,64 @@ class b {
|
|
|
29
29
|
);
|
|
30
30
|
if (!(s != null && s.success))
|
|
31
31
|
return [];
|
|
32
|
-
const
|
|
32
|
+
const t = s.data.map((d) => ({
|
|
33
33
|
...d,
|
|
34
34
|
flightBookings: u(d.flight_bookings ?? []),
|
|
35
|
-
hotelBookings:
|
|
35
|
+
hotelBookings: l(d.hotel_bookings ?? [])
|
|
36
36
|
}));
|
|
37
|
-
return o(
|
|
37
|
+
return o(t);
|
|
38
38
|
});
|
|
39
|
-
|
|
40
|
-
const { data:
|
|
39
|
+
r(this, "updateTrip", async (e, s) => {
|
|
40
|
+
const { data: t } = await n.put(
|
|
41
41
|
`${i.TRIPS}/${e}`,
|
|
42
42
|
T(p(s))
|
|
43
43
|
);
|
|
44
|
-
return
|
|
44
|
+
return t != null && t.success ? {
|
|
45
45
|
success: !0,
|
|
46
|
-
data: o(
|
|
46
|
+
data: o(t.data),
|
|
47
47
|
message: "Trip updated successfully."
|
|
48
48
|
} : {
|
|
49
49
|
success: !1,
|
|
50
50
|
message: "An error occurred while trying to update the trip."
|
|
51
51
|
};
|
|
52
52
|
});
|
|
53
|
-
|
|
53
|
+
r(this, "deleteTrip", async (e) => {
|
|
54
54
|
const { data: s } = await n.delete(
|
|
55
55
|
`${i.TRIPS}/${e}`
|
|
56
56
|
);
|
|
57
57
|
return s;
|
|
58
58
|
});
|
|
59
|
-
|
|
59
|
+
r(this, "getUncategorisedBookings", async () => {
|
|
60
60
|
const { data: e } = await n.get(
|
|
61
61
|
i.UNCATEGORISED_BOOKINGS
|
|
62
62
|
);
|
|
63
63
|
return e != null && e.success ? {
|
|
64
64
|
flightBookings: u(e.data.flight_bookings ?? []),
|
|
65
|
-
hotelBookings:
|
|
65
|
+
hotelBookings: l(e.data.hotel_bookings ?? [])
|
|
66
66
|
} : {
|
|
67
67
|
flightBookings: [],
|
|
68
68
|
hotelBookings: []
|
|
69
69
|
};
|
|
70
70
|
});
|
|
71
|
-
|
|
71
|
+
r(this, "addBookingToTrip", async (e, s, t) => {
|
|
72
72
|
const { data: c } = await n.put(i.ADD_BOOKING, {
|
|
73
73
|
trip_id: e,
|
|
74
74
|
booking_id: s,
|
|
75
|
-
booking_type:
|
|
75
|
+
booking_type: t
|
|
76
76
|
});
|
|
77
77
|
return c.success;
|
|
78
78
|
});
|
|
79
|
+
r(this, "removeBookingFromTrip", async (e, s, t) => {
|
|
80
|
+
const { data: c } = await n.put(
|
|
81
|
+
i.REMOVE_BOOKING,
|
|
82
|
+
p({
|
|
83
|
+
trip_id: e,
|
|
84
|
+
booking_id: s,
|
|
85
|
+
booking_type: t
|
|
86
|
+
})
|
|
87
|
+
);
|
|
88
|
+
return c.success;
|
|
89
|
+
});
|
|
79
90
|
}
|
|
80
91
|
}
|
|
81
92
|
const u = (a) => a.map(
|
|
@@ -84,7 +95,7 @@ const u = (a) => a.map(
|
|
|
84
95
|
reference: e.booking_reference,
|
|
85
96
|
startDate: e.departure_date,
|
|
86
97
|
endDate: e.arrival_date,
|
|
87
|
-
bookingType:
|
|
98
|
+
bookingType: m.FLIGHT,
|
|
88
99
|
airlines: e.slices.map((s) => ({
|
|
89
100
|
logo: y + ".svg",
|
|
90
101
|
name: s.carriers.operating[0]
|
|
@@ -101,24 +112,26 @@ const u = (a) => a.map(
|
|
|
101
112
|
passengers: e.passengers.length,
|
|
102
113
|
hasAirlineChanges: !1,
|
|
103
114
|
orderId: e.order_id,
|
|
104
|
-
type: e.type
|
|
115
|
+
type: e.type,
|
|
116
|
+
cancelledAt: e.cancelled_at
|
|
105
117
|
})
|
|
106
|
-
),
|
|
118
|
+
), l = (a) => a.map(
|
|
107
119
|
(e) => o({
|
|
108
120
|
id: e._id,
|
|
109
121
|
reference: e.reference,
|
|
110
122
|
startDate: e.check_in_date,
|
|
111
123
|
endDate: e.check_out_date,
|
|
112
|
-
bookingType:
|
|
124
|
+
bookingType: m.HOTEL,
|
|
113
125
|
name: e.rooms[0].name,
|
|
114
126
|
image: e.images[0],
|
|
115
127
|
guests: e.number_of_guests,
|
|
116
128
|
address: Object.values(e.address).filter((s) => s).map((s) => s.trim()).join(", "),
|
|
117
129
|
rooms: e.rooms.length,
|
|
118
|
-
bookingId: e.booking_id
|
|
130
|
+
bookingId: e.booking_id,
|
|
131
|
+
cancelledAt: e.cancelled_at
|
|
119
132
|
})
|
|
120
|
-
),
|
|
133
|
+
), O = new b();
|
|
121
134
|
export {
|
|
122
135
|
y as D,
|
|
123
|
-
|
|
136
|
+
O as T
|
|
124
137
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
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.USER_CARDS = "user/cards", 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 || {}), _ = /* @__PURE__ */ ((e) => (e.USER_AWARDS = "user/rewards", e.USER_CARDS = "user/cards", e.BANKS = "banks", e.CARDS = "cards", e))(_ || {}), I = /* @__PURE__ */ ((e) => (e.TRIPS = "user/trips", e.ADD_BOOKING = "user/trips/add-booking-to-trip", e.REMOVE_BOOKING = "user/trips/remove-booking-from-trip", e.UNCATEGORISED_BOOKINGS = "/user/trips/get-uncategorized-bookings", e))(I || {}), O = /* @__PURE__ */ ((e) => (e.USER_HOTEL_BOOKINGS = "/user/bookings/hotels", e.USER_FLIGHT_BOOKINGS = "/user/bookings/flights", e.INITIATE_FLIGHT_CANCEL = "/duffel/flights/initiate-order-cancellation", e.CONFIRM_FLIGHT_CANCEL = "/duffel/flights/confirm-order-cancellation", e.CANCEL_HOTEL_BOOKING = "/duffel/hotels/cancel", e))(O || {});
|
|
2
2
|
export {
|
|
3
3
|
r as EAuthEndpoints,
|
|
4
|
-
|
|
4
|
+
O as EBookingEndpoints,
|
|
5
5
|
a as ECurrencyEndpoints,
|
|
6
|
-
|
|
6
|
+
I as EMyTripsEndpoints,
|
|
7
7
|
_ as EWalletEndpoints
|
|
8
8
|
};
|
|
@@ -1,63 +1,64 @@
|
|
|
1
|
-
import { useQuery as
|
|
2
|
-
import { h as
|
|
1
|
+
import { useQuery as p, useMutation as s } from "@tanstack/react-query";
|
|
2
|
+
import { h as m } from "../../arrayExtensions-DlcBOj5a.js";
|
|
3
3
|
import { E as e } from "../../AccountService-D_6U8vP6.js";
|
|
4
4
|
import "react";
|
|
5
|
-
import { T as
|
|
5
|
+
import { T as t } from "../../TripsService-BbbkMtx6.js";
|
|
6
6
|
import "react/jsx-runtime";
|
|
7
7
|
import "../../context/AwayzContext.js";
|
|
8
|
-
import { awayzClient as
|
|
8
|
+
import { awayzClient as o } 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
|
|
15
|
-
tripId:
|
|
16
|
-
tripDetails:
|
|
14
|
+
const b = ({
|
|
15
|
+
tripId: u,
|
|
16
|
+
tripDetails: a
|
|
17
17
|
}) => {
|
|
18
|
-
if (!
|
|
18
|
+
if (!u)
|
|
19
19
|
throw new Error("Trip ID is required");
|
|
20
|
-
if (!
|
|
20
|
+
if (!a || Object.keys(a).length === 0)
|
|
21
21
|
throw new Error("Trip details must be provided for update");
|
|
22
|
-
},
|
|
23
|
-
const { data:
|
|
22
|
+
}, $ = () => {
|
|
23
|
+
const { data: u = [] } = p({
|
|
24
24
|
queryKey: [
|
|
25
25
|
e.TRIPS,
|
|
26
26
|
"past"
|
|
27
27
|
/* PAST */
|
|
28
28
|
],
|
|
29
|
-
queryFn: () =>
|
|
29
|
+
queryFn: () => t.getTripsByStatus(
|
|
30
30
|
"past"
|
|
31
31
|
/* PAST */
|
|
32
32
|
)
|
|
33
|
-
}), { data:
|
|
33
|
+
}), { data: a = [] } = p({
|
|
34
34
|
queryKey: [
|
|
35
35
|
e.TRIPS,
|
|
36
36
|
"upcoming"
|
|
37
37
|
/* UPCOMING */
|
|
38
38
|
],
|
|
39
|
-
queryFn: () =>
|
|
39
|
+
queryFn: () => t.getTripsByStatus(
|
|
40
40
|
"upcoming"
|
|
41
41
|
/* UPCOMING */
|
|
42
42
|
)
|
|
43
|
-
}), { data:
|
|
43
|
+
}), { data: n } = p({
|
|
44
44
|
queryKey: [e.UNCATEGORISED_BOOKINGS],
|
|
45
|
-
queryFn: () =>
|
|
45
|
+
queryFn: () => t.getUncategorisedBookings()
|
|
46
46
|
}), {
|
|
47
47
|
mutate: y,
|
|
48
|
-
isPending:
|
|
49
|
-
isError:
|
|
50
|
-
error:
|
|
51
|
-
|
|
52
|
-
|
|
48
|
+
isPending: g,
|
|
49
|
+
isError: E,
|
|
50
|
+
error: S,
|
|
51
|
+
isSuccess: l
|
|
52
|
+
} = s({
|
|
53
|
+
mutationFn: async ({ tripId: r, tripDetails: i }) => (b({ tripId: r, tripDetails: i }), await t.updateTrip(r, i)),
|
|
53
54
|
onSuccess: () => {
|
|
54
|
-
|
|
55
|
+
o.invalidateQueries({
|
|
55
56
|
queryKey: [
|
|
56
57
|
e.TRIPS,
|
|
57
58
|
"past"
|
|
58
59
|
/* PAST */
|
|
59
60
|
]
|
|
60
|
-
}),
|
|
61
|
+
}), o.invalidateQueries({
|
|
61
62
|
queryKey: [
|
|
62
63
|
e.TRIPS,
|
|
63
64
|
"upcoming"
|
|
@@ -66,26 +67,27 @@ const F = ({
|
|
|
66
67
|
});
|
|
67
68
|
}
|
|
68
69
|
}), {
|
|
69
|
-
mutate:
|
|
70
|
-
isPending:
|
|
71
|
-
isError:
|
|
72
|
-
error:
|
|
73
|
-
|
|
70
|
+
mutate: q,
|
|
71
|
+
isPending: w,
|
|
72
|
+
isError: v,
|
|
73
|
+
error: P,
|
|
74
|
+
isSuccess: B
|
|
75
|
+
} = s({
|
|
74
76
|
mutationFn: async (r) => {
|
|
75
77
|
if (!r)
|
|
76
78
|
throw new Error("Trip details are required to create a trip");
|
|
77
79
|
if (!r.name || !r.startDate || !r.endDate)
|
|
78
80
|
throw new Error("Trip name, start date, and end date are required");
|
|
79
|
-
return await
|
|
81
|
+
return await t.createTrip(r);
|
|
80
82
|
},
|
|
81
83
|
onSuccess: () => {
|
|
82
|
-
|
|
84
|
+
o.invalidateQueries({
|
|
83
85
|
queryKey: [
|
|
84
86
|
e.TRIPS,
|
|
85
87
|
"past"
|
|
86
88
|
/* PAST */
|
|
87
89
|
]
|
|
88
|
-
}),
|
|
90
|
+
}), o.invalidateQueries({
|
|
89
91
|
queryKey: [
|
|
90
92
|
e.TRIPS,
|
|
91
93
|
"upcoming"
|
|
@@ -94,104 +96,149 @@ const F = ({
|
|
|
94
96
|
});
|
|
95
97
|
}
|
|
96
98
|
}), {
|
|
97
|
-
mutate:
|
|
98
|
-
isPending:
|
|
99
|
-
isError:
|
|
100
|
-
error:
|
|
101
|
-
|
|
99
|
+
mutate: K,
|
|
100
|
+
isPending: I,
|
|
101
|
+
isError: k,
|
|
102
|
+
error: f,
|
|
103
|
+
isSuccess: R
|
|
104
|
+
} = s({
|
|
102
105
|
mutationFn: async (r) => {
|
|
103
106
|
if (!r)
|
|
104
107
|
throw new Error("Trip ID is required to delete a trip");
|
|
105
|
-
await
|
|
108
|
+
await t.deleteTrip(r);
|
|
106
109
|
},
|
|
107
110
|
onSuccess: () => {
|
|
108
|
-
|
|
111
|
+
o.invalidateQueries({
|
|
109
112
|
queryKey: [
|
|
110
113
|
e.TRIPS,
|
|
111
114
|
"past"
|
|
112
115
|
/* PAST */
|
|
113
116
|
]
|
|
114
|
-
}),
|
|
117
|
+
}), o.invalidateQueries({
|
|
115
118
|
queryKey: [
|
|
116
119
|
e.TRIPS,
|
|
117
120
|
"upcoming"
|
|
118
121
|
/* UPCOMING */
|
|
119
122
|
]
|
|
120
|
-
}),
|
|
123
|
+
}), o.invalidateQueries({
|
|
121
124
|
queryKey: [e.UNCATEGORISED_BOOKINGS]
|
|
122
125
|
});
|
|
123
126
|
}
|
|
124
127
|
}), {
|
|
125
|
-
mutate:
|
|
126
|
-
isPending:
|
|
127
|
-
isError:
|
|
128
|
-
error:
|
|
129
|
-
} =
|
|
128
|
+
mutate: h,
|
|
129
|
+
isPending: Q,
|
|
130
|
+
isError: F,
|
|
131
|
+
error: O
|
|
132
|
+
} = s({
|
|
130
133
|
mutationFn: async ({
|
|
131
134
|
tripId: r,
|
|
132
|
-
booking:
|
|
135
|
+
booking: i
|
|
133
136
|
}) => {
|
|
134
137
|
if (!r)
|
|
135
138
|
throw new Error("Trip ID is required to add a booking");
|
|
136
|
-
if (!
|
|
139
|
+
if (!i)
|
|
137
140
|
throw new Error("Booking is required to add a booking");
|
|
138
|
-
return await
|
|
141
|
+
return await t.addBookingToTrip(
|
|
142
|
+
r,
|
|
143
|
+
i.id,
|
|
144
|
+
i.bookingType
|
|
145
|
+
);
|
|
146
|
+
},
|
|
147
|
+
onSuccess: () => {
|
|
148
|
+
o.invalidateQueries({
|
|
149
|
+
queryKey: [
|
|
150
|
+
e.TRIPS,
|
|
151
|
+
"past"
|
|
152
|
+
/* PAST */
|
|
153
|
+
]
|
|
154
|
+
}), o.invalidateQueries({
|
|
155
|
+
queryKey: [
|
|
156
|
+
e.TRIPS,
|
|
157
|
+
"upcoming"
|
|
158
|
+
/* UPCOMING */
|
|
159
|
+
]
|
|
160
|
+
}), o.invalidateQueries({
|
|
161
|
+
queryKey: [e.UNCATEGORISED_BOOKINGS]
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
}), {
|
|
165
|
+
mutate: U,
|
|
166
|
+
isPending: D,
|
|
167
|
+
isError: C,
|
|
168
|
+
error: G
|
|
169
|
+
} = s({
|
|
170
|
+
mutationFn: async ({
|
|
171
|
+
tripId: r,
|
|
172
|
+
booking: i
|
|
173
|
+
}) => {
|
|
174
|
+
if (!r)
|
|
175
|
+
throw new Error("Trip ID is required to remove a booking");
|
|
176
|
+
if (!i)
|
|
177
|
+
throw new Error("Booking is required to remove a booking");
|
|
178
|
+
return await t.removeBookingFromTrip(
|
|
139
179
|
r,
|
|
140
|
-
|
|
141
|
-
|
|
180
|
+
i.id,
|
|
181
|
+
i.bookingType
|
|
142
182
|
);
|
|
143
183
|
},
|
|
144
184
|
onSuccess: () => {
|
|
145
|
-
|
|
185
|
+
o.invalidateQueries({
|
|
146
186
|
queryKey: [
|
|
147
187
|
e.TRIPS,
|
|
148
188
|
"past"
|
|
149
189
|
/* PAST */
|
|
150
190
|
]
|
|
151
|
-
}),
|
|
191
|
+
}), o.invalidateQueries({
|
|
152
192
|
queryKey: [
|
|
153
193
|
e.TRIPS,
|
|
154
194
|
"upcoming"
|
|
155
195
|
/* UPCOMING */
|
|
156
196
|
]
|
|
157
|
-
}),
|
|
197
|
+
}), o.invalidateQueries({
|
|
158
198
|
queryKey: [e.UNCATEGORISED_BOOKINGS]
|
|
159
199
|
});
|
|
160
200
|
}
|
|
161
|
-
}),
|
|
201
|
+
}), N = [...u, ...a], d = (n == null ? void 0 : n.flightBookings) || [], T = (n == null ? void 0 : n.hotelBookings) || [], A = [
|
|
162
202
|
...d,
|
|
163
203
|
...T
|
|
164
|
-
].sort((r,
|
|
204
|
+
].sort((r, i) => m(r.startDate).diff(m(i.startDate)));
|
|
165
205
|
return {
|
|
166
206
|
// Trips
|
|
167
|
-
allTrips:
|
|
168
|
-
pastTrips:
|
|
169
|
-
upcomingTrips:
|
|
207
|
+
allTrips: N,
|
|
208
|
+
pastTrips: u,
|
|
209
|
+
upcomingTrips: a,
|
|
170
210
|
// Bookings
|
|
171
|
-
allUncategorisedBookings:
|
|
211
|
+
allUncategorisedBookings: A,
|
|
172
212
|
uncategorisedFlightBookings: d,
|
|
173
213
|
uncategorisedHotelBookings: T,
|
|
174
214
|
// Trip Management
|
|
175
|
-
createTrip:
|
|
176
|
-
isCreateTripPending:
|
|
177
|
-
isCreateTripError:
|
|
178
|
-
createTripError:
|
|
215
|
+
createTrip: q,
|
|
216
|
+
isCreateTripPending: w,
|
|
217
|
+
isCreateTripError: v,
|
|
218
|
+
createTripError: P,
|
|
219
|
+
isCreateTripSuccess: B,
|
|
179
220
|
updateTrip: y,
|
|
180
|
-
isUpdateTripPending:
|
|
181
|
-
isUpdateTripError:
|
|
182
|
-
updateTripError:
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
221
|
+
isUpdateTripPending: g,
|
|
222
|
+
isUpdateTripError: E,
|
|
223
|
+
updateTripError: S,
|
|
224
|
+
isUpdateTripSuccess: l,
|
|
225
|
+
deleteTrip: K,
|
|
226
|
+
isDeleteTripPending: I,
|
|
227
|
+
isDeleteTripError: k,
|
|
228
|
+
deleteTripError: f,
|
|
229
|
+
isDeleteTripSuccess: R,
|
|
187
230
|
// Booking Management
|
|
188
|
-
addBookingToTrip:
|
|
189
|
-
isAddBookingToTripPending:
|
|
190
|
-
isAddBookingToTripError:
|
|
191
|
-
addBookingToTripError:
|
|
231
|
+
addBookingToTrip: h,
|
|
232
|
+
isAddBookingToTripPending: Q,
|
|
233
|
+
isAddBookingToTripError: F,
|
|
234
|
+
addBookingToTripError: O,
|
|
235
|
+
removeBookingFromTrip: U,
|
|
236
|
+
isRemoveBookingFromTripPending: D,
|
|
237
|
+
isRemoveBookingFromTripError: C,
|
|
238
|
+
removeBookingFromTripError: G
|
|
192
239
|
};
|
|
193
240
|
};
|
|
194
241
|
export {
|
|
195
|
-
|
|
196
|
-
|
|
242
|
+
$ as useTripManagement,
|
|
243
|
+
b as validateUpdateTripArgs
|
|
197
244
|
};
|
|
@@ -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-BbbkMtx6.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";
|
|
@@ -34,6 +34,7 @@ export declare enum EWalletEndpoints {
|
|
|
34
34
|
export declare enum EMyTripsEndpoints {
|
|
35
35
|
TRIPS = "user/trips",
|
|
36
36
|
ADD_BOOKING = "user/trips/add-booking-to-trip",
|
|
37
|
+
REMOVE_BOOKING = "user/trips/remove-booking-from-trip",
|
|
37
38
|
UNCATEGORISED_BOOKINGS = "/user/trips/get-uncategorized-bookings"
|
|
38
39
|
}
|
|
39
40
|
export declare enum EBookingEndpoints {
|
|
@@ -48,6 +48,10 @@ export interface IUseTripManagement {
|
|
|
48
48
|
* Indicates if there was an error while creating a trip
|
|
49
49
|
*/
|
|
50
50
|
isCreateTripError: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Indicates if the trip was successfully created
|
|
53
|
+
*/
|
|
54
|
+
isCreateTripSuccess: boolean;
|
|
51
55
|
/**
|
|
52
56
|
* Error object if there was an error while creating a trip
|
|
53
57
|
*/
|
|
@@ -65,6 +69,10 @@ export interface IUseTripManagement {
|
|
|
65
69
|
* Indicates if there was an error while updating a trip
|
|
66
70
|
*/
|
|
67
71
|
isUpdateTripError: boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Indicates if the trip was successfully updated
|
|
74
|
+
*/
|
|
75
|
+
isUpdateTripSuccess: boolean;
|
|
68
76
|
/**
|
|
69
77
|
* Error object if there was an error while updating a trip
|
|
70
78
|
*/
|
|
@@ -82,6 +90,10 @@ export interface IUseTripManagement {
|
|
|
82
90
|
* Indicates if there was an error while deleting a trip
|
|
83
91
|
*/
|
|
84
92
|
isDeleteTripError: boolean;
|
|
93
|
+
/**
|
|
94
|
+
* Indicates if the trip was successfully deleted
|
|
95
|
+
*/
|
|
96
|
+
isDeleteTripSuccess: boolean;
|
|
85
97
|
/**
|
|
86
98
|
* Error object if there was an error while deleting a trip
|
|
87
99
|
*/
|
|
@@ -106,4 +118,24 @@ export interface IUseTripManagement {
|
|
|
106
118
|
* Error object if there was an error while adding a booking to a trip
|
|
107
119
|
*/
|
|
108
120
|
addBookingToTripError: Error | null;
|
|
121
|
+
/**
|
|
122
|
+
* Function to remove a booking from a trip
|
|
123
|
+
* @param args - Object containing tripId and bookingId to be removed
|
|
124
|
+
*/
|
|
125
|
+
removeBookingFromTrip: (args: {
|
|
126
|
+
tripId: string;
|
|
127
|
+
booking: IBooking;
|
|
128
|
+
}) => void;
|
|
129
|
+
/**
|
|
130
|
+
* Indicates if the remove booking from trip request is pending
|
|
131
|
+
*/
|
|
132
|
+
isRemoveBookingFromTripPending: boolean;
|
|
133
|
+
/**
|
|
134
|
+
* Indicates if there was an error while removing a booking from a trip
|
|
135
|
+
*/
|
|
136
|
+
isRemoveBookingFromTripError: boolean;
|
|
137
|
+
/**
|
|
138
|
+
* Error object if there was an error while removing a booking from a trip
|
|
139
|
+
*/
|
|
140
|
+
removeBookingFromTripError: Error | null;
|
|
109
141
|
}
|
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
import { IAirport } from '@type-op/shared';
|
|
2
|
-
export interface IBed {
|
|
3
|
-
}
|
|
1
|
+
import { IAirport, ICoordinates } from '@type-op/shared';
|
|
4
2
|
export interface IGuest {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
photo: string[];
|
|
9
|
-
totalAmount: number;
|
|
10
|
-
name: string;
|
|
3
|
+
familyName: string;
|
|
4
|
+
givenName: string;
|
|
5
|
+
type: string;
|
|
11
6
|
}
|
|
12
7
|
export interface IAddress {
|
|
13
8
|
lineOne: string;
|
|
@@ -18,12 +13,7 @@ export interface IAddress {
|
|
|
18
13
|
}
|
|
19
14
|
export interface IHotelBookingDetails {
|
|
20
15
|
id: string;
|
|
21
|
-
userId: string;
|
|
22
16
|
status: string;
|
|
23
|
-
accommodationId: string;
|
|
24
|
-
numberOfGuests: number;
|
|
25
|
-
rateId: string;
|
|
26
|
-
quoteId: string;
|
|
27
17
|
baseAmount: number;
|
|
28
18
|
baseCurrency: string;
|
|
29
19
|
taxAmount: number;
|
|
@@ -32,12 +22,19 @@ export interface IHotelBookingDetails {
|
|
|
32
22
|
feeCurrency: string;
|
|
33
23
|
totalAmount: number;
|
|
34
24
|
totalCurrency: string;
|
|
35
|
-
checkInDate: string;
|
|
36
|
-
checkOutDate: string;
|
|
37
25
|
images: string[];
|
|
38
|
-
|
|
26
|
+
numberOfRooms: number;
|
|
39
27
|
address: IAddress;
|
|
40
28
|
guests: IGuest[];
|
|
29
|
+
reference: string;
|
|
30
|
+
name: string;
|
|
31
|
+
description: string;
|
|
32
|
+
cancelledAt?: string;
|
|
33
|
+
checkoutDate: string;
|
|
34
|
+
checkoutBeforeTime: string;
|
|
35
|
+
checkinDate: string;
|
|
36
|
+
checkinAfterTime: string;
|
|
37
|
+
coordinates: ICoordinates;
|
|
41
38
|
}
|
|
42
39
|
export interface IFlightConditionDetails {
|
|
43
40
|
allowed: boolean;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { Moment } from 'moment';
|
|
2
1
|
export declare enum EBookingType {
|
|
3
|
-
HOTEL = "
|
|
4
|
-
FLIGHT = "
|
|
2
|
+
HOTEL = "Hotel",
|
|
3
|
+
FLIGHT = "Flight"
|
|
5
4
|
}
|
|
6
5
|
export interface ICreateTripRequest {
|
|
7
6
|
name: string;
|
|
@@ -21,9 +20,9 @@ export interface ITrip {
|
|
|
21
20
|
export interface IBooking {
|
|
22
21
|
id: string;
|
|
23
22
|
reference: string;
|
|
24
|
-
startDate:
|
|
25
|
-
endDate:
|
|
26
|
-
cancelledAt?:
|
|
23
|
+
startDate: string;
|
|
24
|
+
endDate: string;
|
|
25
|
+
cancelledAt?: string;
|
|
27
26
|
bookingType: EBookingType;
|
|
28
27
|
}
|
|
29
28
|
export interface IHotelBooking extends IBooking {
|
|
@@ -14,6 +14,7 @@ declare class _TripsService {
|
|
|
14
14
|
deleteTrip: (tripId: string) => Promise<any>;
|
|
15
15
|
getUncategorisedBookings: () => Promise<IUncategorizedBookings>;
|
|
16
16
|
addBookingToTrip: (tripId: string, bookingId: string, bookingType: EBookingType) => Promise<any>;
|
|
17
|
+
removeBookingFromTrip: (tripId: string, bookingId: string, bookingType: EBookingType) => Promise<any>;
|
|
17
18
|
}
|
|
18
19
|
export declare const TripsService: _TripsService;
|
|
19
20
|
export {};
|
|
@@ -1,35 +1,66 @@
|
|
|
1
1
|
var m = Object.defineProperty;
|
|
2
|
-
var l = (n,
|
|
3
|
-
var o = (n,
|
|
2
|
+
var l = (n, e, a) => e in n ? m(n, e, { enumerable: !0, configurable: !0, writable: !0, value: a }) : n[e] = a;
|
|
3
|
+
var o = (n, e, a) => l(n, typeof e != "symbol" ? e + "" : e, a);
|
|
4
4
|
import "../../arrayExtensions-DlcBOj5a.js";
|
|
5
|
-
import { c as i, b as
|
|
5
|
+
import { c as i, b as s } from "../../AccountService-D_6U8vP6.js";
|
|
6
6
|
import "react";
|
|
7
|
-
import { EBookingEndpoints as
|
|
7
|
+
import { EBookingEndpoints as d } from "../../configs/endpoints.js";
|
|
8
8
|
const u = (n) => {
|
|
9
|
-
const
|
|
9
|
+
const e = /P((\d+)D)?T((\d+)H)?((\d+)M)?/, a = n.match(e);
|
|
10
10
|
if (a) {
|
|
11
|
-
const
|
|
12
|
-
return `${
|
|
11
|
+
const c = a[2] ? `${a[2]}d ` : "", t = a[4] ? `${a[4]}h ` : "", r = a[6] ? `${a[6]}m` : "";
|
|
12
|
+
return `${c}${t}${r}`.trim();
|
|
13
13
|
} else
|
|
14
14
|
return n;
|
|
15
15
|
};
|
|
16
16
|
class _ {
|
|
17
17
|
constructor() {
|
|
18
|
-
o(this, "getHotelBooking", async (
|
|
18
|
+
o(this, "getHotelBooking", async (e) => {
|
|
19
19
|
const { data: a } = await i.get(
|
|
20
|
-
`${
|
|
20
|
+
`${d.USER_HOTEL_BOOKINGS}/${e}`
|
|
21
21
|
);
|
|
22
|
-
return
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
return {
|
|
23
|
+
id: a.data._id,
|
|
24
|
+
totalAmount: parseFloat(a.data.total_amount),
|
|
25
|
+
feeAmount: parseFloat(a.data.fee_amount),
|
|
26
|
+
taxAmount: parseFloat(a.data.tax_amount),
|
|
27
|
+
baseAmount: parseFloat(a.data.base_amount),
|
|
28
|
+
cancelledAt: a.data.cancelled_at,
|
|
29
|
+
totalCurrency: a.data.total_currency,
|
|
30
|
+
baseCurrency: a.data.base_currency,
|
|
31
|
+
feeCurrency: a.data.fee_currency,
|
|
32
|
+
taxCurrency: a.data.tax_currency,
|
|
33
|
+
status: a.data.status,
|
|
34
|
+
description: a.data.data.accommodation.description,
|
|
35
|
+
name: a.data.data.accommodation.name,
|
|
36
|
+
reference: a.data.reference,
|
|
37
|
+
address: {
|
|
38
|
+
lineOne: a.data.address.line_one,
|
|
39
|
+
cityName: a.data.address.city_name,
|
|
40
|
+
postalCode: a.data.address.postal_code,
|
|
41
|
+
countryCode: a.data.address.country_code,
|
|
42
|
+
region: a.data.address.region || null
|
|
43
|
+
},
|
|
44
|
+
checkinDate: a.data.checkin_date,
|
|
45
|
+
checkinAfterTime: a.data.data.accommodation.check_in_information.check_in_after_time,
|
|
46
|
+
checkoutDate: a.data.checkout_date,
|
|
47
|
+
checkoutBeforeTime: a.data.data.accommodation.check_in_information.check_out_before_time,
|
|
48
|
+
coordinates: {
|
|
49
|
+
latitude: a.data.data.accommodation.location.geographic_coordinates.latitude,
|
|
50
|
+
longitude: a.data.data.accommodation.location.geographic_coordinates.longitude
|
|
51
|
+
},
|
|
52
|
+
images: a.data.images,
|
|
53
|
+
guests: a.data.data.guests.map((t, r) => ({
|
|
54
|
+
familyName: t.family_name,
|
|
55
|
+
givenName: t.given_name,
|
|
56
|
+
type: a.data.data.guest_types[r].type
|
|
57
|
+
})),
|
|
58
|
+
numberOfRooms: a.data.rooms.length
|
|
59
|
+
};
|
|
29
60
|
});
|
|
30
|
-
o(this, "getFlightBooking", async (
|
|
61
|
+
o(this, "getFlightBooking", async (e) => {
|
|
31
62
|
const { data: a } = await i.get(
|
|
32
|
-
`${
|
|
63
|
+
`${d.USER_FLIGHT_BOOKINGS}/${e}`
|
|
33
64
|
);
|
|
34
65
|
return {
|
|
35
66
|
id: a.data._id,
|
|
@@ -45,51 +76,51 @@ class _ {
|
|
|
45
76
|
flightOfferId: a.data.flight_offer_id,
|
|
46
77
|
cancelledAt: a.data.cancelled_at,
|
|
47
78
|
airlines: a.data.data.slices[0].segments.map(
|
|
48
|
-
(
|
|
79
|
+
(t) => t.operating_carrier.name
|
|
49
80
|
),
|
|
50
|
-
passengers: a.data.data.passengers.map((
|
|
51
|
-
id:
|
|
52
|
-
givenName:
|
|
53
|
-
familyName:
|
|
54
|
-
type:
|
|
55
|
-
title:
|
|
56
|
-
email:
|
|
57
|
-
gender:
|
|
58
|
-
phoneNumber:
|
|
81
|
+
passengers: a.data.data.passengers.map((t) => ({
|
|
82
|
+
id: t.id,
|
|
83
|
+
givenName: t.given_ame,
|
|
84
|
+
familyName: t.family_name,
|
|
85
|
+
type: t.type,
|
|
86
|
+
title: t.title,
|
|
87
|
+
email: t.email,
|
|
88
|
+
gender: t.gender,
|
|
89
|
+
phoneNumber: t.phone_number
|
|
59
90
|
})),
|
|
60
|
-
flights: a.data.data.slices.map((
|
|
61
|
-
departingAt:
|
|
62
|
-
arrivingAt:
|
|
63
|
-
numberOfStops:
|
|
91
|
+
flights: a.data.data.slices.map((t) => ({
|
|
92
|
+
departingAt: t.segments[0].departing_at,
|
|
93
|
+
arrivingAt: t.segments.getLast().arriving_at,
|
|
94
|
+
numberOfStops: t.segments.length - 1,
|
|
64
95
|
reference: a.data.booking_reference,
|
|
65
|
-
durationInMinutes: u(
|
|
66
|
-
origin:
|
|
67
|
-
destination:
|
|
96
|
+
durationInMinutes: u(t.duration),
|
|
97
|
+
origin: s(t.origin),
|
|
98
|
+
destination: s(t.destination)
|
|
68
99
|
})),
|
|
69
100
|
availableActions: a.data.available_actions
|
|
70
101
|
};
|
|
71
102
|
});
|
|
72
|
-
o(this, "initiateCancelFlightBooking", async (
|
|
103
|
+
o(this, "initiateCancelFlightBooking", async (e) => {
|
|
73
104
|
const { data: a } = await i.put(
|
|
74
|
-
`${
|
|
105
|
+
`${d.INITIATE_FLIGHT_CANCEL}/${e}`
|
|
75
106
|
);
|
|
76
107
|
return a.success;
|
|
77
108
|
});
|
|
78
|
-
o(this, "confirmCancelFlightBooking", async (
|
|
109
|
+
o(this, "confirmCancelFlightBooking", async (e) => {
|
|
79
110
|
const { data: a } = await i.put(
|
|
80
|
-
`${
|
|
111
|
+
`${d.CONFIRM_FLIGHT_CANCEL}/${e}`
|
|
81
112
|
);
|
|
82
113
|
return a.success;
|
|
83
114
|
});
|
|
84
|
-
o(this, "cancelHotelBooking", async (
|
|
115
|
+
o(this, "cancelHotelBooking", async (e) => {
|
|
85
116
|
const { data: a } = await i.post(
|
|
86
|
-
`${
|
|
117
|
+
`${d.CANCEL_HOTEL_BOOKING}/${e}`
|
|
87
118
|
);
|
|
88
119
|
return a.success;
|
|
89
120
|
});
|
|
90
121
|
}
|
|
91
122
|
}
|
|
92
|
-
const
|
|
123
|
+
const k = new _();
|
|
93
124
|
export {
|
|
94
|
-
|
|
125
|
+
k as BookingService
|
|
95
126
|
};
|
|
@@ -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-BbbkMtx6.js";
|
|
6
6
|
import "react";
|
|
7
7
|
export {
|
|
8
8
|
s as TripsService
|