@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 l, useMutation as c } from "@tanstack/react-query";
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 q } from "../../configs/awayzClient.js";
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 W = (r, e) => {
17
+ const D = (r, e) => {
18
18
  const {
19
- data: u,
20
- isError: m,
21
- error: E
22
- } = l({
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: g,
29
- error: B
30
- } = l({
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: C,
36
- isPending: h,
37
- isError: p,
38
- error: F,
39
- isSuccess: f
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: O,
51
- isPending: H,
52
- isError: S,
53
- error: G,
54
- isSuccess: y
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: L,
67
- isPending: A,
68
- isError: K,
69
- error: d
66
+ mutate: d,
67
+ isPending: I,
68
+ isError: N,
69
+ error: T
70
70
  } = c({
71
71
  mutationFn: async (s) => {
72
- if (e === i.FLIGHT && (n != null && n.airlineInitiatedChanges))
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: n.airlineInitiatedChanges[0].id
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
- q.invalidateQueries({ queryKey: s });
93
+ v.invalidateQueries({ queryKey: s });
90
94
  });
91
- }, I = m || g, N = E || B;
95
+ }, q = B || p, w = h || F;
92
96
  return {
93
- details: e === i.HOTEL ? u : n,
94
- isError: I,
95
- error: N,
96
- initiateCancellation: C,
97
- isInitiatingCancellation: h,
98
- isInitiateCancellationError: p,
99
- initiateCancellationError: F,
100
- isInitiateCancellationSuccess: f,
101
- cancelBooking: O,
102
- isCancellingBooking: H,
103
- isCancelBookingError: S,
104
- cancelBookingError: G,
105
- isCancelBookingSuccess: y,
106
- actionAirlineChanges: L,
107
- isActionAirlineChangesPending: A,
108
- isActionAirlineChangesError: K,
109
- actionAirlineChangesError: d
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
- W as useBookingManagement
118
+ D as useBookingManagement
114
119
  };
@@ -47,11 +47,16 @@ export interface IUseBookingManagement {
47
47
  */
48
48
  isCancellingBooking: boolean;
49
49
  /**
50
- * Indicates if there was an error while canceling the booking
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 canceling the booking
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 i = (n, e, a) => _(n, typeof e != "symbol" ? e + "" : e, a);
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
- i(this, "getHotelBooking", async (e) => {
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((r) => r.url),
54
- guests: a.data.guests.map((r, m) => ({
55
- familyName: r.family_name,
56
- givenName: r.given_name,
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
- (r) => ({
62
- refundAmount: parseFloat(r.refund_amount),
63
- currency: r.currency,
64
- before: r.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
- i(this, "getFlightBooking", async (e) => {
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
- i(this, "initiateCancelFlightBooking", async (e) => {
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
- i(this, "confirmCancelFlightBooking", async (e) => {
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
- i(this, "cancelHotelBooking", async (e) => {
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
- i(this, "actionAirlineChanges", async ({
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" : "reject",
155
+ action_taken: a ? "accept" : "cancel",
156
156
  aic_id: o
157
157
  }
158
158
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@odynn/awayz-core",
3
- "version": "0.5.7",
3
+ "version": "0.5.9",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"