@devtravelcode/widget-native 1.0.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.
- package/LICENSE +18 -0
- package/dist/App.d.ts +10 -0
- package/dist/App.js +192 -0
- package/dist/TravelHubWidget.d.ts +12 -0
- package/dist/TravelHubWidget.js +58 -0
- package/dist/components/ErrorBoundary.d.ts +18 -0
- package/dist/components/ErrorBoundary.js +63 -0
- package/dist/components/ui/Modal.d.ts +11 -0
- package/dist/components/ui/Modal.js +66 -0
- package/dist/components/ui/Skeleton.d.ts +8 -0
- package/dist/components/ui/Skeleton.js +33 -0
- package/dist/components/ui/badge.d.ts +11 -0
- package/dist/components/ui/badge.js +54 -0
- package/dist/components/ui/button.d.ts +14 -0
- package/dist/components/ui/button.js +101 -0
- package/dist/components/ui/card.d.ts +16 -0
- package/dist/components/ui/card.js +51 -0
- package/dist/components/ui/input.d.ts +8 -0
- package/dist/components/ui/input.js +61 -0
- package/dist/components/ui/label.d.ts +8 -0
- package/dist/components/ui/label.js +17 -0
- package/dist/context/WidgetContext.d.ts +29 -0
- package/dist/context/WidgetContext.js +64 -0
- package/dist/icons/CarIcon.d.ts +4 -0
- package/dist/icons/CarIcon.js +3 -0
- package/dist/icons/CloseIcon.d.ts +7 -0
- package/dist/icons/CloseIcon.js +3 -0
- package/dist/icons/FlightIcon.d.ts +4 -0
- package/dist/icons/FlightIcon.js +3 -0
- package/dist/icons/HotelIcon.d.ts +4 -0
- package/dist/icons/HotelIcon.js +3 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/lib/utils.d.ts +2 -0
- package/dist/lib/utils.js +3 -0
- package/dist/locales/widgetTranslations.d.ts +1 -0
- package/dist/locales/widgetTranslations.js +732 -0
- package/dist/modules/hooks/useAirportSearch.d.ts +21 -0
- package/dist/modules/hooks/useAirportSearch.js +48 -0
- package/dist/modules/hooks/useCarOffers.d.ts +7 -0
- package/dist/modules/hooks/useCarOffers.js +47 -0
- package/dist/modules/hooks/useCountriesByCodes.d.ts +4 -0
- package/dist/modules/hooks/useCountriesByCodes.js +60 -0
- package/dist/modules/hooks/useCountriesSearch.d.ts +11 -0
- package/dist/modules/hooks/useCountriesSearch.js +55 -0
- package/dist/modules/hooks/useDefaultHotelLocation.d.ts +7 -0
- package/dist/modules/hooks/useDefaultHotelLocation.js +44 -0
- package/dist/modules/hooks/useDetectNationality.d.ts +1 -0
- package/dist/modules/hooks/useDetectNationality.js +20 -0
- package/dist/modules/hooks/useFlightSearch.d.ts +20 -0
- package/dist/modules/hooks/useFlightSearch.js +243 -0
- package/dist/modules/hooks/useHotelDetails.d.ts +7 -0
- package/dist/modules/hooks/useHotelDetails.js +80 -0
- package/dist/modules/hooks/useHotelLocations.d.ts +5 -0
- package/dist/modules/hooks/useHotelLocations.js +42 -0
- package/dist/modules/hooks/useHotelMapData.d.ts +12 -0
- package/dist/modules/hooks/useHotelMapData.js +78 -0
- package/dist/modules/hooks/useHotelOffers.d.ts +11 -0
- package/dist/modules/hooks/useHotelOffers.js +122 -0
- package/dist/modules/hooks/useHotelSearchSSE.d.ts +18 -0
- package/dist/modules/hooks/useHotelSearchSSE.js +411 -0
- package/dist/modules/hooks/useSearchExpiration.d.ts +6 -0
- package/dist/modules/hooks/useSearchExpiration.js +35 -0
- package/dist/modules/hooks/useTranslationsHub.d.ts +5 -0
- package/dist/modules/hooks/useTranslationsHub.js +48 -0
- package/dist/modules/navbar/Navbar.d.ts +8 -0
- package/dist/modules/navbar/Navbar.js +69 -0
- package/dist/modules/search-form/AgeSelector.d.ts +9 -0
- package/dist/modules/search-form/AgeSelector.js +109 -0
- package/dist/modules/search-form/CustomSelect.d.ts +14 -0
- package/dist/modules/search-form/CustomSelect.js +94 -0
- package/dist/modules/search-form/FiltersSkeleton.d.ts +6 -0
- package/dist/modules/search-form/FiltersSkeleton.js +35 -0
- package/dist/modules/search-form/NationalityInput.d.ts +18 -0
- package/dist/modules/search-form/NationalityInput.js +172 -0
- package/dist/modules/search-form/Pagination.d.ts +8 -0
- package/dist/modules/search-form/Pagination.js +84 -0
- package/dist/modules/search-form/SearchExpiredPopup.d.ts +10 -0
- package/dist/modules/search-form/SearchExpiredPopup.js +91 -0
- package/dist/modules/search-form/SkeletonWidget.d.ts +2 -0
- package/dist/modules/search-form/SkeletonWidget.js +33 -0
- package/dist/modules/search-form/TimePicker.d.ts +9 -0
- package/dist/modules/search-form/TimePicker.js +182 -0
- package/dist/modules/search-form/cars/CarEmptyState.d.ts +6 -0
- package/dist/modules/search-form/cars/CarEmptyState.js +42 -0
- package/dist/modules/search-form/cars/CarFiltersSkeleton.d.ts +6 -0
- package/dist/modules/search-form/cars/CarFiltersSkeleton.js +35 -0
- package/dist/modules/search-form/cars/CarOffersList.d.ts +43 -0
- package/dist/modules/search-form/cars/CarOffersList.js +214 -0
- package/dist/modules/search-form/cars/CarResults.d.ts +25 -0
- package/dist/modules/search-form/cars/CarResults.js +116 -0
- package/dist/modules/search-form/cars/CarSearchForm.d.ts +19 -0
- package/dist/modules/search-form/cars/CarSearchForm.js +173 -0
- package/dist/modules/search-form/cars/CarSkeleton.d.ts +6 -0
- package/dist/modules/search-form/cars/CarSkeleton.js +46 -0
- package/dist/modules/search-form/cars/CarTopOffersSlider.d.ts +20 -0
- package/dist/modules/search-form/cars/CarTopOffersSlider.js +100 -0
- package/dist/modules/search-form/cars/car-filters/CarFilters.d.ts +8 -0
- package/dist/modules/search-form/cars/car-filters/CarFilters.js +318 -0
- package/dist/modules/search-form/cars/car-filters/FilterSection.d.ts +9 -0
- package/dist/modules/search-form/cars/car-filters/FilterSection.js +30 -0
- package/dist/modules/search-form/cars/car-filters/index.d.ts +6 -0
- package/dist/modules/search-form/cars/car-filters/index.js +3 -0
- package/dist/modules/search-form/cars/car-filters/useCarFilters.d.ts +24 -0
- package/dist/modules/search-form/cars/car-filters/useCarFilters.js +121 -0
- package/dist/modules/search-form/flight/AirlinesSelector.d.ts +8 -0
- package/dist/modules/search-form/flight/AirlinesSelector.js +235 -0
- package/dist/modules/search-form/flight/CabinClassSelector.d.ts +9 -0
- package/dist/modules/search-form/flight/CabinClassSelector.js +63 -0
- package/dist/modules/search-form/flight/DatePicker.d.ts +12 -0
- package/dist/modules/search-form/flight/DatePicker.js +536 -0
- package/dist/modules/search-form/flight/FlightSearchForm.d.ts +18 -0
- package/dist/modules/search-form/flight/FlightSearchForm.js +147 -0
- package/dist/modules/search-form/flight/LocationInput.d.ts +11 -0
- package/dist/modules/search-form/flight/LocationInput.js +294 -0
- package/dist/modules/search-form/flight/PassengersPicker.d.ts +16 -0
- package/dist/modules/search-form/flight/PassengersPicker.js +203 -0
- package/dist/modules/search-form/flight/SwitchLocationBtn.d.ts +9 -0
- package/dist/modules/search-form/flight/SwitchLocationBtn.js +48 -0
- package/dist/modules/search-form/flight/flight-filters/FiltersContent.d.ts +21 -0
- package/dist/modules/search-form/flight/flight-filters/FiltersContent.js +145 -0
- package/dist/modules/search-form/flight/flight-filters/FlightFiltersDynamic.d.ts +11 -0
- package/dist/modules/search-form/flight/flight-filters/FlightFiltersDynamic.js +213 -0
- package/dist/modules/search-form/flight/flight-filters/RangeBlock.d.ts +22 -0
- package/dist/modules/search-form/flight/flight-filters/RangeBlock.js +164 -0
- package/dist/modules/search-form/flight/flight-filters/index.d.ts +1 -0
- package/dist/modules/search-form/flight/flight-filters/index.js +1 -0
- package/dist/modules/search-form/flight/flight-results/FlightAdditionalInfo.d.ts +16 -0
- package/dist/modules/search-form/flight/flight-results/FlightAdditionalInfo.js +229 -0
- package/dist/modules/search-form/flight/flight-results/FlightBaggageToggle.d.ts +15 -0
- package/dist/modules/search-form/flight/flight-results/FlightBaggageToggle.js +110 -0
- package/dist/modules/search-form/flight/flight-results/FlightCard.d.ts +14 -0
- package/dist/modules/search-form/flight/flight-results/FlightCard.js +436 -0
- package/dist/modules/search-form/flight/flight-results/FlightInfo.d.ts +12 -0
- package/dist/modules/search-form/flight/flight-results/FlightInfo.js +48 -0
- package/dist/modules/search-form/flight/flight-results/FlightPriceBlock.d.ts +11 -0
- package/dist/modules/search-form/flight/flight-results/FlightPriceBlock.js +36 -0
- package/dist/modules/search-form/flight/flight-results/FlightResults.d.ts +22 -0
- package/dist/modules/search-form/flight/flight-results/FlightResults.js +109 -0
- package/dist/modules/search-form/flight/flight-results/FlightSegments.d.ts +40 -0
- package/dist/modules/search-form/flight/flight-results/FlightSegments.js +162 -0
- package/dist/modules/search-form/flight/flight-results/FlightsSkeleton.d.ts +6 -0
- package/dist/modules/search-form/flight/flight-results/FlightsSkeleton.js +52 -0
- package/dist/modules/search-form/flight/flight-results/ProvidersLoader.d.ts +9 -0
- package/dist/modules/search-form/flight/flight-results/ProvidersLoader.js +242 -0
- package/dist/modules/search-form/hotel/DatePicker.d.ts +1 -0
- package/dist/modules/search-form/hotel/DatePicker.js +1 -0
- package/dist/modules/search-form/hotel/GuestSelector.d.ts +13 -0
- package/dist/modules/search-form/hotel/GuestSelector.js +272 -0
- package/dist/modules/search-form/hotel/GuestSelectorMobilePopup.d.ts +2 -0
- package/dist/modules/search-form/hotel/GuestSelectorMobilePopup.js +1 -0
- package/dist/modules/search-form/hotel/HotelLocation.d.ts +17 -0
- package/dist/modules/search-form/hotel/HotelLocation.js +178 -0
- package/dist/modules/search-form/hotel/HotelLocationMobilePopup.d.ts +2 -0
- package/dist/modules/search-form/hotel/HotelLocationMobilePopup.js +1 -0
- package/dist/modules/search-form/hotel/HotelResults.d.ts +21 -0
- package/dist/modules/search-form/hotel/HotelResults.js +333 -0
- package/dist/modules/search-form/hotel/HotelSearchForm.d.ts +13 -0
- package/dist/modules/search-form/hotel/HotelSearchForm.js +130 -0
- package/dist/modules/search-form/hotel/HotelsSkeleton.d.ts +6 -0
- package/dist/modules/search-form/hotel/HotelsSkeleton.js +40 -0
- package/dist/modules/search-form/hotel/PassengersPicker.d.ts +2 -0
- package/dist/modules/search-form/hotel/PassengersPicker.js +1 -0
- package/dist/modules/search-form/hotel/components/HotelCard.d.ts +11 -0
- package/dist/modules/search-form/hotel/components/HotelCard.js +180 -0
- package/dist/modules/search-form/hotel/components/HotelEmptyState.d.ts +6 -0
- package/dist/modules/search-form/hotel/components/HotelEmptyState.js +34 -0
- package/dist/modules/search-form/hotel/components/HotelGallery.d.ts +6 -0
- package/dist/modules/search-form/hotel/components/HotelGallery.js +77 -0
- package/dist/modules/search-form/hotel/components/HotelList.d.ts +9 -0
- package/dist/modules/search-form/hotel/components/HotelList.js +12 -0
- package/dist/modules/search-form/hotel/components/HotelMap.d.ts +26 -0
- package/dist/modules/search-form/hotel/components/HotelMap.js +707 -0
- package/dist/modules/search-form/hotel/components/HotelPin.d.ts +7 -0
- package/dist/modules/search-form/hotel/components/HotelPin.js +1 -0
- package/dist/modules/search-form/hotel/hotel-filters/HotelFilters.d.ts +29 -0
- package/dist/modules/search-form/hotel/hotel-filters/HotelFilters.js +339 -0
- package/dist/modules/search-form/hotel/hotel-filters/HotelFiltersBar.d.ts +3 -0
- package/dist/modules/search-form/hotel/hotel-filters/HotelFiltersBar.js +2 -0
- package/dist/modules/search-form/hotel/hotel-filters/HotelFiltersContent.d.ts +2 -0
- package/dist/modules/search-form/hotel/hotel-filters/HotelFiltersContent.js +1 -0
- package/dist/modules/search-form/hotel/hotel-filters/HotelFiltersDynamic.d.ts +2 -0
- package/dist/modules/search-form/hotel/hotel-filters/HotelFiltersDynamic.js +1 -0
- package/dist/modules/search-form/hotel/hotel-filters/HotelFiltersMobilePopup.d.ts +2 -0
- package/dist/modules/search-form/hotel/hotel-filters/HotelFiltersMobilePopup.js +1 -0
- package/dist/modules/search-form/hotel/hotel-filters/RangeBlock.d.ts +1 -0
- package/dist/modules/search-form/hotel/hotel-filters/RangeBlock.js +1 -0
- package/dist/modules/search-form/hotel/hotel-filters/index.d.ts +1 -0
- package/dist/modules/search-form/hotel/hotel-filters/index.js +1 -0
- package/dist/modules/tabs/FlightsTab.d.ts +1 -0
- package/dist/modules/tabs/FlightsTab.js +1 -0
- package/dist/modules/tabs/HotelsTab.d.ts +1 -0
- package/dist/modules/tabs/HotelsTab.js +1 -0
- package/dist/store/index.d.ts +22 -0
- package/dist/store/index.js +19 -0
- package/dist/theme/colors.d.ts +56 -0
- package/dist/theme/colors.js +56 -0
- package/dist/theme/formStyles.d.ts +76 -0
- package/dist/theme/formStyles.js +78 -0
- package/dist/utils/applyWidgetColors.d.ts +1 -0
- package/dist/utils/applyWidgetColors.js +2 -0
- package/dist/utils/dateTime.d.ts +2 -0
- package/dist/utils/dateTime.js +23 -0
- package/dist/utils/fetchSSE.d.ts +23 -0
- package/dist/utils/fetchSSE.js +104 -0
- package/dist/utils/getToken.d.ts +3 -0
- package/dist/utils/getToken.js +12 -0
- package/package.json +64 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
type FlightAdditionalInfoProps = {
|
|
3
|
+
itineraries: any[];
|
|
4
|
+
airlines: Record<string, {
|
|
5
|
+
logo: string;
|
|
6
|
+
name: string;
|
|
7
|
+
}>;
|
|
8
|
+
includeBaggage?: boolean;
|
|
9
|
+
baggageText?: string;
|
|
10
|
+
baggageImage?: string;
|
|
11
|
+
show: boolean;
|
|
12
|
+
translations: Record<string, string>;
|
|
13
|
+
lang: string;
|
|
14
|
+
};
|
|
15
|
+
declare const FlightAdditionalInfo: React.FC<FlightAdditionalInfoProps>;
|
|
16
|
+
export default FlightAdditionalInfo;
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { View, Text, Image, StyleSheet } from "react-native";
|
|
4
|
+
import Svg, { Path, Rect } from "react-native-svg";
|
|
5
|
+
import { useWidget } from "../../../../context/WidgetContext";
|
|
6
|
+
import { formatTimeByDateTimeFormat } from "../../../../utils/dateTime";
|
|
7
|
+
import { Colors, Spacing, FontSize, BorderRadius } from "../../../../theme/colors";
|
|
8
|
+
const BaggageIncludedIcon = () => (_jsxs(Svg, { width: 20, height: 20, viewBox: "0 0 24 24", fill: "none", children: [_jsx(Rect, { width: 24, height: 24, rx: 12, fill: "#29AD56" }), _jsx(Path, { d: "M7 12L10.5 15.5L17.5 8", stroke: "white", strokeWidth: 1.8, strokeLinecap: "round", strokeLinejoin: "round" })] }));
|
|
9
|
+
const NoBaggageIcon = () => (_jsxs(Svg, { width: 20, height: 20, viewBox: "0 0 24 24", fill: "none", children: [_jsx(Path, { d: "M24 12C24 5.37258 18.6274 0 12 0C5.37258 0 0 5.37258 0 12C0 18.6274 5.37258 24 12 24C18.6274 24 24 18.6274 24 12Z", fill: "#FF0505" }), _jsx(Path, { d: "M12.0001 13.0496L8.3251 16.7246C8.1876 16.8621 8.0126 16.9309 7.8001 16.9309C7.5876 16.9309 7.4126 16.8621 7.2751 16.7246C7.1376 16.5871 7.06885 16.4121 7.06885 16.1996C7.06885 15.9871 7.1376 15.8121 7.2751 15.6746L10.9501 11.9996L7.2751 8.32461C7.1376 8.18711 7.06885 8.01211 7.06885 7.79961C7.06885 7.58711 7.1376 7.41211 7.2751 7.27461C7.4126 7.13711 7.5876 7.06836 7.8001 7.06836C8.0126 7.06836 8.1876 7.13711 8.3251 7.27461L12.0001 10.9496L15.6751 7.27461C15.8126 7.13711 15.9876 7.06836 16.2001 7.06836C16.4126 7.06836 16.5876 7.13711 16.7251 7.27461C16.8626 7.41211 16.9313 7.58711 16.9313 7.79961C16.9313 8.01211 16.8626 8.18711 16.7251 8.32461L13.0501 11.9996L16.7251 15.6746C16.8626 15.8121 16.9313 15.9871 16.9313 16.1996C16.9313 16.4121 16.8626 16.5871 16.7251 16.7246C16.5876 16.8621 16.4126 16.9309 16.2001 16.9309C15.9876 16.9309 15.8126 16.8621 15.6751 16.7246L12.0001 13.0496Z", fill: "white" })] }));
|
|
10
|
+
const TransferIcon = () => (_jsxs(Svg, { width: 13, height: 22, viewBox: "0 0 13 22", fill: "none", children: [_jsx(Path, { d: "M3.79288 7.4764C3.18768 7.75078 2.64136 7.98926 2.10883 8.25466C2.03616 8.29184 1.99982 8.47006 1.99731 8.58289C1.98478 9.32397 1.99731 10.065 1.98103 10.8061C1.97471 11.0186 1.90173 11.2233 1.77287 11.39C1.64402 11.5567 1.46614 11.6766 1.26556 11.7318C1.05856 11.7895 0.838872 11.7768 0.639553 11.6956C0.440234 11.6144 0.272077 11.4692 0.160399 11.2818C0.0691791 11.1164 0.0192533 10.9306 0.0150495 10.7407C1.33873e-05 9.89709 -0.0100107 9.05344 0.0163025 8.21107C0.0438688 7.30716 0.526278 6.65198 1.31192 6.30581C2.62758 5.725 3.96956 5.20316 5.30777 4.67749C6.20744 4.3249 6.9843 4.54927 7.56319 5.34163C7.97524 5.90377 8.35834 6.48751 8.71095 7.09048C9.45148 8.37262 10.5604 9.08934 11.9362 9.45218C12.1776 9.50809 12.4072 9.60798 12.6141 9.74707C12.8027 9.89052 12.9343 10.099 12.9845 10.3339C13.0347 10.5688 13.0002 10.8145 12.8872 11.0254C12.6805 11.4536 12.2845 11.6331 11.7971 11.5382C10.2746 11.2463 8.88684 10.4535 7.84512 9.28038C7.78301 9.20037 7.72847 9.11451 7.68223 9.02395L7.58825 9.08293C7.39905 10.042 7.20609 11.0061 7.03066 11.9639C7.01563 12.046 7.10209 12.169 7.17226 12.2421C7.59076 12.6819 8.01678 13.114 8.44281 13.5448C8.6562 13.7516 8.82487 14.0018 8.93796 14.2794C9.05104 14.557 9.10604 14.8558 9.09939 15.1564C9.08811 17.0489 9.09939 18.94 9.09939 20.8325C9.09939 21.5197 8.70093 21.9864 8.12204 21.9954C7.52185 21.9954 7.09206 21.53 7.08956 20.835C7.08956 19.276 7.08956 17.7156 7.07703 16.1565C7.06611 15.9637 6.98732 15.7816 6.85524 15.6436C6.22874 15.0359 5.58845 14.4551 4.90806 13.8243C4.74893 14.5461 4.59857 15.2141 4.45322 15.8834C4.07731 17.6374 3.70141 19.3939 3.31423 21.1479C3.17515 21.789 2.66266 22.1018 2.00734 21.9749C1.44098 21.8646 1.10266 21.3864 1.21669 20.7491C1.45977 19.3824 1.73669 18.0207 2.00358 16.6578C2.4413 14.4201 2.87944 12.1827 3.31799 9.94581C3.4696 9.14575 3.62372 8.34826 3.79288 7.4764Z", fill: Colors.textSecondary }), _jsx(Path, { d: "M7.48515 4.08362C7.2227 4.08381 6.96283 4.03073 6.72056 3.92746C6.4783 3.82419 6.25846 3.67279 6.07376 3.482C5.88905 3.29122 5.74317 3.06485 5.64453 2.81599C5.5459 2.56713 5.49647 2.30073 5.49912 2.0322C5.50668 1.49142 5.72161 0.97533 6.09757 0.595188C6.47353 0.215045 6.98041 0.00129005 7.50896 0C7.77122 0.00167067 8.03057 0.0563769 8.27209 0.160973C8.51362 0.265568 8.73256 0.41799 8.91631 0.609471C9.10006 0.800953 9.24501 1.02772 9.34282 1.27672C9.44062 1.52573 9.48935 1.79206 9.48621 2.0604C9.4881 2.3287 9.43745 2.59466 9.33726 2.8426C9.23706 3.09054 9.08935 3.31543 8.90284 3.50401C8.71633 3.69259 8.49479 3.84103 8.2513 3.94058C8.00781 4.04013 7.74731 4.08877 7.48515 4.08362Z", fill: Colors.textSecondary })] }));
|
|
11
|
+
const FlightAdditionalInfo = ({ itineraries, airlines, includeBaggage = false, baggageText, baggageImage, show, translations, lang, }) => {
|
|
12
|
+
const { dateTimeFormat } = useWidget();
|
|
13
|
+
const locale = lang === "ru" ? "ru-RU" : "en-US";
|
|
14
|
+
const getTransferDuration = (prevSeg, nextSeg) => {
|
|
15
|
+
if (!prevSeg || !nextSeg)
|
|
16
|
+
return null;
|
|
17
|
+
if (nextSeg.transfer_duration) {
|
|
18
|
+
return nextSeg.transfer_duration;
|
|
19
|
+
}
|
|
20
|
+
const arrTime = new Date(prevSeg.arrival.at).getTime();
|
|
21
|
+
const depTime = new Date(nextSeg.departure.at).getTime();
|
|
22
|
+
let diffMin = Math.round((depTime - arrTime) / 60000);
|
|
23
|
+
if (diffMin < 0)
|
|
24
|
+
return null;
|
|
25
|
+
const h = Math.floor(diffMin / 60);
|
|
26
|
+
const m = diffMin % 60;
|
|
27
|
+
return `${h}:${m.toString().padStart(2, "0")}`;
|
|
28
|
+
};
|
|
29
|
+
const getItineraryTravelTime = (segments) => {
|
|
30
|
+
if (!segments || segments.length === 0)
|
|
31
|
+
return null;
|
|
32
|
+
let totalMinutes = 0;
|
|
33
|
+
for (const seg of segments) {
|
|
34
|
+
if (!seg.duration)
|
|
35
|
+
continue;
|
|
36
|
+
const [h, m] = seg.duration.split(":").map(Number);
|
|
37
|
+
totalMinutes += h * 60 + m;
|
|
38
|
+
}
|
|
39
|
+
for (let i = 0; i < segments.length - 1; i++) {
|
|
40
|
+
const current = segments[i];
|
|
41
|
+
const next = segments[i + 1];
|
|
42
|
+
const transferDuration = getTransferDuration(current, next);
|
|
43
|
+
if (!transferDuration)
|
|
44
|
+
continue;
|
|
45
|
+
const [th, tm] = transferDuration.split(":").map(Number);
|
|
46
|
+
totalMinutes += th * 60 + tm;
|
|
47
|
+
}
|
|
48
|
+
const hours = Math.floor(totalMinutes / 60);
|
|
49
|
+
const minutes = totalMinutes % 60;
|
|
50
|
+
return `${hours}${translations["hours_label"] || "h"} ${minutes
|
|
51
|
+
.toString()
|
|
52
|
+
.padStart(2, "0")}${translations["minutes_label"] || "m"}`;
|
|
53
|
+
};
|
|
54
|
+
return (_jsx(View, { style: [
|
|
55
|
+
styles.container,
|
|
56
|
+
{ display: show ? "flex" : "none" },
|
|
57
|
+
], children: itineraries.map((itinerary, itinIndex) => {
|
|
58
|
+
const travelTime = getItineraryTravelTime(itinerary.segments);
|
|
59
|
+
return (_jsxs(React.Fragment, { children: [_jsx(View, { style: styles.itineraryBlock, children: itinerary.segments.map((segment, segIndex) => {
|
|
60
|
+
const nextSeg = itinerary.segments[segIndex + 1];
|
|
61
|
+
const transferDuration = getTransferDuration(segment, nextSeg);
|
|
62
|
+
const airlineCode = segment.operating?.iata_code ||
|
|
63
|
+
segment.operating?.carrier_code ||
|
|
64
|
+
segment.carrier_code ||
|
|
65
|
+
"";
|
|
66
|
+
const airlineName = segment.operating?.[`name_${lang}`] ||
|
|
67
|
+
airlines[airlineCode]?.name ||
|
|
68
|
+
airlineCode ||
|
|
69
|
+
(lang === "ru"
|
|
70
|
+
? "\u041D\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043D\u0430\u044F \u0430\u0432\u0438\u0430\u043A\u043E\u043C\u043F\u0430\u043D\u0438\u044F"
|
|
71
|
+
: "Unknown Airline");
|
|
72
|
+
const airlineLogo = airlineCode
|
|
73
|
+
? `https://cdn.travel-code.com/prod/uploads/airlines/${airlineCode.toUpperCase()}.png`
|
|
74
|
+
: "https://cdn.travel-code.com/prod/images/airline-default.png";
|
|
75
|
+
const [hours, minutes] = segment.duration?.split(":") || [
|
|
76
|
+
"1",
|
|
77
|
+
"00",
|
|
78
|
+
];
|
|
79
|
+
const departureTime = formatTimeByDateTimeFormat(segment.departure?.at, dateTimeFormat);
|
|
80
|
+
const arrivalTime = formatTimeByDateTimeFormat(segment.arrival?.at, dateTimeFormat);
|
|
81
|
+
const departureDate = new Date(segment.departure.at).toLocaleDateString(locale, {
|
|
82
|
+
day: "2-digit",
|
|
83
|
+
month: "long",
|
|
84
|
+
weekday: "short",
|
|
85
|
+
});
|
|
86
|
+
const arrivalDate = new Date(segment.arrival.at).toLocaleDateString(locale, {
|
|
87
|
+
day: "2-digit",
|
|
88
|
+
month: "long",
|
|
89
|
+
weekday: "short",
|
|
90
|
+
});
|
|
91
|
+
return (_jsxs(React.Fragment, { children: [_jsxs(View, { style: styles.segmentBlock, children: [_jsxs(View, { style: styles.segmentHeader, children: [_jsx(Image, { source: { uri: airlineLogo }, style: styles.segmentAirlineLogo, defaultSource: {
|
|
92
|
+
uri: "https://cdn.travel-code.com/prod/images/airline-default.png",
|
|
93
|
+
} }), _jsxs(View, { style: styles.segmentHeaderInfo, children: [_jsx(Text, { style: styles.segmentAirlineName, children: airlineName }), _jsxs(Text, { style: styles.segmentDuration, children: [hours, translations["hours_label"] || "h", " ", minutes, translations["minutes_label"] || "m", " ", translations["in_flight"] || "in flight"] })] }), _jsx(View, { style: styles.flightNumberBadge, children: _jsxs(Text, { style: styles.flightNumberText, children: [translations["flight"] || "Flight", ":", " ", segment.carrier_code, segment.number] }) })] }), _jsxs(View, { style: styles.timingBlock, children: [_jsxs(View, { style: styles.timingRow, children: [_jsx(View, { style: styles.timelineDot }), _jsx(View, { style: styles.timelineConnector }), _jsxs(View, { style: styles.timingInfo, children: [_jsx(Text, { style: styles.timingTime, children: departureTime }), _jsx(Text, { style: styles.timingDate, children: departureDate })] }), _jsx(Text, { style: styles.timingIata, children: segment.departure.iata_code })] }), _jsxs(View, { style: styles.timingRow, children: [_jsx(View, { style: styles.timelineDot }), _jsxs(View, { style: styles.timingInfo, children: [_jsx(Text, { style: styles.timingTime, children: arrivalTime }), _jsx(Text, { style: styles.timingDate, children: arrivalDate })] }), _jsx(Text, { style: styles.timingIata, children: segment.arrival.iata_code })] })] })] }), nextSeg && transferDuration && (_jsxs(View, { style: styles.transferBlock, children: [_jsx(TransferIcon, {}), _jsxs(Text, { style: styles.transferText, children: [translations["transfer"] || "Transfer", " ", transferDuration.replace(":", `${translations["hours_label"] || "h"} `), translations["minutes_label"] || "m"] })] }))] }, segIndex));
|
|
94
|
+
}) }), _jsxs(View, { style: styles.travelTimeBlock, children: [_jsxs(Text, { style: styles.travelTimeText, children: [translations["travel_time"] || "Travel time", ": ", travelTime] }), _jsxs(View, { style: styles.baggageInfo, children: [includeBaggage ? _jsx(BaggageIncludedIcon, {}) : _jsx(NoBaggageIcon, {}), _jsx(Text, { style: styles.baggageStatusText, children: baggageText ||
|
|
95
|
+
(includeBaggage
|
|
96
|
+
? translations["baggage_included"] || "Baggage included"
|
|
97
|
+
: translations["no_baggage"] || "No baggage") })] })] })] }, itinIndex));
|
|
98
|
+
}) }));
|
|
99
|
+
};
|
|
100
|
+
const styles = StyleSheet.create({
|
|
101
|
+
container: {
|
|
102
|
+
overflow: "hidden",
|
|
103
|
+
borderTopWidth: 1,
|
|
104
|
+
borderTopColor: Colors.borderLight,
|
|
105
|
+
marginTop: Spacing.sm,
|
|
106
|
+
paddingTop: Spacing.md,
|
|
107
|
+
},
|
|
108
|
+
itineraryBlock: {
|
|
109
|
+
marginBottom: Spacing.md,
|
|
110
|
+
},
|
|
111
|
+
segmentBlock: {
|
|
112
|
+
marginBottom: Spacing.md,
|
|
113
|
+
},
|
|
114
|
+
segmentHeader: {
|
|
115
|
+
flexDirection: "row",
|
|
116
|
+
alignItems: "center",
|
|
117
|
+
marginBottom: Spacing.md,
|
|
118
|
+
},
|
|
119
|
+
segmentAirlineLogo: {
|
|
120
|
+
width: 40,
|
|
121
|
+
height: 40,
|
|
122
|
+
borderRadius: BorderRadius.full,
|
|
123
|
+
marginRight: Spacing.sm,
|
|
124
|
+
},
|
|
125
|
+
segmentHeaderInfo: {
|
|
126
|
+
flex: 1,
|
|
127
|
+
},
|
|
128
|
+
segmentAirlineName: {
|
|
129
|
+
fontSize: FontSize.md,
|
|
130
|
+
fontWeight: "600",
|
|
131
|
+
color: Colors.text,
|
|
132
|
+
},
|
|
133
|
+
segmentDuration: {
|
|
134
|
+
fontSize: FontSize.sm,
|
|
135
|
+
color: Colors.textSecondary,
|
|
136
|
+
marginTop: 2,
|
|
137
|
+
},
|
|
138
|
+
flightNumberBadge: {
|
|
139
|
+
backgroundColor: Colors.surfaceSecondary,
|
|
140
|
+
paddingHorizontal: Spacing.sm,
|
|
141
|
+
paddingVertical: Spacing.xs,
|
|
142
|
+
borderRadius: BorderRadius.sm,
|
|
143
|
+
},
|
|
144
|
+
flightNumberText: {
|
|
145
|
+
fontSize: FontSize.xs,
|
|
146
|
+
color: Colors.textSecondary,
|
|
147
|
+
fontWeight: "500",
|
|
148
|
+
},
|
|
149
|
+
timingBlock: {
|
|
150
|
+
paddingLeft: Spacing.lg,
|
|
151
|
+
},
|
|
152
|
+
timingRow: {
|
|
153
|
+
flexDirection: "row",
|
|
154
|
+
alignItems: "center",
|
|
155
|
+
marginBottom: Spacing.md,
|
|
156
|
+
},
|
|
157
|
+
timelineDot: {
|
|
158
|
+
width: 10,
|
|
159
|
+
height: 10,
|
|
160
|
+
borderRadius: 5,
|
|
161
|
+
backgroundColor: Colors.primary,
|
|
162
|
+
marginRight: Spacing.sm,
|
|
163
|
+
zIndex: 1,
|
|
164
|
+
},
|
|
165
|
+
timelineConnector: {
|
|
166
|
+
position: "absolute",
|
|
167
|
+
left: 4,
|
|
168
|
+
top: 17,
|
|
169
|
+
width: 2,
|
|
170
|
+
height: 40,
|
|
171
|
+
backgroundColor: Colors.borderLight,
|
|
172
|
+
},
|
|
173
|
+
timingInfo: {
|
|
174
|
+
flex: 1,
|
|
175
|
+
},
|
|
176
|
+
timingTime: {
|
|
177
|
+
fontSize: FontSize.lg,
|
|
178
|
+
fontWeight: "600",
|
|
179
|
+
color: Colors.text,
|
|
180
|
+
},
|
|
181
|
+
timingDate: {
|
|
182
|
+
fontSize: FontSize.xs,
|
|
183
|
+
color: Colors.textSecondary,
|
|
184
|
+
marginTop: 2,
|
|
185
|
+
},
|
|
186
|
+
timingIata: {
|
|
187
|
+
fontSize: FontSize.md,
|
|
188
|
+
fontWeight: "700",
|
|
189
|
+
color: Colors.text,
|
|
190
|
+
},
|
|
191
|
+
transferBlock: {
|
|
192
|
+
flexDirection: "row",
|
|
193
|
+
alignItems: "center",
|
|
194
|
+
backgroundColor: Colors.surfaceSecondary,
|
|
195
|
+
padding: Spacing.md,
|
|
196
|
+
borderRadius: BorderRadius.md,
|
|
197
|
+
marginBottom: Spacing.md,
|
|
198
|
+
gap: Spacing.sm,
|
|
199
|
+
},
|
|
200
|
+
transferIconWrap: {
|
|
201
|
+
marginRight: Spacing.sm,
|
|
202
|
+
},
|
|
203
|
+
transferText: {
|
|
204
|
+
fontSize: FontSize.sm,
|
|
205
|
+
color: Colors.textSecondary,
|
|
206
|
+
},
|
|
207
|
+
travelTimeBlock: {
|
|
208
|
+
borderTopWidth: 1,
|
|
209
|
+
borderTopColor: Colors.borderLight,
|
|
210
|
+
paddingTop: Spacing.md,
|
|
211
|
+
marginBottom: Spacing.md,
|
|
212
|
+
},
|
|
213
|
+
travelTimeText: {
|
|
214
|
+
fontSize: FontSize.md,
|
|
215
|
+
color: Colors.text,
|
|
216
|
+
fontWeight: "500",
|
|
217
|
+
marginBottom: Spacing.sm,
|
|
218
|
+
},
|
|
219
|
+
baggageInfo: {
|
|
220
|
+
flexDirection: "row",
|
|
221
|
+
alignItems: "center",
|
|
222
|
+
gap: Spacing.xs,
|
|
223
|
+
},
|
|
224
|
+
baggageStatusText: {
|
|
225
|
+
fontSize: FontSize.sm,
|
|
226
|
+
color: Colors.textSecondary,
|
|
227
|
+
},
|
|
228
|
+
});
|
|
229
|
+
export default FlightAdditionalInfo;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
type FlightBaggageToggleProps = {
|
|
3
|
+
flight: any;
|
|
4
|
+
includeBaggage: boolean;
|
|
5
|
+
setIncludeBaggage: React.Dispatch<React.SetStateAction<boolean>>;
|
|
6
|
+
setDynamicPrice: React.Dispatch<React.SetStateAction<string | number>>;
|
|
7
|
+
setBaggageText: React.Dispatch<React.SetStateAction<string | undefined>>;
|
|
8
|
+
setBaggageImage: React.Dispatch<React.SetStateAction<string | undefined>>;
|
|
9
|
+
setBuyHref: React.Dispatch<React.SetStateAction<string | null>>;
|
|
10
|
+
sessionId?: string | null;
|
|
11
|
+
translations: Record<string, string>;
|
|
12
|
+
lang: string;
|
|
13
|
+
};
|
|
14
|
+
declare const FlightBaggageToggle: React.FC<FlightBaggageToggleProps>;
|
|
15
|
+
export default FlightBaggageToggle;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
import { View, Text, TouchableOpacity, Switch, StyleSheet } from "react-native";
|
|
4
|
+
import { useWidget } from "../../../../context/WidgetContext";
|
|
5
|
+
import { useApiToken } from "../../../../utils/getToken";
|
|
6
|
+
import { Colors, Spacing, FontSize } from "../../../../theme/colors";
|
|
7
|
+
const translateBaggageText = (text, translations) => {
|
|
8
|
+
if (!text)
|
|
9
|
+
return "";
|
|
10
|
+
const lower = text.toLowerCase().trim();
|
|
11
|
+
if (lower.includes("no luggage"))
|
|
12
|
+
return translations["baggage_toggle_not_included"] || "No baggage";
|
|
13
|
+
if (lower.includes("luggage included"))
|
|
14
|
+
return translations["baggage_toggle_included"] || "Baggage included";
|
|
15
|
+
if (lower === "luggage")
|
|
16
|
+
return translations["baggage_toggle_not_included"] || "Baggage";
|
|
17
|
+
return text;
|
|
18
|
+
};
|
|
19
|
+
const FlightBaggageToggle = ({ flight, includeBaggage, sessionId, setIncludeBaggage, setDynamicPrice, setBaggageText, setBaggageImage, setBuyHref, translations, lang, }) => {
|
|
20
|
+
const token = useApiToken();
|
|
21
|
+
const [isChecked, setIsChecked] = useState(includeBaggage);
|
|
22
|
+
const [labelText, setLabelText] = useState("");
|
|
23
|
+
const [priceDiffText, setPriceDiffText] = useState("");
|
|
24
|
+
const currentSessionId = sessionId || flight.sessionId || "no-session";
|
|
25
|
+
const { config } = useWidget();
|
|
26
|
+
const HOST_URL = config?.additional?.basket_link?.trim() || "https://travel-code.com";
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
if (flight.upgrade) {
|
|
29
|
+
const baggageLabel = translateBaggageText(flight.upgrade.withoutBaggage.baggageText, translations);
|
|
30
|
+
setLabelText(baggageLabel);
|
|
31
|
+
setPriceDiffText(`+${flight.upgrade.priceDiff}`);
|
|
32
|
+
}
|
|
33
|
+
}, [flight, translations]);
|
|
34
|
+
const handleChange = (checked) => {
|
|
35
|
+
setIsChecked(checked);
|
|
36
|
+
setIncludeBaggage(checked);
|
|
37
|
+
if (!flight.upgrade)
|
|
38
|
+
return;
|
|
39
|
+
const data = checked
|
|
40
|
+
? flight.upgrade.withBaggage
|
|
41
|
+
: flight.upgrade.withoutBaggage;
|
|
42
|
+
const translatedText = translateBaggageText(data.baggageText, translations);
|
|
43
|
+
if (checked) {
|
|
44
|
+
setLabelText(translatedText);
|
|
45
|
+
setPriceDiffText("");
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
setLabelText(translateBaggageText(flight.upgrade.withoutBaggage.baggageText, translations));
|
|
49
|
+
setPriceDiffText(`+${flight.upgrade.priceDiff}`);
|
|
50
|
+
}
|
|
51
|
+
const cleanPrice = Number(String(data.totalPrice)
|
|
52
|
+
.replace(/[^0-9.,]/g, "")
|
|
53
|
+
.replace(",", "."));
|
|
54
|
+
setDynamicPrice(cleanPrice || 0);
|
|
55
|
+
setBaggageText(data.bottomBaggageText);
|
|
56
|
+
setBaggageImage(data.image);
|
|
57
|
+
setBuyHref(`${HOST_URL}/flights/add-to-cart?itemIds=${data.id}&sessionId=${currentSessionId}&accessToken=${token}&language=${lang}`);
|
|
58
|
+
};
|
|
59
|
+
if (!flight.upgrade) {
|
|
60
|
+
return (_jsx(View, { style: styles.simpleBaggage, children: _jsx(Text, { style: [
|
|
61
|
+
styles.simpleBaggageText,
|
|
62
|
+
flight.includeBaggage ? styles.baggageGreen : styles.baggageRed,
|
|
63
|
+
], children: flight.includeBaggage
|
|
64
|
+
? translations["baggage_toggle_included"] || "Baggage included"
|
|
65
|
+
: translations["baggage_toggle_not_included"] || "No baggage" }) }));
|
|
66
|
+
}
|
|
67
|
+
return (_jsxs(TouchableOpacity, { style: styles.toggleContainer, onPress: () => handleChange(!isChecked), activeOpacity: 0.7, children: [_jsxs(View, { style: styles.labelRow, children: [_jsx(Text, { style: styles.labelText, children: labelText }), priceDiffText ? (_jsx(Text, { style: styles.priceDiffText, children: priceDiffText })) : null] }), _jsx(Switch, { value: isChecked, onValueChange: handleChange, trackColor: {
|
|
68
|
+
false: Colors.border,
|
|
69
|
+
true: Colors.primary,
|
|
70
|
+
}, thumbColor: Colors.white, ios_backgroundColor: Colors.border })] }));
|
|
71
|
+
};
|
|
72
|
+
const styles = StyleSheet.create({
|
|
73
|
+
simpleBaggage: {
|
|
74
|
+
paddingVertical: Spacing.xs,
|
|
75
|
+
},
|
|
76
|
+
simpleBaggageText: {
|
|
77
|
+
fontSize: FontSize.sm,
|
|
78
|
+
fontWeight: "500",
|
|
79
|
+
},
|
|
80
|
+
baggageGreen: {
|
|
81
|
+
color: Colors.success,
|
|
82
|
+
},
|
|
83
|
+
baggageRed: {
|
|
84
|
+
color: Colors.textTertiary,
|
|
85
|
+
},
|
|
86
|
+
toggleContainer: {
|
|
87
|
+
flexDirection: "row",
|
|
88
|
+
alignItems: "center",
|
|
89
|
+
justifyContent: "space-between",
|
|
90
|
+
width: "100%",
|
|
91
|
+
paddingVertical: Spacing.xs,
|
|
92
|
+
},
|
|
93
|
+
labelRow: {
|
|
94
|
+
flexDirection: "row",
|
|
95
|
+
alignItems: "center",
|
|
96
|
+
flex: 1,
|
|
97
|
+
marginRight: Spacing.sm,
|
|
98
|
+
},
|
|
99
|
+
labelText: {
|
|
100
|
+
fontSize: FontSize.sm,
|
|
101
|
+
color: Colors.text,
|
|
102
|
+
},
|
|
103
|
+
priceDiffText: {
|
|
104
|
+
fontSize: FontSize.sm,
|
|
105
|
+
color: Colors.primary,
|
|
106
|
+
fontWeight: "600",
|
|
107
|
+
marginLeft: Spacing.xs,
|
|
108
|
+
},
|
|
109
|
+
});
|
|
110
|
+
export default FlightBaggageToggle;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
type FlightCardProps = {
|
|
3
|
+
item: any;
|
|
4
|
+
loading: boolean;
|
|
5
|
+
dictionaries?: any;
|
|
6
|
+
airlines?: Record<string, string>;
|
|
7
|
+
sessionId?: string | null;
|
|
8
|
+
translations: Record<string, string>;
|
|
9
|
+
lang: string;
|
|
10
|
+
currencySign?: string;
|
|
11
|
+
onSelect?: (item: any) => void;
|
|
12
|
+
};
|
|
13
|
+
declare const FlightCard: React.FC<FlightCardProps>;
|
|
14
|
+
export default FlightCard;
|