@odynn/awayz-flights 0.9.11 → 0.10.0

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.
@@ -0,0 +1,205 @@
1
+ import { jsxs as t, jsx as o, Fragment as d } from "react/jsx-runtime";
2
+ import { useAwayzContext as M, useFeatureFlags as $, useWallet as x, EBookingPaymentMethod as j, convertCashToClientPoints as q, CashValue as u, EToolTipPosition as y, EInvalidAmountDisplayOption as f, EAmountsDisplayFeature as W, ClientPointsValue as b } from "@odynn/awayz-core";
3
+ import { useQuery as Z } from "@tanstack/react-query";
4
+ import "./moment-BGjjqtLQ.js";
5
+ import "./arrayExtensions-Ce8YopTP.js";
6
+ import G, { useState as k, useEffect as K } from "react";
7
+ import { G as Q } from "./iconBase-DSKTHwal.js";
8
+ import { h as J, i as O, j as X, k as V } from "./index-9LVJi5JO.js";
9
+ import { EPaymentType as D } from "./enums/EPaymentType.js";
10
+ import { EBaggage as I } from "./hooks/useFlightSearch/useFlightSearch.types.js";
11
+ import { getAirlineProgram as oo, formatCabinClass as ro } from "./utils/flightUtils.js";
12
+ import './assets/_styles4.css';/* empty css */
13
+ const U = (e, l, n = l + "s") => e === 1 ? l : n, to = (e) => e ? e.toLowerCase().replace(/-/g, " ").split(" ").map((l) => l.charAt(0).toUpperCase() + l.slice(1)).join(" ") : "";
14
+ function no(e, l = !0) {
15
+ if ((!e || isNaN(e) || e < 0) && l) return "N/A";
16
+ let n = e == null ? void 0 : e.toString().split(".")[0];
17
+ return n == null ? void 0 : n.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
18
+ }
19
+ const eo = "USD";
20
+ function F(e) {
21
+ return Q({ 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 ho = ({
24
+ type: e,
25
+ title: l,
26
+ cashValue: n,
27
+ milesValue: w,
28
+ cashFee: p,
29
+ setSelected: B,
30
+ conditions: c,
31
+ slices: s,
32
+ baggages: N,
33
+ program: h
34
+ }) => {
35
+ var L, T, v;
36
+ const { config: A } = M(), { featureFlags: g } = $(), [m, H] = k(!1), [E, Y] = k(), { pointsAsCash: P } = x(), i = c == null ? void 0 : c.refundBeforeDeparture, a = c == null ? void 0 : c.changeBeforeDeparture, S = (i != null && i.allowed ? 1 : 0) + (a != null && a.allowed ? 1 : 0) + (((T = (L = s == null ? void 0 : s[0]) == null ? void 0 : L.segments) == null ? void 0 : T.length) || 0), { data: _ } = Z({
37
+ queryKey: ["airlineProgram", h],
38
+ queryFn: () => oo(h),
39
+ enabled: !!h
40
+ });
41
+ return K(() => {
42
+ g.bookingPaymentMethodFeature === j.FULL_VCC_PARTIAL_DISABLED && q({
43
+ cashAmount: (n == null ? void 0 : n.amount) ?? 0,
44
+ currency: (n == null ? void 0 : n.currency) ?? "",
45
+ pointsAsCash: P
46
+ }).then((r) => {
47
+ P.availablePoints < r && Y("Insufficient points balance.");
48
+ });
49
+ }, [n, g]), /* @__PURE__ */ t(
50
+ "div",
51
+ {
52
+ className: "flight-booking-option",
53
+ onClick: (r) => r.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: to(l) })
58
+ ] }),
59
+ e === D.CASH && /* @__PURE__ */ t("div", { className: "fare-comparison-content", children: [
60
+ N == null ? void 0 : N.map((r, C) => /* @__PURE__ */ t(G.Fragment, { children: [
61
+ r.type === I.CHECKED && /* @__PURE__ */ t("div", { className: "fare-option checked", children: [
62
+ /* @__PURE__ */ o("p", { children: "Checked bags:" }),
63
+ /* @__PURE__ */ o("p", { children: r.quantity })
64
+ ] }),
65
+ r.type === I.CARRY_ON && /* @__PURE__ */ t("div", { className: "fare-option", children: [
66
+ /* @__PURE__ */ o("p", { children: "Carry-on bags:" }),
67
+ /* @__PURE__ */ o("p", { children: r.quantity })
68
+ ] }),
69
+ r.type === null && /* @__PURE__ */ t("div", { className: "fare-option", children: [
70
+ /* @__PURE__ */ o(J, {}),
71
+ /* @__PURE__ */ o("p", { children: "N/A" })
72
+ ] })
73
+ ] }, C)),
74
+ /* @__PURE__ */ t("div", { className: "fare-option refundable", children: [
75
+ "Refundable:",
76
+ " ",
77
+ i != null && i.allowed ? /* @__PURE__ */ o(O, { className: "yes" }) : /* @__PURE__ */ o(F, { className: "no" })
78
+ ] }),
79
+ /* @__PURE__ */ t("div", { className: "fare-option changeable", children: [
80
+ "Changeable:",
81
+ " ",
82
+ a != null && a.allowed ? /* @__PURE__ */ o(O, { className: "yes" }) : /* @__PURE__ */ o(F, { className: "no" })
83
+ ] }),
84
+ /* @__PURE__ */ t(
85
+ "div",
86
+ {
87
+ className: "fare-option show-more-toggle",
88
+ onClick: (r) => {
89
+ r.stopPropagation(), H(!m);
90
+ },
91
+ children: [
92
+ /* @__PURE__ */ o("p", { children: m ? `Hide ${U(S, "option")}` : `+${S} ${U(S, "option")}` }),
93
+ /* @__PURE__ */ o("p", { children: m ? /* @__PURE__ */ o(X, {}) : /* @__PURE__ */ o(V, {}) })
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
+ u,
103
+ {
104
+ amount: i.penaltyAmount || 0,
105
+ currency: i.penaltyCurrency || "",
106
+ zeroDisplayOption: f.DISPLAY_AS_ZERO_WITH_CURRENCY,
107
+ position: y.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
+ u,
116
+ {
117
+ amount: a.penaltyAmount || 0,
118
+ currency: a.penaltyCurrency || "",
119
+ zeroDisplayOption: f.DISPLAY_AS_ZERO_WITH_CURRENCY,
120
+ position: y.LEFT
121
+ }
122
+ )
123
+ ] }),
124
+ (v = s == null ? void 0 : s[0].segments) == null ? void 0 : v.map((r) => {
125
+ var C, R;
126
+ return /* @__PURE__ */ t(
127
+ "div",
128
+ {
129
+ className: "fare-option checked",
130
+ children: [
131
+ /* @__PURE__ */ t("p", { children: [
132
+ r.origin.iataCode,
133
+ " - ",
134
+ r.destination.iataCode,
135
+ ":"
136
+ ] }),
137
+ /* @__PURE__ */ t("div", { children: [
138
+ /* @__PURE__ */ o(
139
+ "img",
140
+ {
141
+ src: r.operatingCarrier.logo ?? r.operatingCarrier.logoSymbolUrl ?? ((C = r.marketingCarrier) == null ? void 0 : C.logo) ?? ((R = r.marketingCarrier) == null ? void 0 : R.logoSymbolUrl),
142
+ onError: (z) => z.currentTarget.src = (A == null ? void 0 : A.logoFallbackImageUrl) ?? ""
143
+ }
144
+ ),
145
+ /* @__PURE__ */ o("p", { children: ro(r.passengers[0].cabinClass) })
146
+ ] })
147
+ ]
148
+ },
149
+ `${r.origin.iataCode}-${r.destination.iataCode}`
150
+ );
151
+ })
152
+ ] })
153
+ ] }),
154
+ /* @__PURE__ */ o(
155
+ "button",
156
+ {
157
+ onClick: (r) => {
158
+ r.stopPropagation(), B();
159
+ },
160
+ disabled: !!E,
161
+ children: e === D.CASH && n ? /* @__PURE__ */ o(d, { children: E ? /* @__PURE__ */ o("p", { children: E }) : /* @__PURE__ */ t(d, { children: [
162
+ /* @__PURE__ */ o(
163
+ u,
164
+ {
165
+ amount: n.amount,
166
+ currency: n.currency,
167
+ position: y.LEFT,
168
+ zeroDisplayOption: f.DISPLAY_AS_ZERO_WITH_CURRENCY,
169
+ decimalPlaces: 2
170
+ }
171
+ ),
172
+ g.amountsDisplayFeature === W.CASH_AND_CLIENT_POINTS && /* @__PURE__ */ t(d, { children: [
173
+ " / ",
174
+ /* @__PURE__ */ o(
175
+ b,
176
+ {
177
+ currency: n.currency,
178
+ cashAmount: n.amount
179
+ }
180
+ )
181
+ ] })
182
+ ] }) }) : /* @__PURE__ */ t(d, { children: [
183
+ `${no(w)} miles + `,
184
+ /* @__PURE__ */ o(
185
+ u,
186
+ {
187
+ amount: (p == null ? void 0 : p.amount) || 0,
188
+ currency: (p == null ? void 0 : p.currency) || eo,
189
+ position: y.LEFT,
190
+ customDisplay: "No fee",
191
+ zeroDisplayOption: f.CUSTOM
192
+ }
193
+ )
194
+ ] })
195
+ }
196
+ )
197
+ ]
198
+ }
199
+ );
200
+ };
201
+ export {
202
+ ho as B,
203
+ no as c,
204
+ U as p
205
+ };
@@ -0,0 +1,102 @@
1
+ import { jsx as t, jsxs as a, Fragment as u } from "react/jsx-runtime";
2
+ import { useAwayzContext as g } from "@odynn/awayz-core";
3
+ import { g as Y, b as S } from "./dateUtils-Cb9VQiIL.js";
4
+ import { l as C } from "./arrayExtensions-Ce8YopTP.js";
5
+ import "react";
6
+ import { h as e } from "./moment-BGjjqtLQ.js";
7
+ import { useTranslation as E } from "react-i18next";
8
+ import { a as N } from "./index-Kopwbl-x.js";
9
+ import './assets/FlightItinerary.css';const W = (r) => {
10
+ var o;
11
+ if (!r) return "";
12
+ try {
13
+ return (o = C.byIso(r)) == null ? void 0 : o.country;
14
+ } catch (d) {
15
+ return console.error(d), "";
16
+ }
17
+ };
18
+ var l = /* @__PURE__ */ ((r) => (r.ISO = "dates:iso", r.DISPLAY_SHORT = "dates:displayShort", r.DISPLAY_MEDIUM = "dates:displayMedium", r.DISPLAY_LONG = "dates:displayLong", r.DISPLAY_FULL = "dates:displayFull", r.DISPLAY_SHORT_WITH_YEAR = "dates:displayShortWithYear", r.DISPLAY_MEDIUM_WITH_YEAR = "dates:displayMediumWithYear", r.DISPLAY_LONG_WITH_YEAR = "dates:displayLongWithYear", r.DISPLAY_FULL_WITH_YEAR = "dates:displayFullWithYear", r.DATE_TIME_SHORT = "dates:dateTimeShort", r.DATE_TIME_MEDIUM = "dates:dateTimeMedium", r.DATE_TIME_LONG = "dates:dateTimeLong", r.DATE_TIME_FULL = "dates:dateTimeFull", r.DATE_TIME_SHORT_WITH_YEAR = "dates:dateTimeShortWithYear", r.DATE_TIME_MEDIUM_WITH_YEAR = "dates:dateTimeMediumWithYear", r.DATE_TIME_LONG_WITH_YEAR = "dates:dateTimeLongWithYear", r.DATE_TIME_FULL_WITH_YEAR = "dates:dateTimeFullWithYear", r.TIME_ONLY = "dates:timeOnly", r.TIME_WITH_SECONDS = "dates:timeWithSeconds", r))(l || {});
19
+ const y = ({ itinerary: r }) => {
20
+ const { t: o } = E(), { config: d } = g();
21
+ return /* @__PURE__ */ t("div", { className: "flight-itinerary", children: r.map((i, I) => {
22
+ var s, c, _, T, h, m, p;
23
+ const n = r[I + 1], A = i.operatingCarrier.logoSymbolUrl ?? i.operatingCarrier.logo ?? ((s = i.marketingCarrier) == null ? void 0 : s.logoSymbolUrl) ?? ((c = i.marketingCarrier) == null ? void 0 : c.logo), L = ((T = (_ = i.passengers[0]) == null ? void 0 : _.cabin) == null ? void 0 : T.marketingName.toLowerCase()) ?? ((h = i.passengers[0]) == null ? void 0 : h.cabinClass);
24
+ return /* @__PURE__ */ a(u, { children: [
25
+ /* @__PURE__ */ a("div", { className: "flight-itinerary-segment", children: [
26
+ /* @__PURE__ */ a("div", { children: [
27
+ /* @__PURE__ */ a("div", { className: "segment-details", children: [
28
+ /* @__PURE__ */ t(
29
+ "img",
30
+ {
31
+ src: A,
32
+ alt: i.operatingCarrier.name,
33
+ onError: (M) => M.currentTarget.src = (d == null ? void 0 : d.logoFallbackImageUrl) ?? ""
34
+ }
35
+ ),
36
+ /* @__PURE__ */ a("div", { children: [
37
+ /* @__PURE__ */ a("p", { children: [
38
+ e(i.departingAt).format(
39
+ o(l.DATE_TIME_MEDIUM)
40
+ ),
41
+ " ",
42
+ "-",
43
+ " ",
44
+ e(i.arrivingAt).format(
45
+ o(l.DATE_TIME_MEDIUM)
46
+ )
47
+ ] }),
48
+ /* @__PURE__ */ a("div", { className: "flight-locations", children: [
49
+ /* @__PURE__ */ t("p", { children: i.origin.iataCode }),
50
+ /* @__PURE__ */ t(N, {}),
51
+ /* @__PURE__ */ t("p", { children: i.destination.iataCode })
52
+ ] })
53
+ ] })
54
+ ] }),
55
+ /* @__PURE__ */ a("div", { className: "segment-times", children: [
56
+ /* @__PURE__ */ t("p", { children: Y(i.duration) }),
57
+ /* @__PURE__ */ t("p", { className: "cabin-class", children: L })
58
+ ] })
59
+ ] }),
60
+ /* @__PURE__ */ a("div", { className: "operated-by", children: [
61
+ /* @__PURE__ */ a("p", { children: [
62
+ "Operated by ",
63
+ i.operatingCarrier.name
64
+ ] }),
65
+ /* @__PURE__ */ a("p", { children: [
66
+ "Aircraft ",
67
+ (m = i.aircraft) == null ? void 0 : m.name,
68
+ " •",
69
+ " ",
70
+ i.operatingCarrier.iataCode,
71
+ " ",
72
+ i.operatingCarrierFlightNumber ?? i.marketingCarrierFlightNumber
73
+ ] })
74
+ ] })
75
+ ] }, i.id),
76
+ n && /* @__PURE__ */ a("div", { className: "flight-itinerary-layover", children: [
77
+ /* @__PURE__ */ a("p", { children: [
78
+ "Layover in",
79
+ " ",
80
+ ((p = i.destination.city) == null ? void 0 : p.name) ?? i.destination.cityName,
81
+ ", ",
82
+ W(i.destination.iataCountryCode),
83
+ " ",
84
+ "(",
85
+ i.destination.iataCode,
86
+ ")"
87
+ ] }),
88
+ /* @__PURE__ */ t("p", { children: S(
89
+ e(n.departingAt).diff(
90
+ i.arrivingAt,
91
+ "minutes"
92
+ )
93
+ ) })
94
+ ] })
95
+ ] });
96
+ }) });
97
+ };
98
+ export {
99
+ l as E,
100
+ y as F,
101
+ W as g
102
+ };
@@ -1,7 +1,7 @@
1
1
  import "react/jsx-runtime";
2
2
  import "@odynn/awayz-core";
3
3
  import "@tanstack/react-query";
4
- import { B as x } from "../../BookingOption-V-FzaupW.js";
4
+ import { B as x } from "../../BookingOption-D566Ie2y.js";
5
5
  import "../../moment-BGjjqtLQ.js";
6
6
  import "../../arrayExtensions-Ce8YopTP.js";
7
7
  import "react";
@@ -1,11 +1,12 @@
1
1
  import "react/jsx-runtime";
2
+ import "@odynn/awayz-core";
2
3
  import "../../dateUtils-Cb9VQiIL.js";
3
- import { F as f } from "../../FlightItinerary-C4KPpVcF.js";
4
+ import { F as g } from "../../FlightItinerary-BvAVMr_3.js";
4
5
  import "../../arrayExtensions-Ce8YopTP.js";
5
6
  import "react";
6
7
  import "../../moment-BGjjqtLQ.js";
7
8
  import "react-i18next";
8
9
  import "../../index-Kopwbl-x.js";
9
10
  export {
10
- f as FlightItinerary
11
+ g as FlightItinerary
11
12
  };
@@ -6,7 +6,7 @@ import "@tanstack/react-query";
6
6
  import "@odynn/awayz-core";
7
7
  import "../../moment-BGjjqtLQ.js";
8
8
  import "../../arrayExtensions-Ce8YopTP.js";
9
- import { F as c } from "../../FlightItinerary-C4KPpVcF.js";
9
+ import { F as c } from "../../FlightItinerary-BvAVMr_3.js";
10
10
  import "react-i18next";
11
11
  import "../../utils/flightUtils.js";
12
12
  import '../../assets/_styles.css';import '../../assets/_styles2.css';import '../../assets/_styles3.css';import '../../assets/_styles4.css';import '../../assets/FlightItineraryDropdown.css';/* empty css */