@travelswitchhq/flight-search-react 1.0.7 → 1.0.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.
package/dist/index.cjs CHANGED
@@ -195,6 +195,18 @@ var flightSearchWidgetStyles = `
195
195
  min-width: 0;
196
196
  overflow: visible;
197
197
  }
198
+ .sw-form-field.sw-is-invalid {
199
+ box-shadow: inset 0 0 0 1px var(--sw-error);
200
+ }
201
+ .sw-form-field.sw-is-invalid label {
202
+ color: var(--sw-error);
203
+ }
204
+ .sw-custom-dropdown.sw-has-error .sw-custom-dropdown-trigger {
205
+ color: var(--sw-error);
206
+ }
207
+ .sw-custom-dropdown.sw-has-error .sw-custom-dropdown-trigger::placeholder {
208
+ color: var(--sw-error) !important;
209
+ }
198
210
  .sw-form-field label {
199
211
  display: block;
200
212
  width: 100%;
@@ -1617,8 +1629,12 @@ function FlightSearchWidget({
1617
1629
  }
1618
1630
  return updated;
1619
1631
  });
1632
+ setValidationErrors((prev) => ({
1633
+ ...prev,
1634
+ [segmentIndex]: { ...prev[segmentIndex] ?? {}, [dropdownType]: false }
1635
+ }));
1620
1636
  closeAirportDropdown(dropdownType, segmentIndex);
1621
- }, [closeAirportDropdown]);
1637
+ }, [closeAirportDropdown, tripType]);
1622
1638
  const updateSelectedIndex = (0, import_react.useCallback)((segmentIndex, dropdownType, newIndex) => {
1623
1639
  setPredictiveSearchList((prev) => {
1624
1640
  const state = prev[segmentIndex] ?? { fromAirport: [], toAirport: [], selectedFromIndex: -1, selectedToIndex: -1 };
@@ -2039,6 +2055,14 @@ function FlightSearchWidget({
2039
2055
  queryStringObj[`umrah`] = isUmrahFareOption();
2040
2056
  return queryStringObj;
2041
2057
  };
2058
+ const getNormalizedRedirectionBase = () => {
2059
+ const raw = (redirectionDomain ?? "").trim();
2060
+ if (!raw) return null;
2061
+ if (raw.startsWith("http://") || raw.startsWith("https://")) {
2062
+ return raw.replace(/\/+$/, "");
2063
+ }
2064
+ return `https://${raw.replace(/\/+$/, "")}`;
2065
+ };
2042
2066
  const handleSearch = () => {
2043
2067
  const queryStringObj = createQueryString();
2044
2068
  console.log("Query String Object:", queryStringObj);
@@ -2058,8 +2082,9 @@ function FlightSearchWidget({
2058
2082
  }
2059
2083
  const queryString = queryParams.toString();
2060
2084
  console.log("Query String:", queryString);
2061
- if (redirectionDomain) {
2062
- const url = `${redirectionDomain}/flight/listing?${queryString}`;
2085
+ const base = getNormalizedRedirectionBase();
2086
+ if (base) {
2087
+ const url = `${base}/flight/listing?${queryString}`;
2063
2088
  window.location.href = url;
2064
2089
  }
2065
2090
  };