@odynn/awayz-flights 0.1.13 → 0.1.14

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.
@@ -2,6 +2,7 @@ var f = Object.defineProperty;
2
2
  var m = (a, s, t) => s in a ? f(a, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[s] = t;
3
3
  var u = (a, s, t) => m(a, typeof s != "symbol" ? s + "" : s, t);
4
4
  import "./arrayExtensions-DWKenJCh.js";
5
+ import "react";
5
6
  import { EFlightEndpoint as d } from "./constants/endpoints.js";
6
7
  import { clientInstance as i } from "@odynn/awayz-auth";
7
8
  function _(a) {
@@ -134,8 +135,8 @@ class l {
134
135
  });
135
136
  }
136
137
  }
137
- const O = new l();
138
+ const R = new l();
138
139
  export {
139
- O as F,
140
+ R as F,
140
141
  r as c
141
142
  };
@@ -1,17 +1,29 @@
1
- import { useQuery as t } from "@tanstack/react-query";
2
- import { F as a } from "../../FlightsService-DDCgYDB9.js";
3
- const n = (r) => {
4
- const { data: o, isLoading: e, error: i } = t({
5
- queryKey: ["airports", r],
6
- queryFn: () => a.getAirports(r),
7
- enabled: !!r && r.length > 2
1
+ import { useQuery as i } from "@tanstack/react-query";
2
+ import { F as n } from "../../FlightsService-DddArKLm.js";
3
+ import "../../arrayExtensions-DWKenJCh.js";
4
+ import { useState as a, useEffect as m } from "react";
5
+ const c = 500, u = (t, e = c) => {
6
+ const [r, o] = a(t);
7
+ return m(() => {
8
+ const s = setTimeout(() => {
9
+ o(t);
10
+ }, e);
11
+ return () => {
12
+ clearTimeout(s);
13
+ };
14
+ }, [t, e]), r;
15
+ }, E = (t) => {
16
+ const e = u(t), { data: r, isLoading: o, error: s } = i({
17
+ queryKey: ["airports", e],
18
+ queryFn: () => n.getAirports(t),
19
+ enabled: !!t && t.length > 2
8
20
  });
9
21
  return {
10
- airports: o ?? [],
11
- loading: e,
12
- error: i
22
+ airports: r ?? [],
23
+ loading: o,
24
+ error: s
13
25
  };
14
26
  };
15
27
  export {
16
- n as useAirportSearch
28
+ E as useAirportSearch
17
29
  };
@@ -1,7 +1,7 @@
1
1
  import { useState as n } from "react";
2
2
  import { useMutation as u } from "@tanstack/react-query";
3
3
  import { ECabinClass as C, EFlightType as d } from "../../types/enums.js";
4
- import { F as a, c as D } from "../../FlightsService-DDCgYDB9.js";
4
+ import { F as a, c as D } from "../../FlightsService-DddArKLm.js";
5
5
  import { parseFlightDetails as _, groupFlightResults as N } from "../../utils/flightUtils.js";
6
6
  import "../../arrayExtensions-DWKenJCh.js";
7
7
  const P = 1, v = C.ECONOMY, A = (t) => {
@@ -108,7 +108,9 @@ const P = 1, v = C.ECONOMY, A = (t) => {
108
108
  },
109
109
  onSuccess: (r) => {
110
110
  const { success: s, data: o } = r;
111
- s && m(D(o.offers));
111
+ if (!s) return;
112
+ const e = o.offers;
113
+ m(D(e));
112
114
  },
113
115
  onError: (r) => {
114
116
  console.error("Error in round-trip fare search:", r);
@@ -1,7 +1,8 @@
1
1
  import "../../arrayExtensions-DWKenJCh.js";
2
- import { F as p } from "../../FlightsService-DDCgYDB9.js";
2
+ import { F as e } from "../../FlightsService-DddArKLm.js";
3
+ import "react";
3
4
  import "../../constants/endpoints.js";
4
5
  import "@odynn/awayz-auth";
5
6
  export {
6
- p as FlightService
7
+ e as FlightService
7
8
  };
@@ -1,5 +1,6 @@
1
1
  import { h as F } from "../arrayExtensions-DWKenJCh.js";
2
2
  import { c as z } from "../dateUtils-DeNLG5hw.js";
3
+ import "react";
3
4
  const L = (r) => r == null ? void 0 : r.map((e) => {
4
5
  var c, a, t, o, i, s, l, h, g, I, T, f, M, w, b, d, p, n, y, C, N, m, u, D;
5
6
  return {
@@ -45,7 +46,7 @@ const L = (r) => r == null ? void 0 : r.map((e) => {
45
46
  duration: e.slices[0].duration
46
47
  })
47
48
  };
48
- }), O = (r, e) => {
49
+ }), P = (r, e) => {
49
50
  if (!(e != null && e.length))
50
51
  return L(r);
51
52
  const c = [...e];
@@ -103,7 +104,7 @@ const L = (r) => r == null ? void 0 : r.map((e) => {
103
104
  }, A = (r) => {
104
105
  const e = r.operatingCarrierFlightNumber ? r.operatingCarrier : r.marketingCarrier, c = r.operatingCarrierFlightNumber ?? r.marketingCarrierFlightNumber;
105
106
  return e.iataCode + " " + c;
106
- }, P = ({
107
+ }, $ = ({
107
108
  originCode: r,
108
109
  destinationCode: e,
109
110
  departureDate: c,
@@ -113,7 +114,7 @@ const L = (r) => r == null ? void 0 : r.map((e) => {
113
114
  }) => {
114
115
  let i = "/flights/search/one-way/points-cash?";
115
116
  return i += `origin=${r}`, i += `&destination=${e}`, i += `&departure_date=${c}`, i += `&cabin_class=${a}`, i += `&adults=${t}`, i += `&cash_or_points=[${o}]`, i;
116
- }, $ = (r) => {
117
+ }, Z = (r) => {
117
118
  const e = r.reduce((a, t) => {
118
119
  const o = t.awayzGroupId;
119
120
  return a[o] || (a[o] = []), a[o].push(t), a;
@@ -184,9 +185,9 @@ const L = (r) => r == null ? void 0 : r.map((e) => {
184
185
  );
185
186
  };
186
187
  export {
187
- P as buildFlightSearchQuery,
188
+ $ as buildFlightSearchQuery,
188
189
  A as getFlightNumber,
189
- $ as groupFlightResults,
190
+ Z as groupFlightResults,
190
191
  L as mapFlightDetailsToResults,
191
- O as parseFlightDetails
192
+ P as parseFlightDetails
192
193
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@odynn/awayz-flights",
3
- "version": "0.1.13",
3
+ "version": "0.1.14",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"
@@ -67,7 +67,7 @@
67
67
  },
68
68
  "dependencies": {
69
69
  "@microsoft/fetch-event-source": "^2.0.1",
70
- "@odynn/awayz-auth": "^0.1.8",
70
+ "@odynn/awayz-auth": "^0.1.17",
71
71
  "@tanstack/react-query": "^5.67.1"
72
72
  }
73
73
  }