@odynn/awayz-core 0.5.7 → 0.5.9
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,10 +1,10 @@
|
|
|
1
|
-
import { useQuery as
|
|
1
|
+
import { useQuery as g, useMutation as c } from "@tanstack/react-query";
|
|
2
2
|
import "../../arrayExtensions-DlcBOj5a.js";
|
|
3
3
|
import { E as o } from "../../AccountService-CtMwRIoL.js";
|
|
4
4
|
import "react";
|
|
5
5
|
import "react/jsx-runtime";
|
|
6
6
|
import "../../context/AwayzContext.js";
|
|
7
|
-
import { awayzClient as
|
|
7
|
+
import { awayzClient as v } from "../../configs/awayzClient.js";
|
|
8
8
|
import { EBookingType as i } from "../../services/trips/TripService.types.js";
|
|
9
9
|
import "../../services/noRetryInstance.js";
|
|
10
10
|
import '../../assets/_styles5.css';import '../../assets/_styles4.css';import '../../assets/_styles3.css';import '../../assets/_styles2.css';import '../../assets/_styles.css';/* empty css */
|
|
@@ -14,29 +14,29 @@ import "react-i18next";
|
|
|
14
14
|
/* empty css */
|
|
15
15
|
/* empty css */
|
|
16
16
|
import { BookingService as t } from "../../services/bookings/BookingService.js";
|
|
17
|
-
const
|
|
17
|
+
const D = (r, e) => {
|
|
18
18
|
const {
|
|
19
|
-
data:
|
|
20
|
-
isError:
|
|
21
|
-
error:
|
|
22
|
-
} =
|
|
19
|
+
data: C,
|
|
20
|
+
isError: B,
|
|
21
|
+
error: h
|
|
22
|
+
} = g({
|
|
23
23
|
queryKey: [o.BOOKING, r, i.HOTEL],
|
|
24
24
|
queryFn: () => t.getHotelBooking(r),
|
|
25
25
|
enabled: e === i.HOTEL && !!r
|
|
26
26
|
}), {
|
|
27
27
|
data: n,
|
|
28
|
-
isError:
|
|
29
|
-
error:
|
|
30
|
-
} =
|
|
28
|
+
isError: p,
|
|
29
|
+
error: F
|
|
30
|
+
} = g({
|
|
31
31
|
queryKey: [o.BOOKING, r, i.FLIGHT],
|
|
32
32
|
queryFn: () => t.getFlightBooking(r),
|
|
33
33
|
enabled: e === i.FLIGHT && !!r
|
|
34
34
|
}), {
|
|
35
|
-
mutate:
|
|
36
|
-
isPending:
|
|
37
|
-
isError:
|
|
38
|
-
error:
|
|
39
|
-
isSuccess:
|
|
35
|
+
mutate: O,
|
|
36
|
+
isPending: f,
|
|
37
|
+
isError: H,
|
|
38
|
+
error: S,
|
|
39
|
+
isSuccess: G
|
|
40
40
|
} = c({
|
|
41
41
|
mutationFn: async () => {
|
|
42
42
|
if (e === i.FLIGHT)
|
|
@@ -47,11 +47,11 @@ const W = (r, e) => {
|
|
|
47
47
|
a();
|
|
48
48
|
}
|
|
49
49
|
}), {
|
|
50
|
-
mutate:
|
|
51
|
-
isPending:
|
|
52
|
-
isError:
|
|
53
|
-
error:
|
|
54
|
-
isSuccess:
|
|
50
|
+
mutate: y,
|
|
51
|
+
isPending: l,
|
|
52
|
+
isError: L,
|
|
53
|
+
error: A,
|
|
54
|
+
isSuccess: K
|
|
55
55
|
} = c({
|
|
56
56
|
mutationFn: async () => {
|
|
57
57
|
if (e === i.FLIGHT)
|
|
@@ -63,17 +63,21 @@ const W = (r, e) => {
|
|
|
63
63
|
a();
|
|
64
64
|
}
|
|
65
65
|
}), {
|
|
66
|
-
mutate:
|
|
67
|
-
isPending:
|
|
68
|
-
isError:
|
|
69
|
-
error:
|
|
66
|
+
mutate: d,
|
|
67
|
+
isPending: I,
|
|
68
|
+
isError: N,
|
|
69
|
+
error: T
|
|
70
70
|
} = c({
|
|
71
71
|
mutationFn: async (s) => {
|
|
72
|
-
|
|
72
|
+
var m, E;
|
|
73
|
+
const u = (E = (m = n == null ? void 0 : n.airlineInitiatedChanges) == null ? void 0 : m.filter(
|
|
74
|
+
(P) => !P.actionTaken
|
|
75
|
+
)) == null ? void 0 : E[0];
|
|
76
|
+
if (e === i.FLIGHT && (n != null && n.airlineInitiatedChanges) && u)
|
|
73
77
|
return t.actionAirlineChanges({
|
|
74
78
|
bookingId: r,
|
|
75
79
|
acceptChanges: s,
|
|
76
|
-
aicId:
|
|
80
|
+
aicId: u.id
|
|
77
81
|
});
|
|
78
82
|
throw new Error("Not supported for hotel bookings");
|
|
79
83
|
},
|
|
@@ -86,29 +90,30 @@ const W = (r, e) => {
|
|
|
86
90
|
[o.TRIPS],
|
|
87
91
|
[o.UNCATEGORISED_BOOKINGS]
|
|
88
92
|
].forEach((s) => {
|
|
89
|
-
|
|
93
|
+
v.invalidateQueries({ queryKey: s });
|
|
90
94
|
});
|
|
91
|
-
},
|
|
95
|
+
}, q = B || p, w = h || F;
|
|
92
96
|
return {
|
|
93
|
-
details: e === i.HOTEL ?
|
|
94
|
-
isError:
|
|
95
|
-
error:
|
|
96
|
-
initiateCancellation:
|
|
97
|
-
isInitiatingCancellation:
|
|
98
|
-
isInitiateCancellationError:
|
|
99
|
-
initiateCancellationError:
|
|
100
|
-
isInitiateCancellationSuccess:
|
|
101
|
-
cancelBooking:
|
|
102
|
-
isCancellingBooking:
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
97
|
+
details: e === i.HOTEL ? C : n,
|
|
98
|
+
isError: q,
|
|
99
|
+
error: w,
|
|
100
|
+
initiateCancellation: O,
|
|
101
|
+
isInitiatingCancellation: f,
|
|
102
|
+
isInitiateCancellationError: H,
|
|
103
|
+
initiateCancellationError: S,
|
|
104
|
+
isInitiateCancellationSuccess: G,
|
|
105
|
+
cancelBooking: y,
|
|
106
|
+
isCancellingBooking: l,
|
|
107
|
+
isCancelingBooking: l,
|
|
108
|
+
isCancelBookingError: L,
|
|
109
|
+
cancelBookingError: A,
|
|
110
|
+
isCancelBookingSuccess: K,
|
|
111
|
+
actionAirlineChanges: d,
|
|
112
|
+
isActionAirlineChangesPending: I,
|
|
113
|
+
isActionAirlineChangesError: N,
|
|
114
|
+
actionAirlineChangesError: T
|
|
110
115
|
};
|
|
111
116
|
};
|
|
112
117
|
export {
|
|
113
|
-
|
|
118
|
+
D as useBookingManagement
|
|
114
119
|
};
|
|
@@ -47,11 +47,16 @@ export interface IUseBookingManagement {
|
|
|
47
47
|
*/
|
|
48
48
|
isCancellingBooking: boolean;
|
|
49
49
|
/**
|
|
50
|
-
* Indicates if
|
|
50
|
+
* Indicates if the cancel booking request is pending
|
|
51
|
+
* @deprecated Use `isCancellingBooking` instead
|
|
52
|
+
*/
|
|
53
|
+
isCancelingBooking: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Indicates if there was an error while cancelling the booking
|
|
51
56
|
*/
|
|
52
57
|
isCancelBookingError: boolean;
|
|
53
58
|
/**
|
|
54
|
-
* The error object if there was an error while
|
|
59
|
+
* The error object if there was an error while cancelling the booking
|
|
55
60
|
*/
|
|
56
61
|
cancelBookingError: Error | null;
|
|
57
62
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
var u = Object.defineProperty;
|
|
2
2
|
var _ = (n, e, a) => e in n ? u(n, e, { enumerable: !0, configurable: !0, writable: !0, value: a }) : n[e] = a;
|
|
3
|
-
var
|
|
3
|
+
var r = (n, e, a) => _(n, typeof e != "symbol" ? e + "" : e, a);
|
|
4
4
|
import "../../arrayExtensions-DlcBOj5a.js";
|
|
5
5
|
import { c, b as l } from "../../AccountService-CtMwRIoL.js";
|
|
6
6
|
import "react";
|
|
@@ -15,7 +15,7 @@ const p = (n) => {
|
|
|
15
15
|
};
|
|
16
16
|
class g {
|
|
17
17
|
constructor() {
|
|
18
|
-
|
|
18
|
+
r(this, "getHotelBooking", async (e) => {
|
|
19
19
|
var s;
|
|
20
20
|
const { data: a } = await c.get(
|
|
21
21
|
`${d.USER_HOTEL_BOOKINGS}/${e}`
|
|
@@ -50,23 +50,23 @@ class g {
|
|
|
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
|
-
familyName:
|
|
56
|
-
givenName:
|
|
53
|
+
images: a.data.accommodation.photos.map((i) => i.url),
|
|
54
|
+
guests: a.data.guests.map((i, m) => ({
|
|
55
|
+
familyName: i.family_name,
|
|
56
|
+
givenName: i.given_name,
|
|
57
57
|
type: a.data.guest_types[m].type
|
|
58
58
|
})),
|
|
59
59
|
numberOfRooms: (s = a.data.rooms) == null ? void 0 : s.length,
|
|
60
60
|
cancellationTimeline: o.cancellation_timeline.map(
|
|
61
|
-
(
|
|
62
|
-
refundAmount: parseFloat(
|
|
63
|
-
currency:
|
|
64
|
-
before:
|
|
61
|
+
(i) => ({
|
|
62
|
+
refundAmount: parseFloat(i.refund_amount),
|
|
63
|
+
currency: i.currency,
|
|
64
|
+
before: i.before
|
|
65
65
|
})
|
|
66
66
|
)
|
|
67
67
|
};
|
|
68
68
|
});
|
|
69
|
-
|
|
69
|
+
r(this, "getFlightBooking", async (e) => {
|
|
70
70
|
const { data: a } = await c.get(
|
|
71
71
|
`${d.USER_FLIGHT_BOOKINGS}/${e}`
|
|
72
72
|
);
|
|
@@ -125,25 +125,25 @@ class g {
|
|
|
125
125
|
airlineInitiatedChanges: l(a.data.airline_initiated_changes) || []
|
|
126
126
|
};
|
|
127
127
|
});
|
|
128
|
-
|
|
128
|
+
r(this, "initiateCancelFlightBooking", async (e) => {
|
|
129
129
|
const { data: a } = await c.put(
|
|
130
130
|
`${d.INITIATE_FLIGHT_CANCEL}/${e}`
|
|
131
131
|
);
|
|
132
132
|
return a.success;
|
|
133
133
|
});
|
|
134
|
-
|
|
134
|
+
r(this, "confirmCancelFlightBooking", async (e) => {
|
|
135
135
|
const { data: a } = await c.put(
|
|
136
136
|
`${d.CONFIRM_FLIGHT_CANCEL}/${e}`
|
|
137
137
|
);
|
|
138
138
|
return a.success;
|
|
139
139
|
});
|
|
140
|
-
|
|
140
|
+
r(this, "cancelHotelBooking", async (e) => {
|
|
141
141
|
const { data: a } = await c.post(
|
|
142
142
|
`${d.CANCEL_HOTEL_BOOKING}/${e}`
|
|
143
143
|
);
|
|
144
144
|
return a.success;
|
|
145
145
|
});
|
|
146
|
-
|
|
146
|
+
r(this, "actionAirlineChanges", async ({
|
|
147
147
|
bookingId: e,
|
|
148
148
|
acceptChanges: a,
|
|
149
149
|
aicId: o
|
|
@@ -152,7 +152,7 @@ class g {
|
|
|
152
152
|
d.ACTION_AIRLINE_CHANGES,
|
|
153
153
|
{
|
|
154
154
|
booking_id: e,
|
|
155
|
-
action_taken: a ? "accept" : "
|
|
155
|
+
action_taken: a ? "accept" : "cancel",
|
|
156
156
|
aic_id: o
|
|
157
157
|
}
|
|
158
158
|
);
|