@odynn/awayz-flights 0.9.6 → 0.9.8

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.
Files changed (44) hide show
  1. package/dist/BookingOption-V-FzaupW.js +196 -0
  2. package/dist/FlightItinerary-C4KPpVcF.js +94 -0
  3. package/dist/_commonjsHelpers-MdHo5S7N.js +26 -0
  4. package/dist/{arrayExtensions-DFLvtO8l.js → arrayExtensions-Ce8YopTP.js} +92 -113
  5. package/dist/assets/FlightItinerary.css +1 -1
  6. package/dist/assets/FlightItineraryDropdown.css +1 -1
  7. package/dist/assets/_styles.css +1 -1
  8. package/dist/assets/_styles2.css +1 -1
  9. package/dist/assets/_styles3.css +1 -0
  10. package/dist/assets/_styles4.css +1 -0
  11. package/dist/components/BookingOption/BookingOption.js +5 -6
  12. package/dist/components/Dialog/Dialog.js +20542 -0
  13. package/dist/components/FlightItinerary/FlightItinerary.js +5 -6
  14. package/dist/components/FlightItineraryDropdown/FlightItineraryDropdown.js +23 -29
  15. package/dist/components/FlightResult/FlightResult.js +318 -284
  16. package/dist/components/HorizontalScroller/HorizontalScroller.js +4 -4
  17. package/dist/components/MiniFlightItinerary/MiniFlightItinerary.js +90 -7
  18. package/dist/components/index.js +5 -5
  19. package/dist/constants/endpoints.js +1 -1
  20. package/dist/{dateUtils-CWDSSY2R.js → dateUtils-Cb9VQiIL.js} +1 -1
  21. package/dist/enums-tLvxh02p.js +4 -0
  22. package/dist/hooks/index.js +3 -3
  23. package/dist/hooks/useAirportSearch/useAirportSearch.js +1 -1
  24. package/dist/hooks/useFlightSearch/useFlightSearch.js +422 -12
  25. package/dist/{index-nOT-DH7g.js → index-9LVJi5JO.js} +12 -8
  26. package/dist/index-Kopwbl-x.js +19 -0
  27. package/dist/lib/components/Dialog/Dialog.d.ts +9 -0
  28. package/dist/lib/components/FlightItinerary/FlightItinerary.d.ts +1 -6
  29. package/dist/lib/components/FlightItineraryDropdown/FlightItineraryDropdown.d.ts +2 -4
  30. package/dist/lib/components/FlightResult/FlightResult.d.ts +1 -1
  31. package/dist/lib/constants/endpoints.d.ts +2 -1
  32. package/dist/lib/hooks/useFlightSearch/useFlightSearch.types.d.ts +3 -2
  33. package/dist/lib/services/flights/FlightsService.d.ts +1 -0
  34. package/dist/main.js +36 -35
  35. package/dist/services/flights/FlightsService.js +38 -29
  36. package/dist/services/wallet/WalletService.js +1 -1
  37. package/dist/utils/flightUtils.js +27 -28
  38. package/package.json +2 -1
  39. package/dist/BookingOption-Bf4d2RKS.js +0 -192
  40. package/dist/FlightItinerary-C2Jp2a9c.js +0 -262
  41. package/dist/MiniFlightItinerary-BEdrqoGh.js +0 -105
  42. package/dist/index-Gj4bRuCQ.js +0 -15
  43. package/dist/index-nI16-czT.js +0 -4
  44. package/dist/useFlightSearch-C0DEmnCL.js +0 -412
@@ -0,0 +1,196 @@
1
+ import { jsxs as t, jsx as o, Fragment as d } from "react/jsx-runtime";
2
+ import { useFeatureFlags as H, useWallet as Y, EBookingPaymentMethod as M, convertCashToClientPoints as $, CashValue as C, EToolTipPosition as u, EInvalidAmountDisplayOption as y, EAmountsDisplayFeature as z, ClientPointsValue as j } from "@odynn/awayz-core";
3
+ import { useQuery as q } from "@tanstack/react-query";
4
+ import "./moment-BGjjqtLQ.js";
5
+ import "./arrayExtensions-Ce8YopTP.js";
6
+ import x, { useState as v, useEffect as W } from "react";
7
+ import { G as Z } from "./iconBase-DSKTHwal.js";
8
+ import { h as G, i as R, j as K, k as Q } from "./index-9LVJi5JO.js";
9
+ import { EPaymentType as D } from "./enums/EPaymentType.js";
10
+ import { EBaggage as T } from "./hooks/useFlightSearch/useFlightSearch.types.js";
11
+ import { getAirlineProgram as b, formatCabinClass as J } from "./utils/flightUtils.js";
12
+ import './assets/_styles4.css';/* empty css */
13
+ const O = (e, l, r = l + "s") => e === 1 ? l : r, X = (e) => e ? e.toLowerCase().replace(/-/g, " ").split(" ").map((l) => l.charAt(0).toUpperCase() + l.slice(1)).join(" ") : "";
14
+ function V(e, l = !0) {
15
+ if ((!e || isNaN(e) || e < 0) && l) return "N/A";
16
+ let r = e == null ? void 0 : e.toString().split(".")[0];
17
+ return r == null ? void 0 : r.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
18
+ }
19
+ const oo = "USD";
20
+ function k(e) {
21
+ return Z({ attr: { viewBox: "0 0 352 512" }, child: [{ tag: "path", attr: { d: "M242.72 256l100.07-100.07c12.28-12.28 12.28-32.19 0-44.48l-22.24-22.24c-12.28-12.28-32.19-12.28-44.48 0L176 189.28 75.93 89.21c-12.28-12.28-32.19-12.28-44.48 0L9.21 111.45c-12.28 12.28-12.28 32.19 0 44.48L109.28 256 9.21 356.07c-12.28 12.28-12.28 32.19 0 44.48l22.24 22.24c12.28 12.28 32.2 12.28 44.48 0L176 322.72l100.07 100.07c12.28 12.28 32.2 12.28 44.48 0l22.24-22.24c12.28-12.28 12.28-32.19 0-44.48L242.72 256z" }, child: [] }] })(e);
22
+ }
23
+ const uo = ({
24
+ type: e,
25
+ title: l,
26
+ cashValue: r,
27
+ milesValue: I,
28
+ cashFee: p,
29
+ setSelected: F,
30
+ conditions: c,
31
+ slices: s,
32
+ baggages: f,
33
+ program: N
34
+ }) => {
35
+ var L, S, g;
36
+ const { featureFlags: h } = H(), [m, w] = v(!1), [A, B] = v(), { pointsAsCash: P } = Y(), i = c == null ? void 0 : c.refundBeforeDeparture, a = c == null ? void 0 : c.changeBeforeDeparture, E = (i != null && i.allowed ? 1 : 0) + (a != null && a.allowed ? 1 : 0) + (((S = (L = s == null ? void 0 : s[0]) == null ? void 0 : L.segments) == null ? void 0 : S.length) || 0), { data: _ } = q({
37
+ queryKey: ["airlineProgram", N],
38
+ queryFn: () => b(N),
39
+ enabled: !!N
40
+ });
41
+ return W(() => {
42
+ h.bookingPaymentMethodFeature === M.FULL_VCC_PARTIAL_DISABLED && $({
43
+ cashAmount: (r == null ? void 0 : r.amount) ?? 0,
44
+ currency: (r == null ? void 0 : r.currency) ?? "",
45
+ pointsAsCash: P
46
+ }).then((n) => {
47
+ P.availablePoints < n && B("Insufficient points balance.");
48
+ });
49
+ }, [r, h]), /* @__PURE__ */ t(
50
+ "div",
51
+ {
52
+ className: "flight-booking-option",
53
+ onClick: (n) => n.stopPropagation(),
54
+ children: [
55
+ /* @__PURE__ */ t("div", { className: "rate-details", children: [
56
+ e === D.POINTS && /* @__PURE__ */ o("img", { src: _ == null ? void 0 : _.programLogo }),
57
+ /* @__PURE__ */ o("p", { className: "fare-brand-name", children: X(l) })
58
+ ] }),
59
+ e === D.CASH && /* @__PURE__ */ t("div", { className: "fare-comparison-content", children: [
60
+ f == null ? void 0 : f.map((n, U) => /* @__PURE__ */ t(x.Fragment, { children: [
61
+ n.type === T.CHECKED && /* @__PURE__ */ t("div", { className: "fare-option checked", children: [
62
+ /* @__PURE__ */ o("p", { children: "Checked bags:" }),
63
+ /* @__PURE__ */ o("p", { children: n.quantity })
64
+ ] }),
65
+ n.type === T.CARRY_ON && /* @__PURE__ */ t("div", { className: "fare-option", children: [
66
+ /* @__PURE__ */ o("p", { children: "Carry-on bags:" }),
67
+ /* @__PURE__ */ o("p", { children: n.quantity })
68
+ ] }),
69
+ n.type === null && /* @__PURE__ */ t("div", { className: "fare-option", children: [
70
+ /* @__PURE__ */ o(G, {}),
71
+ /* @__PURE__ */ o("p", { children: "N/A" })
72
+ ] })
73
+ ] }, U)),
74
+ /* @__PURE__ */ t("div", { className: "fare-option refundable", children: [
75
+ "Refundable:",
76
+ " ",
77
+ i != null && i.allowed ? /* @__PURE__ */ o(R, { className: "yes" }) : /* @__PURE__ */ o(k, { className: "no" })
78
+ ] }),
79
+ /* @__PURE__ */ t("div", { className: "fare-option changeable", children: [
80
+ "Changeable:",
81
+ " ",
82
+ a != null && a.allowed ? /* @__PURE__ */ o(R, { className: "yes" }) : /* @__PURE__ */ o(k, { className: "no" })
83
+ ] }),
84
+ /* @__PURE__ */ t(
85
+ "div",
86
+ {
87
+ className: "fare-option show-more-toggle",
88
+ onClick: (n) => {
89
+ n.stopPropagation(), w(!m);
90
+ },
91
+ children: [
92
+ /* @__PURE__ */ o("p", { children: m ? `Hide ${O(E, "option")}` : `+${E} ${O(E, "option")}` }),
93
+ /* @__PURE__ */ o("p", { children: m ? /* @__PURE__ */ o(K, {}) : /* @__PURE__ */ o(Q, {}) })
94
+ ]
95
+ }
96
+ ),
97
+ m && /* @__PURE__ */ t(d, { children: [
98
+ (i == null ? void 0 : i.allowed) && /* @__PURE__ */ t("div", { className: "fare-option", children: [
99
+ "Refundable Penalty:",
100
+ " ",
101
+ /* @__PURE__ */ o(
102
+ C,
103
+ {
104
+ amount: i.penaltyAmount || 0,
105
+ currency: i.penaltyCurrency || "",
106
+ zeroDisplayOption: y.DISPLAY_AS_ZERO_WITH_CURRENCY,
107
+ position: u.LEFT
108
+ }
109
+ )
110
+ ] }),
111
+ (a == null ? void 0 : a.allowed) && /* @__PURE__ */ t("div", { className: "fare-option", children: [
112
+ "Changeable Penalty:",
113
+ " ",
114
+ /* @__PURE__ */ o(
115
+ C,
116
+ {
117
+ amount: a.penaltyAmount || 0,
118
+ currency: a.penaltyCurrency || "",
119
+ zeroDisplayOption: y.DISPLAY_AS_ZERO_WITH_CURRENCY,
120
+ position: u.LEFT
121
+ }
122
+ )
123
+ ] }),
124
+ (g = s == null ? void 0 : s[0].segments) == null ? void 0 : g.map((n) => /* @__PURE__ */ t(
125
+ "div",
126
+ {
127
+ className: "fare-option checked",
128
+ children: [
129
+ /* @__PURE__ */ t("p", { children: [
130
+ n.origin.iataCode,
131
+ " - ",
132
+ n.destination.iataCode,
133
+ ":"
134
+ ] }),
135
+ /* @__PURE__ */ t("div", { children: [
136
+ /* @__PURE__ */ o("img", { src: n.operatingCarrier.logo }),
137
+ /* @__PURE__ */ o("p", { children: J(n.passengers[0].cabinClass) })
138
+ ] })
139
+ ]
140
+ },
141
+ `${n.origin.iataCode}-${n.destination.iataCode}`
142
+ ))
143
+ ] })
144
+ ] }),
145
+ /* @__PURE__ */ o(
146
+ "button",
147
+ {
148
+ onClick: (n) => {
149
+ n.stopPropagation(), F();
150
+ },
151
+ disabled: !!A,
152
+ children: e === D.CASH && r ? /* @__PURE__ */ o(d, { children: A ? /* @__PURE__ */ o("p", { children: A }) : /* @__PURE__ */ t(d, { children: [
153
+ /* @__PURE__ */ o(
154
+ C,
155
+ {
156
+ amount: r.amount,
157
+ currency: r.currency,
158
+ position: u.LEFT,
159
+ zeroDisplayOption: y.DISPLAY_AS_ZERO_WITH_CURRENCY,
160
+ decimalPlaces: 2
161
+ }
162
+ ),
163
+ h.amountsDisplayFeature === z.CASH_AND_CLIENT_POINTS && /* @__PURE__ */ t(d, { children: [
164
+ " / ",
165
+ /* @__PURE__ */ o(
166
+ j,
167
+ {
168
+ currency: r.currency,
169
+ cashAmount: r.amount
170
+ }
171
+ )
172
+ ] })
173
+ ] }) }) : /* @__PURE__ */ t(d, { children: [
174
+ `${V(I)} miles + `,
175
+ /* @__PURE__ */ o(
176
+ C,
177
+ {
178
+ amount: (p == null ? void 0 : p.amount) || 0,
179
+ currency: (p == null ? void 0 : p.currency) || oo,
180
+ position: u.LEFT,
181
+ customDisplay: "No fee",
182
+ zeroDisplayOption: y.CUSTOM
183
+ }
184
+ )
185
+ ] })
186
+ }
187
+ )
188
+ ]
189
+ }
190
+ );
191
+ };
192
+ export {
193
+ uo as B,
194
+ V as c,
195
+ O as p
196
+ };
@@ -0,0 +1,94 @@
1
+ import { jsx as t, jsxs as a, Fragment as I } from "react/jsx-runtime";
2
+ import { g as A, b as L } from "./dateUtils-Cb9VQiIL.js";
3
+ import { l as M } from "./arrayExtensions-Ce8YopTP.js";
4
+ import "react";
5
+ import { h as e } from "./moment-BGjjqtLQ.js";
6
+ import { useTranslation as u } from "react-i18next";
7
+ import { a as Y } from "./index-Kopwbl-x.js";
8
+ import './assets/FlightItinerary.css';const S = (i) => {
9
+ var d;
10
+ if (!i) return "";
11
+ try {
12
+ return (d = M.byIso(i)) == null ? void 0 : d.country;
13
+ } catch (r) {
14
+ return console.error(r), "";
15
+ }
16
+ };
17
+ var o = /* @__PURE__ */ ((i) => (i.ISO = "dates:iso", i.DISPLAY_SHORT = "dates:displayShort", i.DISPLAY_MEDIUM = "dates:displayMedium", i.DISPLAY_LONG = "dates:displayLong", i.DISPLAY_FULL = "dates:displayFull", i.DISPLAY_SHORT_WITH_YEAR = "dates:displayShortWithYear", i.DISPLAY_MEDIUM_WITH_YEAR = "dates:displayMediumWithYear", i.DISPLAY_LONG_WITH_YEAR = "dates:displayLongWithYear", i.DISPLAY_FULL_WITH_YEAR = "dates:displayFullWithYear", i.DATE_TIME_SHORT = "dates:dateTimeShort", i.DATE_TIME_MEDIUM = "dates:dateTimeMedium", i.DATE_TIME_LONG = "dates:dateTimeLong", i.DATE_TIME_FULL = "dates:dateTimeFull", i.DATE_TIME_SHORT_WITH_YEAR = "dates:dateTimeShortWithYear", i.DATE_TIME_MEDIUM_WITH_YEAR = "dates:dateTimeMediumWithYear", i.DATE_TIME_LONG_WITH_YEAR = "dates:dateTimeLongWithYear", i.DATE_TIME_FULL_WITH_YEAR = "dates:dateTimeFullWithYear", i.TIME_ONLY = "dates:timeOnly", i.TIME_WITH_SECONDS = "dates:timeWithSeconds", i))(o || {});
18
+ const F = ({ itinerary: i }) => {
19
+ const { t: d } = u();
20
+ return /* @__PURE__ */ t("div", { className: "flight-itinerary", children: i.map((r, h) => {
21
+ var l, s, c, _, T;
22
+ const n = i[h + 1], m = r.operatingCarrier.logoSymbolUrl ?? r.operatingCarrier.logo, p = ((s = (l = r.passengers[0]) == null ? void 0 : l.cabin) == null ? void 0 : s.marketingName.toLowerCase()) ?? ((c = r.passengers[0]) == null ? void 0 : c.cabinClass);
23
+ return /* @__PURE__ */ a(I, { children: [
24
+ /* @__PURE__ */ a("div", { className: "flight-itinerary-segment", children: [
25
+ /* @__PURE__ */ a("div", { children: [
26
+ /* @__PURE__ */ a("div", { className: "segment-details", children: [
27
+ /* @__PURE__ */ t("img", { src: m, alt: r.operatingCarrier.name }),
28
+ /* @__PURE__ */ a("div", { children: [
29
+ /* @__PURE__ */ a("p", { children: [
30
+ e(r.departingAt).format(
31
+ d(o.DATE_TIME_MEDIUM)
32
+ ),
33
+ " ",
34
+ "-",
35
+ " ",
36
+ e(r.arrivingAt).format(
37
+ d(o.DATE_TIME_MEDIUM)
38
+ )
39
+ ] }),
40
+ /* @__PURE__ */ a("div", { className: "flight-locations", children: [
41
+ /* @__PURE__ */ t("p", { children: r.origin.iataCode }),
42
+ /* @__PURE__ */ t(Y, {}),
43
+ /* @__PURE__ */ t("p", { children: r.destination.iataCode })
44
+ ] })
45
+ ] })
46
+ ] }),
47
+ /* @__PURE__ */ a("div", { className: "segment-times", children: [
48
+ /* @__PURE__ */ t("p", { children: A(r.duration) }),
49
+ /* @__PURE__ */ t("p", { className: "cabin-class", children: p })
50
+ ] })
51
+ ] }),
52
+ /* @__PURE__ */ a("div", { className: "operated-by", children: [
53
+ /* @__PURE__ */ a("p", { children: [
54
+ "Operated by ",
55
+ r.operatingCarrier.name
56
+ ] }),
57
+ /* @__PURE__ */ a("p", { children: [
58
+ "Aircraft ",
59
+ (_ = r.aircraft) == null ? void 0 : _.name,
60
+ " •",
61
+ " ",
62
+ r.operatingCarrier.iataCode,
63
+ " ",
64
+ r.operatingCarrierFlightNumber ?? r.marketingCarrierFlightNumber
65
+ ] })
66
+ ] })
67
+ ] }, r.id),
68
+ n && /* @__PURE__ */ a("div", { className: "flight-itinerary-layover", children: [
69
+ /* @__PURE__ */ a("p", { children: [
70
+ "Layover in",
71
+ " ",
72
+ ((T = r.destination.city) == null ? void 0 : T.name) ?? r.destination.cityName,
73
+ ", ",
74
+ S(r.destination.iataCountryCode),
75
+ " ",
76
+ "(",
77
+ r.destination.iataCode,
78
+ ")"
79
+ ] }),
80
+ /* @__PURE__ */ t("p", { children: L(
81
+ e(n.departingAt).diff(
82
+ r.arrivingAt,
83
+ "minutes"
84
+ )
85
+ ) })
86
+ ] })
87
+ ] });
88
+ }) });
89
+ };
90
+ export {
91
+ o as E,
92
+ F,
93
+ S as g
94
+ };
@@ -0,0 +1,26 @@
1
+ function n(e) {
2
+ return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
3
+ }
4
+ function c(e) {
5
+ if (Object.prototype.hasOwnProperty.call(e, "__esModule")) return e;
6
+ var o = e.default;
7
+ if (typeof o == "function") {
8
+ var t = function r() {
9
+ return this instanceof r ? Reflect.construct(o, arguments, this.constructor) : o.apply(this, arguments);
10
+ };
11
+ t.prototype = o.prototype;
12
+ } else t = {};
13
+ return Object.defineProperty(t, "__esModule", { value: !0 }), Object.keys(e).forEach(function(r) {
14
+ var u = Object.getOwnPropertyDescriptor(e, r);
15
+ Object.defineProperty(t, r, u.get ? u : {
16
+ enumerable: !0,
17
+ get: function() {
18
+ return e[r];
19
+ }
20
+ });
21
+ }), t;
22
+ }
23
+ export {
24
+ n as a,
25
+ c as g
26
+ };