@odynn/awayz-flights 0.6.3 → 0.6.4
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/hooks/useFlightSearch/useFlightSearch.js +79 -75
- package/dist/lib/services/flights/FlightsService.d.ts +2 -2
- package/dist/lib/services/flights/FlightsService.types.d.ts +1 -0
- package/dist/lib/stores/useFlightStore.d.ts +2 -0
- package/dist/services/flights/FlightsService.js +35 -33
- package/dist/stores/useFlightStore.js +8 -6
- package/package.json +2 -2
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { useAwayzContext as
|
|
1
|
+
import { useAwayzContext as X, awayzClient as _, getBaseUrl as Z } from "@odynn/awayz-core";
|
|
2
2
|
import { useMutation as N } from "@tanstack/react-query";
|
|
3
3
|
import "../../moment-BGjjqtLQ.js";
|
|
4
4
|
import "../../arrayExtensions-DFLvtO8l.js";
|
|
5
5
|
import { c as W } from "../../objectUtils-CyIaVmog.js";
|
|
6
6
|
import { E as q } from "../../enums-DxmoBOKL.js";
|
|
7
|
-
import { useState as M, useRef as
|
|
7
|
+
import { useState as M, useRef as ee } from "react";
|
|
8
8
|
import { FlightService as D } from "../../services/flights/FlightsService.js";
|
|
9
|
-
import
|
|
9
|
+
import te from "../../stores/useFlightStore.js";
|
|
10
10
|
import { EFlightType as J, EFlightPaymentType as k } from "../../types/enums.js";
|
|
11
|
-
import { ECabinClass as
|
|
12
|
-
import { mapDataToFlightDetails as
|
|
13
|
-
async function
|
|
11
|
+
import { ECabinClass as ne } from "../../types/ECabinClass.js";
|
|
12
|
+
import { mapDataToFlightDetails as re, groupFlightResults as oe, buildFlightSearchQuery as se } from "../../utils/flightUtils.js";
|
|
13
|
+
async function ae(o, t) {
|
|
14
14
|
const r = o.getReader();
|
|
15
15
|
let n;
|
|
16
16
|
for (; !(n = await r.read()).done; )
|
|
17
17
|
t(n.value);
|
|
18
18
|
}
|
|
19
|
-
function
|
|
19
|
+
function ie(o) {
|
|
20
20
|
let t, r, n, s = !1;
|
|
21
21
|
return function(c) {
|
|
22
|
-
t === void 0 ? (t = c, r = 0, n = -1) : t =
|
|
22
|
+
t === void 0 ? (t = c, r = 0, n = -1) : t = ce(t, c);
|
|
23
23
|
const u = t.length;
|
|
24
24
|
let a = 0;
|
|
25
25
|
for (; r < u; ) {
|
|
@@ -43,7 +43,7 @@ function se(o) {
|
|
|
43
43
|
a === u ? t = void 0 : a !== 0 && (t = t.subarray(a), r -= a);
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
|
-
function
|
|
46
|
+
function ue(o, t, r) {
|
|
47
47
|
let n = U();
|
|
48
48
|
const s = new TextDecoder();
|
|
49
49
|
return function(c, u) {
|
|
@@ -63,14 +63,14 @@ function ae(o, t, r) {
|
|
|
63
63
|
o(n.id = m);
|
|
64
64
|
break;
|
|
65
65
|
case "retry":
|
|
66
|
-
const
|
|
67
|
-
isNaN(
|
|
66
|
+
const g = parseInt(m, 10);
|
|
67
|
+
isNaN(g) || t(n.retry = g);
|
|
68
68
|
break;
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
};
|
|
72
72
|
}
|
|
73
|
-
function
|
|
73
|
+
function ce(o, t) {
|
|
74
74
|
const r = new Uint8Array(o.length + t.length);
|
|
75
75
|
return r.set(o), r.set(t, o.length), r;
|
|
76
76
|
}
|
|
@@ -82,7 +82,7 @@ function U() {
|
|
|
82
82
|
retry: void 0
|
|
83
83
|
};
|
|
84
84
|
}
|
|
85
|
-
var
|
|
85
|
+
var le = function(o, t) {
|
|
86
86
|
var r = {};
|
|
87
87
|
for (var n in o) Object.prototype.hasOwnProperty.call(o, n) && t.indexOf(n) < 0 && (r[n] = o[n]);
|
|
88
88
|
if (o != null && typeof Object.getOwnPropertySymbols == "function")
|
|
@@ -90,80 +90,82 @@ var ue = function(o, t) {
|
|
|
90
90
|
t.indexOf(n[s]) < 0 && Object.prototype.propertyIsEnumerable.call(o, n[s]) && (r[n[s]] = o[n[s]]);
|
|
91
91
|
return r;
|
|
92
92
|
};
|
|
93
|
-
const x = "text/event-stream",
|
|
94
|
-
function
|
|
95
|
-
var { signal: r, headers: n, onopen: s, onmessage:
|
|
96
|
-
return new Promise((
|
|
93
|
+
const x = "text/event-stream", de = 1e3, z = "last-event-id";
|
|
94
|
+
function fe(o, t) {
|
|
95
|
+
var { signal: r, headers: n, onopen: s, onmessage: E, onclose: c, onerror: u, openWhenHidden: a, fetch: d } = t, m = le(t, ["signal", "headers", "onopen", "onmessage", "onclose", "onerror", "openWhenHidden", "fetch"]);
|
|
96
|
+
return new Promise((g, S) => {
|
|
97
97
|
const p = Object.assign({}, n);
|
|
98
98
|
p.accept || (p.accept = x);
|
|
99
|
-
let
|
|
100
|
-
function E() {
|
|
101
|
-
b.abort(), document.hidden || R();
|
|
102
|
-
}
|
|
103
|
-
a || document.addEventListener("visibilitychange", E);
|
|
104
|
-
let F = ce, T = 0;
|
|
99
|
+
let y;
|
|
105
100
|
function C() {
|
|
106
|
-
|
|
101
|
+
y.abort(), document.hidden || R();
|
|
102
|
+
}
|
|
103
|
+
a || document.addEventListener("visibilitychange", C);
|
|
104
|
+
let F = de, v = 0;
|
|
105
|
+
function T() {
|
|
106
|
+
document.removeEventListener("visibilitychange", C), window.clearTimeout(v), y.abort();
|
|
107
107
|
}
|
|
108
108
|
r == null || r.addEventListener("abort", () => {
|
|
109
|
-
|
|
109
|
+
T(), g();
|
|
110
110
|
});
|
|
111
|
-
const L = d ?? window.fetch, P = s ??
|
|
111
|
+
const L = d ?? window.fetch, P = s ?? pe;
|
|
112
112
|
async function R() {
|
|
113
113
|
var I;
|
|
114
|
-
|
|
114
|
+
y = new AbortController();
|
|
115
115
|
try {
|
|
116
|
-
const O = await L(o, Object.assign(Object.assign({}, m), { headers: p, signal:
|
|
117
|
-
await P(O), await
|
|
116
|
+
const O = await L(o, Object.assign(Object.assign({}, m), { headers: p, signal: y.signal }));
|
|
117
|
+
await P(O), await ae(O.body, ie(ue((h) => {
|
|
118
118
|
h ? p[z] = h : delete p[z];
|
|
119
119
|
}, (h) => {
|
|
120
120
|
F = h;
|
|
121
|
-
},
|
|
121
|
+
}, E))), c == null || c(), T(), g();
|
|
122
122
|
} catch (O) {
|
|
123
|
-
if (!
|
|
123
|
+
if (!y.signal.aborted)
|
|
124
124
|
try {
|
|
125
125
|
const h = (I = u == null ? void 0 : u(O)) !== null && I !== void 0 ? I : F;
|
|
126
|
-
window.clearTimeout(
|
|
126
|
+
window.clearTimeout(v), v = window.setTimeout(R, h);
|
|
127
127
|
} catch (h) {
|
|
128
|
-
|
|
128
|
+
T(), S(h);
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
132
|
R();
|
|
133
133
|
});
|
|
134
134
|
}
|
|
135
|
-
function
|
|
135
|
+
function pe(o) {
|
|
136
136
|
const t = o.headers.get("content-type");
|
|
137
137
|
if (!(t != null && t.startsWith(x)))
|
|
138
138
|
throw new Error(`Expected content-type to be ${x}, Actual: ${t}`);
|
|
139
139
|
}
|
|
140
|
-
const B = 1, Y =
|
|
140
|
+
const B = 1, Y = ne.ECONOMY;
|
|
141
141
|
let j = new AbortController();
|
|
142
|
-
const
|
|
142
|
+
const he = 3 * 60 * 1e3, $ = (o) => {
|
|
143
143
|
if (!o.origin || !o.destination)
|
|
144
144
|
throw new Error("Origin and destination are required.");
|
|
145
145
|
if (!o.departureDate)
|
|
146
146
|
throw new Error("Departure date is required.");
|
|
147
147
|
if (o.flightType === J.ROUND_TRIP && !o.returnDate)
|
|
148
148
|
throw new Error("Return date is required for round-trip flights.");
|
|
149
|
-
},
|
|
150
|
-
const { token: o, config: t } =
|
|
149
|
+
}, _e = () => {
|
|
150
|
+
const { token: o, config: t } = X(), [r, n] = M(""), [s, E] = M([]), [c, u] = M(!1), a = ee(null), {
|
|
151
151
|
inboundResults: d,
|
|
152
152
|
outboundResults: m,
|
|
153
|
-
setInboundResults:
|
|
153
|
+
setInboundResults: g,
|
|
154
154
|
setOutboundResults: S,
|
|
155
155
|
partialOfferRequestId: p,
|
|
156
|
-
setPartialOfferRequestId:
|
|
157
|
-
|
|
156
|
+
setPartialOfferRequestId: y,
|
|
157
|
+
cabinClass: C,
|
|
158
|
+
setCabinClass: F
|
|
159
|
+
} = te(), v = ({
|
|
158
160
|
data: e,
|
|
159
161
|
inbound: f
|
|
160
162
|
}) => {
|
|
161
|
-
const l =
|
|
162
|
-
return (f ?
|
|
163
|
+
const l = re(e);
|
|
164
|
+
return (f ? g : S)(oe(l)), l;
|
|
163
165
|
}, {
|
|
164
|
-
mutate:
|
|
165
|
-
status:
|
|
166
|
-
error:
|
|
166
|
+
mutate: T,
|
|
167
|
+
status: L,
|
|
168
|
+
error: P
|
|
167
169
|
} = N({
|
|
168
170
|
mutationFn: async (e) => {
|
|
169
171
|
$(e);
|
|
@@ -204,7 +206,7 @@ const fe = 3 * 60 * 1e3, $ = (o) => {
|
|
|
204
206
|
console.log("oh lol, it didn't work");
|
|
205
207
|
return;
|
|
206
208
|
}
|
|
207
|
-
|
|
209
|
+
v({ data: l }), i && y(i);
|
|
208
210
|
},
|
|
209
211
|
onError: (e) => {
|
|
210
212
|
console.error("Error in outbound flight search:", e);
|
|
@@ -213,21 +215,22 @@ const fe = 3 * 60 * 1e3, $ = (o) => {
|
|
|
213
215
|
_.invalidateQueries({ queryKey: [q.SEARCH_LIMIT] });
|
|
214
216
|
}
|
|
215
217
|
}), {
|
|
216
|
-
mutate:
|
|
217
|
-
status:
|
|
218
|
-
error:
|
|
218
|
+
mutate: R,
|
|
219
|
+
status: I,
|
|
220
|
+
error: O
|
|
219
221
|
} = N({
|
|
220
222
|
mutationFn: async (e) => {
|
|
221
223
|
if (!p)
|
|
222
224
|
throw new Error("No partialOfferRequestId found for inbound search.");
|
|
223
225
|
return n(e), await D.roundTripInboundSearch({
|
|
224
226
|
outboundOfferId: e,
|
|
225
|
-
outboundOfferRequestId: p
|
|
227
|
+
outboundOfferRequestId: p,
|
|
228
|
+
cabinClass: C
|
|
226
229
|
});
|
|
227
230
|
},
|
|
228
231
|
onSuccess: (e) => {
|
|
229
232
|
const { success: f, data: l } = e;
|
|
230
|
-
f &&
|
|
233
|
+
f && v({
|
|
231
234
|
data: l.offers,
|
|
232
235
|
inbound: !0
|
|
233
236
|
});
|
|
@@ -239,9 +242,9 @@ const fe = 3 * 60 * 1e3, $ = (o) => {
|
|
|
239
242
|
_.invalidateQueries({ queryKey: [q.SEARCH_LIMIT] });
|
|
240
243
|
}
|
|
241
244
|
}), {
|
|
242
|
-
mutate:
|
|
243
|
-
status:
|
|
244
|
-
error:
|
|
245
|
+
mutate: h,
|
|
246
|
+
status: V,
|
|
247
|
+
error: G
|
|
245
248
|
} = N({
|
|
246
249
|
mutationFn: async (e) => {
|
|
247
250
|
if (!p)
|
|
@@ -249,14 +252,15 @@ const fe = 3 * 60 * 1e3, $ = (o) => {
|
|
|
249
252
|
return await D.getRoundTripFares({
|
|
250
253
|
outboundOfferId: r,
|
|
251
254
|
outboundOfferRequestId: p,
|
|
252
|
-
inboundOfferId: e
|
|
255
|
+
inboundOfferId: e,
|
|
256
|
+
cabinClass: C
|
|
253
257
|
});
|
|
254
258
|
},
|
|
255
259
|
onSuccess: (e) => {
|
|
256
260
|
const { success: f, data: l } = e;
|
|
257
261
|
if (!f) return;
|
|
258
262
|
const i = l.offers;
|
|
259
|
-
|
|
263
|
+
E(W(i));
|
|
260
264
|
},
|
|
261
265
|
onError: (e) => {
|
|
262
266
|
console.error("Error in round-trip fare search:", e);
|
|
@@ -267,7 +271,7 @@ const fe = 3 * 60 * 1e3, $ = (o) => {
|
|
|
267
271
|
}), K = async (e) => {
|
|
268
272
|
var Q;
|
|
269
273
|
u(!0);
|
|
270
|
-
const f = e.paymentType === k.CASH_AND_MILES ? ['"cash"', '"points"'] : ['"points"'], l =
|
|
274
|
+
const f = e.paymentType === k.CASH_AND_MILES ? ['"cash"', '"points"'] : ['"points"'], l = se({
|
|
271
275
|
originCode: e.origin,
|
|
272
276
|
destinationCode: e.destination,
|
|
273
277
|
departureDate: e.departureDate,
|
|
@@ -278,7 +282,7 @@ const fe = 3 * 60 * 1e3, $ = (o) => {
|
|
|
278
282
|
let i = [], H = 0;
|
|
279
283
|
j = new AbortController(), a.current = setTimeout(() => {
|
|
280
284
|
w();
|
|
281
|
-
}, (((Q = t == null ? void 0 : t.flightsConfig) == null ? void 0 : Q.streamTimeoutTotalSeconds) ??
|
|
285
|
+
}, (((Q = t == null ? void 0 : t.flightsConfig) == null ? void 0 : Q.streamTimeoutTotalSeconds) ?? he) * 1e3), fe(Z() + l, {
|
|
282
286
|
headers: {
|
|
283
287
|
"Content-Type": "application/json",
|
|
284
288
|
Authorization: o ?? "",
|
|
@@ -288,16 +292,16 @@ const fe = 3 * 60 * 1e3, $ = (o) => {
|
|
|
288
292
|
signal: j.signal,
|
|
289
293
|
onmessage(A) {
|
|
290
294
|
try {
|
|
291
|
-
const
|
|
292
|
-
if (
|
|
295
|
+
const b = W(JSON.parse(A.data));
|
|
296
|
+
if (b.success === !1)
|
|
293
297
|
return;
|
|
294
|
-
if (
|
|
298
|
+
if (b.close === !0) {
|
|
295
299
|
w();
|
|
296
300
|
return;
|
|
297
301
|
}
|
|
298
|
-
|
|
299
|
-
} catch (
|
|
300
|
-
console.error("Error parsing message:",
|
|
302
|
+
b.status === 200 && b.flights && b.flights.length > 0 && (H = 0, i = [...i, ...b.flights], v({ data: i })), b.ping && (H++, H >= t.flightsConfig.streamTimeoutPingCount && w());
|
|
303
|
+
} catch (b) {
|
|
304
|
+
console.error("Error parsing message:", b), w();
|
|
301
305
|
}
|
|
302
306
|
},
|
|
303
307
|
onerror(A) {
|
|
@@ -317,16 +321,16 @@ const fe = 3 * 60 * 1e3, $ = (o) => {
|
|
|
317
321
|
* @type {boolean}
|
|
318
322
|
* @default false
|
|
319
323
|
*/
|
|
320
|
-
loading:
|
|
324
|
+
loading: L === "pending" || I === "pending" || c,
|
|
321
325
|
/**
|
|
322
326
|
* Loading status for fares
|
|
323
327
|
* @type {boolean}
|
|
324
328
|
* @default false
|
|
325
329
|
*/
|
|
326
|
-
loadingFares:
|
|
327
|
-
outboundError:
|
|
328
|
-
inboundError:
|
|
329
|
-
roundTripFaresError:
|
|
330
|
+
loadingFares: V === "pending",
|
|
331
|
+
outboundError: P,
|
|
332
|
+
inboundError: O,
|
|
333
|
+
roundTripFaresError: G,
|
|
330
334
|
// Results
|
|
331
335
|
outboundResults: m,
|
|
332
336
|
inboundResults: d,
|
|
@@ -344,7 +348,7 @@ const fe = 3 * 60 * 1e3, $ = (o) => {
|
|
|
344
348
|
K(e);
|
|
345
349
|
break;
|
|
346
350
|
case k.CASH:
|
|
347
|
-
|
|
351
|
+
T(e);
|
|
348
352
|
break;
|
|
349
353
|
case k.MILES:
|
|
350
354
|
K(e);
|
|
@@ -357,14 +361,14 @@ const fe = 3 * 60 * 1e3, $ = (o) => {
|
|
|
357
361
|
*
|
|
358
362
|
* @param {string} outboundOfferId - The ID of the outbound offer
|
|
359
363
|
*/
|
|
360
|
-
searchInboundFlights:
|
|
364
|
+
searchInboundFlights: R,
|
|
361
365
|
/**
|
|
362
366
|
* Used to get round-trip fares after selecting both outbound and inbound flights
|
|
363
367
|
* @type {function}
|
|
364
368
|
*
|
|
365
369
|
* @param {string} inboundOfferId - The ID of the inbound offer
|
|
366
370
|
*/
|
|
367
|
-
getRoundTripFares:
|
|
371
|
+
getRoundTripFares: h,
|
|
368
372
|
/**
|
|
369
373
|
* Resets the flight search state, clearing all results and selections
|
|
370
374
|
* @type {function}
|
|
@@ -372,10 +376,10 @@ const fe = 3 * 60 * 1e3, $ = (o) => {
|
|
|
372
376
|
* @returns {void}
|
|
373
377
|
*/
|
|
374
378
|
reset: () => {
|
|
375
|
-
w(), S([]),
|
|
379
|
+
w(), S([]), g([]), E([]), y(""), n(""), F("");
|
|
376
380
|
}
|
|
377
381
|
};
|
|
378
382
|
};
|
|
379
383
|
export {
|
|
380
|
-
|
|
384
|
+
_e as useFlightSearch
|
|
381
385
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TServiceResponse } from '@type-op/shared';
|
|
2
|
-
import { IOneWayCashOnlyFlightSearchArgs, IRoundCashOnlyFlightSearchArgs, IRoundTripFareSearchArgs, IRoundTripInboundSearchArgs } from './FlightsService.types';
|
|
3
|
-
import { IFlightOffer } from '../../hooks/useFlightSearch/useFlightSearch.types';
|
|
4
2
|
import { IAirport } from '../../hooks/useAirportSearch/useAirportSearch.types';
|
|
3
|
+
import { IFlightOffer } from '../../hooks/useFlightSearch/useFlightSearch.types';
|
|
4
|
+
import { IOneWayCashOnlyFlightSearchArgs, IRoundCashOnlyFlightSearchArgs, IRoundTripFareSearchArgs, IRoundTripInboundSearchArgs } from './FlightsService.types';
|
|
5
5
|
declare class _FlightService {
|
|
6
6
|
getAirports: (searchTerm: string) => Promise<IAirport[]>;
|
|
7
7
|
cashOnlySearch: (args: IOneWayCashOnlyFlightSearchArgs) => Promise<TServiceResponse<IFlightOffer[]>>;
|
|
@@ -201,6 +201,7 @@ export interface IOwnerResponse {
|
|
|
201
201
|
export interface IRoundTripInboundSearchArgs {
|
|
202
202
|
outboundOfferRequestId: string;
|
|
203
203
|
outboundOfferId: string;
|
|
204
|
+
cabinClass: string;
|
|
204
205
|
}
|
|
205
206
|
export interface IRoundTripFareSearchArgs extends IRoundTripInboundSearchArgs {
|
|
206
207
|
inboundOfferId: string;
|
|
@@ -6,6 +6,8 @@ interface IFlightStore {
|
|
|
6
6
|
setInboundResults: (inboundResults: IFlightResult[]) => void;
|
|
7
7
|
partialOfferRequestId: string;
|
|
8
8
|
setPartialOfferRequestId: (partialOfferRequestId: string) => void;
|
|
9
|
+
cabinClass: string;
|
|
10
|
+
setCabinClass: (cabinClass: string) => void;
|
|
9
11
|
}
|
|
10
12
|
declare const useFlightStore: import('zustand').UseBoundStore<import('zustand').StoreApi<IFlightStore>>;
|
|
11
13
|
export default useFlightStore;
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
var m = Object.defineProperty;
|
|
2
|
-
var
|
|
3
|
-
var o = (c, s,
|
|
2
|
+
var _ = (c, s, a) => s in c ? m(c, s, { enumerable: !0, configurable: !0, writable: !0, value: a }) : c[s] = a;
|
|
3
|
+
var o = (c, s, a) => _(c, typeof s != "symbol" ? s + "" : s, a);
|
|
4
|
+
import { clientInstance as d } from "@odynn/awayz-core";
|
|
4
5
|
import "../../moment-BGjjqtLQ.js";
|
|
5
6
|
import "../../arrayExtensions-DFLvtO8l.js";
|
|
6
7
|
import { c as f } from "../../objectUtils-CyIaVmog.js";
|
|
7
8
|
import "react";
|
|
8
|
-
import { EFlightEndpoint as
|
|
9
|
-
|
|
10
|
-
class _ {
|
|
9
|
+
import { EFlightEndpoint as i } from "../../constants/endpoints.js";
|
|
10
|
+
class r {
|
|
11
11
|
constructor() {
|
|
12
12
|
o(this, "getAirports", async (s) => {
|
|
13
13
|
try {
|
|
14
|
-
const { data:
|
|
15
|
-
`${
|
|
14
|
+
const { data: a } = await d.get(
|
|
15
|
+
`${i.GET_AIRPORTS}?search_term=${s}`
|
|
16
16
|
);
|
|
17
|
-
return
|
|
17
|
+
return a.data.map((e) => {
|
|
18
18
|
var u;
|
|
19
19
|
return {
|
|
20
20
|
city: {
|
|
@@ -41,36 +41,36 @@ class _ {
|
|
|
41
41
|
}
|
|
42
42
|
});
|
|
43
43
|
o(this, "cashOnlySearch", async (s) => {
|
|
44
|
-
var
|
|
44
|
+
var a, n, e, u;
|
|
45
45
|
try {
|
|
46
|
-
const { data:
|
|
47
|
-
|
|
46
|
+
const { data: t } = await d.post(
|
|
47
|
+
i.CASH_FLIGHT_SEARCH,
|
|
48
48
|
s
|
|
49
49
|
);
|
|
50
|
-
return
|
|
50
|
+
return t.success ? {
|
|
51
51
|
success: !0,
|
|
52
52
|
data: f(
|
|
53
|
-
|
|
53
|
+
t.data.offers
|
|
54
54
|
)
|
|
55
55
|
} : {
|
|
56
56
|
success: !1,
|
|
57
|
-
message:
|
|
57
|
+
message: t.message
|
|
58
58
|
};
|
|
59
|
-
} catch (
|
|
60
|
-
return console.error(JSON.stringify(
|
|
59
|
+
} catch (t) {
|
|
60
|
+
return console.error(JSON.stringify(t)), t.message === "canceled" ? {
|
|
61
61
|
success: !1,
|
|
62
|
-
message: ((n = (
|
|
62
|
+
message: ((n = (a = t == null ? void 0 : t.response) == null ? void 0 : a.data) == null ? void 0 : n.message) || (t == null ? void 0 : t.message)
|
|
63
63
|
} : {
|
|
64
64
|
success: !1,
|
|
65
|
-
message: ((u = (e =
|
|
65
|
+
message: ((u = (e = t == null ? void 0 : t.response) == null ? void 0 : e.data) == null ? void 0 : u.message) || (t == null ? void 0 : t.message)
|
|
66
66
|
};
|
|
67
67
|
}
|
|
68
68
|
});
|
|
69
69
|
o(this, "roundTripOutboundSearch", async (s) => {
|
|
70
|
-
var
|
|
70
|
+
var a, n;
|
|
71
71
|
try {
|
|
72
|
-
const { data: e } = await
|
|
73
|
-
|
|
72
|
+
const { data: e } = await d.post(
|
|
73
|
+
i.CASH_OUTBOUND_SEARCH,
|
|
74
74
|
{ ...s, to: s.return_date, from: s.departure_date }
|
|
75
75
|
);
|
|
76
76
|
if (!e.success) throw e;
|
|
@@ -81,19 +81,20 @@ class _ {
|
|
|
81
81
|
} catch (e) {
|
|
82
82
|
return {
|
|
83
83
|
success: !1,
|
|
84
|
-
message: ((n = (
|
|
84
|
+
message: ((n = (a = e == null ? void 0 : e.response) == null ? void 0 : a.data) == null ? void 0 : n.message) || (e == null ? void 0 : e.message)
|
|
85
85
|
};
|
|
86
86
|
}
|
|
87
87
|
});
|
|
88
88
|
o(this, "roundTripInboundSearch", async (s) => {
|
|
89
|
-
var
|
|
89
|
+
var a, n;
|
|
90
90
|
try {
|
|
91
|
-
const { data: e } = await
|
|
92
|
-
|
|
91
|
+
const { data: e } = await d.get(
|
|
92
|
+
i.CASH_INBOUND_SEARCH,
|
|
93
93
|
{
|
|
94
94
|
params: {
|
|
95
95
|
outbound_offer_id: s.outboundOfferId,
|
|
96
|
-
outbound_offer_request_id: s.outboundOfferRequestId
|
|
96
|
+
outbound_offer_request_id: s.outboundOfferRequestId,
|
|
97
|
+
cabin_class: s.cabinClass
|
|
97
98
|
}
|
|
98
99
|
}
|
|
99
100
|
);
|
|
@@ -102,20 +103,21 @@ class _ {
|
|
|
102
103
|
} catch (e) {
|
|
103
104
|
return {
|
|
104
105
|
success: !1,
|
|
105
|
-
message: ((n = (
|
|
106
|
+
message: ((n = (a = e == null ? void 0 : e.response) == null ? void 0 : a.data) == null ? void 0 : n.message) || (e == null ? void 0 : e.message)
|
|
106
107
|
};
|
|
107
108
|
}
|
|
108
109
|
});
|
|
109
110
|
o(this, "getRoundTripFares", async (s) => {
|
|
110
|
-
var
|
|
111
|
+
var a, n;
|
|
111
112
|
try {
|
|
112
|
-
const { data: e } = await
|
|
113
|
-
|
|
113
|
+
const { data: e } = await d.get(
|
|
114
|
+
i.ROUND_TRIP_FARES,
|
|
114
115
|
{
|
|
115
116
|
params: {
|
|
116
117
|
outbound_offer_id: s.outboundOfferId,
|
|
117
118
|
outbound_offer_request_id: s.outboundOfferRequestId,
|
|
118
|
-
inbound_offer_id: s.inboundOfferId
|
|
119
|
+
inbound_offer_id: s.inboundOfferId,
|
|
120
|
+
cabin_class: s.cabinClass
|
|
119
121
|
}
|
|
120
122
|
}
|
|
121
123
|
);
|
|
@@ -124,13 +126,13 @@ class _ {
|
|
|
124
126
|
} catch (e) {
|
|
125
127
|
return console.error(JSON.stringify(e)), {
|
|
126
128
|
success: !1,
|
|
127
|
-
message: ((n = (
|
|
129
|
+
message: ((n = (a = e == null ? void 0 : e.response) == null ? void 0 : a.data) == null ? void 0 : n.message) || (e == null ? void 0 : e.message)
|
|
128
130
|
};
|
|
129
131
|
}
|
|
130
132
|
});
|
|
131
133
|
}
|
|
132
134
|
}
|
|
133
|
-
const R = new
|
|
135
|
+
const R = new r();
|
|
134
136
|
export {
|
|
135
137
|
R as FlightService
|
|
136
138
|
};
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import
|
|
1
|
+
import r from "react";
|
|
2
2
|
const l = (e) => {
|
|
3
3
|
let t;
|
|
4
|
-
const s = /* @__PURE__ */ new Set(), u = (n,
|
|
4
|
+
const s = /* @__PURE__ */ new Set(), u = (n, a) => {
|
|
5
5
|
const o = typeof n == "function" ? n(t) : n;
|
|
6
6
|
if (!Object.is(o, t)) {
|
|
7
7
|
const d = t;
|
|
8
|
-
t =
|
|
8
|
+
t = a ?? (typeof o != "object" || o === null) ? o : Object.assign({}, t, o), s.forEach((f) => f(t, d));
|
|
9
9
|
}
|
|
10
10
|
}, c = () => t, i = { setState: u, getState: c, getInitialState: () => S, subscribe: (n) => (s.add(n), () => s.delete(n)) }, S = t = e(u, c, i);
|
|
11
11
|
return i;
|
|
12
12
|
}, g = (e) => e ? l(e) : l, I = (e) => e;
|
|
13
13
|
function R(e, t = I) {
|
|
14
|
-
const s =
|
|
14
|
+
const s = r.useSyncExternalStore(
|
|
15
15
|
e.subscribe,
|
|
16
16
|
() => t(e.getState()),
|
|
17
17
|
() => t(e.getInitialState())
|
|
18
18
|
);
|
|
19
|
-
return
|
|
19
|
+
return r.useDebugValue(s), s;
|
|
20
20
|
}
|
|
21
21
|
const b = (e) => {
|
|
22
22
|
const t = g(e), s = (u) => R(t, u);
|
|
@@ -27,7 +27,9 @@ const b = (e) => {
|
|
|
27
27
|
setOutboundResults: (t) => e({ outboundResults: t }),
|
|
28
28
|
setInboundResults: (t) => e({ inboundResults: t }),
|
|
29
29
|
partialOfferRequestId: "",
|
|
30
|
-
setPartialOfferRequestId: (t) => e({ partialOfferRequestId: t })
|
|
30
|
+
setPartialOfferRequestId: (t) => e({ partialOfferRequestId: t }),
|
|
31
|
+
cabinClass: "",
|
|
32
|
+
setCabinClass: (t) => e({ cabinClass: t })
|
|
31
33
|
}));
|
|
32
34
|
export {
|
|
33
35
|
y as default
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@odynn/awayz-flights",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
70
|
"@microsoft/fetch-event-source": "^2.0.1",
|
|
71
|
-
"@odynn/awayz-core": "
|
|
71
|
+
"@odynn/awayz-core": ">= 0.6.0",
|
|
72
72
|
"@tanstack/react-query": "^5.67.1",
|
|
73
73
|
"country-code-lookup": "^0.1.3"
|
|
74
74
|
}
|