@travelswitchhq/flight-search-react 1.0.5 → 1.0.7

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/index.cjs CHANGED
@@ -1323,6 +1323,16 @@ padding-inline-start: 25px;
1323
1323
 
1324
1324
  // src/Flight.tsx
1325
1325
  var import_jsx_runtime = require("react/jsx-runtime");
1326
+ var API_URLS = {
1327
+ dev: {
1328
+ airport: "https://adminapi-go.dev.futuretravelplatform.com/api",
1329
+ airline: "https://adminapi.dev.futuretravelplatform.com/api"
1330
+ },
1331
+ prod: {
1332
+ airport: "https://adminapi-go.futuretravelplatform.com/api",
1333
+ airline: "https://adminapi.futuretravelplatform.com/api"
1334
+ }
1335
+ };
1326
1336
  var normalizeDomainName = (domainName) => {
1327
1337
  const trimmed = domainName.trim();
1328
1338
  if (!trimmed) return "";
@@ -1446,8 +1456,10 @@ function FlightSearchWidget({
1446
1456
  const primaryLightColor = theme?.primaryLight ?? "#f3e2ff";
1447
1457
  const fontName = config?.fontName;
1448
1458
  const redirectionDomain = config?.redirectionDomain;
1449
- const airportSearchApiBaseUrl = "https://adminapi-go.dev.futuretravelplatform.com/api";
1450
- const airlineSearchApiBaseUrl = "https://adminapi.dev.futuretravelplatform.com/api";
1459
+ const env = config?.env ?? "dev";
1460
+ const urls = API_URLS[env];
1461
+ const airportSearchApiBaseUrl = urls.airport;
1462
+ const airlineSearchApiBaseUrl = urls.airline;
1451
1463
  const langCode = "en";
1452
1464
  const [airlineQuery, setAirlineQuery] = (0, import_react.useState)("");
1453
1465
  const [airlineSuggestions, setAirlineSuggestions] = (0, import_react.useState)([]);
@@ -1498,6 +1510,8 @@ function FlightSearchWidget({
1498
1510
  const roomsGuestsMenuRef = (0, import_react.useRef)(null);
1499
1511
  const dateRangeCalendarRef = (0, import_react.useRef)(null);
1500
1512
  const mobileDateRangeCalendarRef = (0, import_react.useRef)(null);
1513
+ const oneWayDesktopCalendarRef = (0, import_react.useRef)(null);
1514
+ const oneWayMobileCalendarRef = (0, import_react.useRef)(null);
1501
1515
  const segmentCalendarRefs = (0, import_react.useRef)({});
1502
1516
  const getMaxSegments = () => {
1503
1517
  if (tripType === "custom-search") return 3;
@@ -2046,7 +2060,7 @@ function FlightSearchWidget({
2046
2060
  console.log("Query String:", queryString);
2047
2061
  if (redirectionDomain) {
2048
2062
  const url = `${redirectionDomain}/flight/listing?${queryString}`;
2049
- window.open(url, "_blank");
2063
+ window.location.href = url;
2050
2064
  }
2051
2065
  };
2052
2066
  const handleSubmit = (e) => {
@@ -2383,17 +2397,19 @@ function FlightSearchWidget({
2383
2397
  {
2384
2398
  className: "sw-form-field sw-pos-rel sw-com-cal",
2385
2399
  style: { cursor: "pointer" },
2386
- onClick: () => segmentCalendarRefs.current[0]?.show?.(),
2400
+ onClick: () => {
2401
+ oneWayDesktopCalendarRef.current?.show?.();
2402
+ oneWayMobileCalendarRef.current?.show?.();
2403
+ },
2387
2404
  children: [
2388
2405
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", { children: "Departure" }),
2389
2406
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: formatDisplayDate(segments[0]?.departureDate) }),
2390
2407
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
2391
2408
  import_calendar.Calendar,
2392
2409
  {
2410
+ id: "oneWayDepartureDesktop",
2393
2411
  numberOfMonths: 2,
2394
- ref: (el) => {
2395
- segmentCalendarRefs.current[0] = el;
2396
- },
2412
+ ref: oneWayDesktopCalendarRef,
2397
2413
  value: segments[0]?.departureDate ?? null,
2398
2414
  onChange: (e) => {
2399
2415
  const raw = e.value;
@@ -2413,10 +2429,9 @@ function FlightSearchWidget({
2413
2429
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
2414
2430
  import_calendar.Calendar,
2415
2431
  {
2432
+ id: "oneWayDepartureMobile",
2416
2433
  numberOfMonths: 10,
2417
- ref: (el) => {
2418
- segmentCalendarRefs.current[0] = el;
2419
- },
2434
+ ref: oneWayMobileCalendarRef,
2420
2435
  value: segments[0]?.departureDate ?? null,
2421
2436
  onChange: (e) => {
2422
2437
  const raw = e.value;
@@ -2434,7 +2449,7 @@ function FlightSearchWidget({
2434
2449
  headerTemplate: () => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "mobileHead MobileShow", children: [
2435
2450
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", { type: "button", onClick: (e) => {
2436
2451
  e.stopPropagation();
2437
- segmentCalendarRefs.current[0]?.hide?.();
2452
+ oneWayMobileCalendarRef.current?.hide?.();
2438
2453
  }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", { width: "20px", height: "20px", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
2439
2454
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M19 5L5 19", stroke: "black", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }),
2440
2455
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M5 5L19 19", stroke: "black", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" })
@@ -2448,7 +2463,7 @@ function FlightSearchWidget({
2448
2463
  className: "sw-confirm-btn",
2449
2464
  onClick: (e) => {
2450
2465
  e.stopPropagation();
2451
- segmentCalendarRefs.current[0]?.hide?.();
2466
+ oneWayMobileCalendarRef.current?.hide?.();
2452
2467
  },
2453
2468
  children: "Confirm"
2454
2469
  }