@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,147 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useEffect } from "react";
|
|
3
|
+
import { View, Text, TouchableOpacity, StyleSheet, ScrollView, ActivityIndicator, } from "react-native";
|
|
4
|
+
import { format, addDays } from "date-fns";
|
|
5
|
+
import LocationInput from "./LocationInput";
|
|
6
|
+
import DatePicker from "./DatePicker";
|
|
7
|
+
import PassengersPicker from "./PassengersPicker";
|
|
8
|
+
import AirlinesSelector from "./AirlinesSelector";
|
|
9
|
+
import SwitchLocationBtn from "./SwitchLocationBtn";
|
|
10
|
+
import { useWidget } from "../../../context/WidgetContext";
|
|
11
|
+
import SearchExpiredPopup from "../../search-form/SearchExpiredPopup";
|
|
12
|
+
import { Colors, Spacing, BorderRadius, FontSize } from "../../../theme/colors";
|
|
13
|
+
import { formStyles } from "../../../theme/formStyles";
|
|
14
|
+
const FlightSearchForm = ({ startSearch, loading, error, translations = {}, defaults = null, isPreview, expiration, hasSearched, }) => {
|
|
15
|
+
const { lang, currency, config, colors } = useWidget();
|
|
16
|
+
const defaultFromLocation = config?.defaults?.flights?.from || "VNO";
|
|
17
|
+
const defaultToLocation = config?.defaults?.flights?.to || "BCN";
|
|
18
|
+
const today = new Date();
|
|
19
|
+
const defaultFrom = format(addDays(today, 3), "yyyy-MM-dd");
|
|
20
|
+
const defaultTo = format(addDays(today, 10), "yyyy-MM-dd");
|
|
21
|
+
const [userEdited, setUserEdited] = useState(false);
|
|
22
|
+
const [locationFrom, setLocationFrom] = useState("");
|
|
23
|
+
const [locationTo, setLocationTo] = useState("");
|
|
24
|
+
const [dates, setDates] = useState([defaultFrom, defaultTo]);
|
|
25
|
+
const [passengers, setPassengers] = useState({
|
|
26
|
+
adults: 1,
|
|
27
|
+
children: 0,
|
|
28
|
+
infants: 0,
|
|
29
|
+
});
|
|
30
|
+
const [cabinClass, setCabinClass] = useState("economy");
|
|
31
|
+
const [airlines, setAirlines] = useState([]);
|
|
32
|
+
const [formErrors, setFormErrors] = useState({
|
|
33
|
+
locationFrom: "",
|
|
34
|
+
locationTo: "",
|
|
35
|
+
date: "",
|
|
36
|
+
});
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
if (config?.defaults?.flights) {
|
|
39
|
+
const from = config.defaults.flights.from || "VNO";
|
|
40
|
+
const to = config.defaults.flights.to || "BCN";
|
|
41
|
+
setLocationFrom(from);
|
|
42
|
+
setLocationTo(to);
|
|
43
|
+
}
|
|
44
|
+
}, [config]);
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
setLocationFrom(defaultFromLocation);
|
|
47
|
+
setLocationTo(defaultToLocation);
|
|
48
|
+
}, []);
|
|
49
|
+
const { isExpired: isFlightSearchExpired, startTimer, ignore, reset, } = expiration;
|
|
50
|
+
const refreshFlightSearch = () => {
|
|
51
|
+
startTimer();
|
|
52
|
+
ignore();
|
|
53
|
+
handleSearchClick();
|
|
54
|
+
};
|
|
55
|
+
const handleSearchClick = async () => {
|
|
56
|
+
startTimer();
|
|
57
|
+
const errors = {
|
|
58
|
+
locationFrom: !locationFrom
|
|
59
|
+
? translations["error_location_from"] || "Enter departure city"
|
|
60
|
+
: "",
|
|
61
|
+
locationTo: !locationTo
|
|
62
|
+
? translations["error_location_to"] || "Enter arrival city"
|
|
63
|
+
: "",
|
|
64
|
+
date: !dates[0]
|
|
65
|
+
? translations["error_date"] || "Select departure date"
|
|
66
|
+
: "",
|
|
67
|
+
};
|
|
68
|
+
setFormErrors(errors);
|
|
69
|
+
if (Object.values(errors).some((err) => err !== ""))
|
|
70
|
+
return;
|
|
71
|
+
const toApiDate = (d) => d.split("-").reverse().join(".");
|
|
72
|
+
const params = {
|
|
73
|
+
locationFrom,
|
|
74
|
+
locationTo,
|
|
75
|
+
date: toApiDate(dates[0]),
|
|
76
|
+
dateEnd: dates[1] ? toApiDate(dates[1]) : null,
|
|
77
|
+
cabinClass,
|
|
78
|
+
adults: passengers.adults,
|
|
79
|
+
children: passengers.children,
|
|
80
|
+
infants: passengers.infants,
|
|
81
|
+
airlines: airlines.length ? airlines : undefined,
|
|
82
|
+
};
|
|
83
|
+
await startSearch(params);
|
|
84
|
+
};
|
|
85
|
+
useEffect(() => {
|
|
86
|
+
if (!config?.defaults?.flights)
|
|
87
|
+
return;
|
|
88
|
+
if (userEdited)
|
|
89
|
+
return;
|
|
90
|
+
const from = config.defaults.flights.from || "VNO";
|
|
91
|
+
const to = config.defaults.flights.to || "BCN";
|
|
92
|
+
setLocationFrom(from);
|
|
93
|
+
setLocationTo(to);
|
|
94
|
+
}, [config?.defaults?.flights]);
|
|
95
|
+
return (_jsxs(ScrollView, { style: local.container, showsVerticalScrollIndicator: false, keyboardShouldPersistTaps: "handled", children: [_jsxs(View, { style: [formStyles.formCard, { backgroundColor: colors.form || Colors.surface }], children: [_jsxs(View, { children: [_jsxs(View, { style: local.locationCard, children: [_jsx(Text, { style: local.labelInner, children: translations["from_label_flight"] || "From" }), _jsx(LocationInput, { label: translations["from_label_flight"] || "From", value: locationFrom, onChange: (val) => {
|
|
96
|
+
setLocationFrom(val);
|
|
97
|
+
setUserEdited(true);
|
|
98
|
+
if (formErrors.locationFrom)
|
|
99
|
+
setFormErrors((p) => ({ ...p, locationFrom: "" }));
|
|
100
|
+
}, lang: lang, translations: translations, minimal: true }), _jsx(View, { style: local.locationDivider, children: _jsx(SwitchLocationBtn, { from: locationFrom, to: locationTo, setFrom: (val) => {
|
|
101
|
+
setLocationFrom(val);
|
|
102
|
+
setUserEdited(true);
|
|
103
|
+
}, setTo: (val) => {
|
|
104
|
+
setLocationTo(val);
|
|
105
|
+
setUserEdited(true);
|
|
106
|
+
} }) }), _jsxs(View, { children: [_jsx(Text, { style: local.labelInner, children: translations["to_label_flight"] || "To" }), _jsx(LocationInput, { label: translations["to_label_flight"] || "To", value: locationTo, onChange: (val) => {
|
|
107
|
+
setLocationTo(val);
|
|
108
|
+
setUserEdited(true);
|
|
109
|
+
if (formErrors.locationTo)
|
|
110
|
+
setFormErrors((p) => ({ ...p, locationTo: "" }));
|
|
111
|
+
}, lang: lang, translations: translations, minimal: true })] })] }), formErrors.locationFrom ? (_jsx(Text, { style: formStyles.errorText, children: formErrors.locationFrom })) : null, formErrors.locationTo ? (_jsx(Text, { style: formStyles.errorText, children: formErrors.locationTo })) : null] }), _jsxs(View, { children: [_jsx(DatePicker, { value: dates, onChange: (val) => {
|
|
112
|
+
setDates(val);
|
|
113
|
+
if (formErrors.date)
|
|
114
|
+
setFormErrors((p) => ({ ...p, date: "" }));
|
|
115
|
+
}, lang: lang, translations: translations, mode: "flight" }), formErrors.date ? (_jsx(Text, { style: formStyles.errorText, children: formErrors.date })) : null] }), _jsx(PassengersPicker, { value: passengers, onChange: setPassengers, cabinClass: cabinClass, onCabinClassChange: setCabinClass, translations: translations }), _jsx(AirlinesSelector, { value: airlines, onChange: setAirlines, translations: translations }), _jsx(TouchableOpacity, { style: [
|
|
116
|
+
formStyles.searchButton,
|
|
117
|
+
{ backgroundColor: colors.primary || Colors.primary },
|
|
118
|
+
loading && formStyles.searchButtonDisabled,
|
|
119
|
+
], onPress: handleSearchClick, disabled: loading, activeOpacity: 0.8, children: loading ? (_jsxs(View, { style: formStyles.searchButtonContent, children: [_jsx(ActivityIndicator, { size: "small", color: Colors.textOnPrimary }), _jsx(Text, { style: formStyles.searchButtonText, children: translations?.["search_btn_label_start"] || "Searching..." })] })) : (_jsx(Text, { style: formStyles.searchButtonText, children: translations?.["search_btn_label"] || "Search flights" })) }), error ? _jsx(Text, { style: formStyles.searchError, children: error }) : null] }), !isPreview && hasSearched && (_jsx(SearchExpiredPopup, { isOpen: isFlightSearchExpired, onRefresh: refreshFlightSearch, onClose: ignore, translations: translations, type: "flight" }))] }));
|
|
120
|
+
};
|
|
121
|
+
const local = StyleSheet.create({
|
|
122
|
+
container: {
|
|
123
|
+
flex: 1,
|
|
124
|
+
},
|
|
125
|
+
locationCard: {
|
|
126
|
+
backgroundColor: Colors.inputBg,
|
|
127
|
+
borderRadius: BorderRadius.lg,
|
|
128
|
+
overflow: "hidden",
|
|
129
|
+
},
|
|
130
|
+
locationDivider: {
|
|
131
|
+
borderTopWidth: 1,
|
|
132
|
+
borderTopColor: Colors.border,
|
|
133
|
+
height: 0,
|
|
134
|
+
alignItems: "flex-end",
|
|
135
|
+
paddingRight: Spacing.md,
|
|
136
|
+
zIndex: 2,
|
|
137
|
+
},
|
|
138
|
+
labelInner: {
|
|
139
|
+
color: Colors.label,
|
|
140
|
+
fontWeight: "600",
|
|
141
|
+
fontSize: FontSize.sm,
|
|
142
|
+
marginBottom: 2,
|
|
143
|
+
paddingTop: Spacing.sm,
|
|
144
|
+
paddingHorizontal: Spacing.lg,
|
|
145
|
+
},
|
|
146
|
+
});
|
|
147
|
+
export default FlightSearchForm;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
type LocationInputProps = {
|
|
3
|
+
label: string;
|
|
4
|
+
value: string;
|
|
5
|
+
onChange: (val: string) => void;
|
|
6
|
+
lang: string;
|
|
7
|
+
translations: Record<string, string>;
|
|
8
|
+
minimal?: boolean;
|
|
9
|
+
};
|
|
10
|
+
declare const LocationInput: React.FC<LocationInputProps>;
|
|
11
|
+
export default LocationInput;
|
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useEffect, useCallback } from "react";
|
|
3
|
+
import { View, Text, TextInput, TouchableOpacity, Modal, FlatList, StyleSheet, ActivityIndicator, } from "react-native";
|
|
4
|
+
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
5
|
+
import Svg, { Circle, Path } from "react-native-svg";
|
|
6
|
+
import { useAirportSearch } from "../../hooks/useAirportSearch";
|
|
7
|
+
import { useApiToken } from "../../../utils/getToken";
|
|
8
|
+
import { Colors, Spacing, FontSize } from "../../../theme/colors";
|
|
9
|
+
import { formStyles } from "../../../theme/formStyles";
|
|
10
|
+
import { CloseIcon } from "../../../store";
|
|
11
|
+
const POPULAR_LOCATIONS = [
|
|
12
|
+
{
|
|
13
|
+
id: 1,
|
|
14
|
+
code: "WAW",
|
|
15
|
+
title: "Варшава",
|
|
16
|
+
titleEn: "Warsaw",
|
|
17
|
+
country: { id: 1001, title: "Польша", titleEn: "Poland" },
|
|
18
|
+
isAirport: true,
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
id: 2,
|
|
22
|
+
code: "BER",
|
|
23
|
+
title: "Берлин",
|
|
24
|
+
titleEn: "Berlin",
|
|
25
|
+
country: { id: 1002, title: "Германия", titleEn: "Germany" },
|
|
26
|
+
isAirport: true,
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
id: 3,
|
|
30
|
+
code: "VNO",
|
|
31
|
+
title: "Вильнюс",
|
|
32
|
+
titleEn: "Vilnius",
|
|
33
|
+
country: { id: 1003, title: "Литва", titleEn: "Lithuania" },
|
|
34
|
+
isAirport: true,
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
id: 4,
|
|
38
|
+
code: "IST",
|
|
39
|
+
title: "Стамбул",
|
|
40
|
+
titleEn: "Istanbul",
|
|
41
|
+
country: { id: 1004, title: "Турция", titleEn: "Turkey" },
|
|
42
|
+
isAirport: true,
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
id: 5,
|
|
46
|
+
code: "CDG",
|
|
47
|
+
title: "Париж",
|
|
48
|
+
titleEn: "Paris",
|
|
49
|
+
country: { id: 1005, title: "Франция", titleEn: "France" },
|
|
50
|
+
isAirport: true,
|
|
51
|
+
},
|
|
52
|
+
];
|
|
53
|
+
const API_URL = "https://api.travel-code.com/v1/data/airports";
|
|
54
|
+
const SearchIcon = () => (_jsxs(Svg, { width: 19, height: 18, viewBox: "0 0 19 18", fill: "none", children: [_jsx(Circle, { cx: 7, cy: 7, r: 6, stroke: Colors.primary, strokeWidth: 2 }), _jsx(Path, { d: "M12 11L17.2857 16.0902", stroke: Colors.primary, strokeWidth: 2, strokeLinecap: "round" })] }));
|
|
55
|
+
const LocationInput = ({ label, value, onChange, lang, translations, minimal = false, }) => {
|
|
56
|
+
const token = useApiToken();
|
|
57
|
+
const insets = useSafeAreaInsets();
|
|
58
|
+
const getLabel = (loc) => lang === "en" ? loc.titleEn || loc.title : loc.title;
|
|
59
|
+
const [query, setQuery] = useState("");
|
|
60
|
+
const [savedValue, setSavedValue] = useState({
|
|
61
|
+
code: value || "",
|
|
62
|
+
title: "",
|
|
63
|
+
titleEn: "",
|
|
64
|
+
country: undefined,
|
|
65
|
+
});
|
|
66
|
+
const [isPopupOpen, setIsPopupOpen] = useState(false);
|
|
67
|
+
const [allowSearch, setAllowSearch] = useState(false);
|
|
68
|
+
const { locations, loading } = useAirportSearch(allowSearch ? query : "");
|
|
69
|
+
const fetchLocationByIata = useCallback(async (iata) => {
|
|
70
|
+
try {
|
|
71
|
+
const res = await fetch(`${API_URL}/${iata}?type=iata&scope=country`, {
|
|
72
|
+
headers: {
|
|
73
|
+
"Content-Type": "application/json",
|
|
74
|
+
Authorization: `Bearer ${token}`,
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
if (!res.ok)
|
|
78
|
+
throw new Error(`Error ${res.status}`);
|
|
79
|
+
const data = await res.json();
|
|
80
|
+
if (data?.title) {
|
|
81
|
+
const country = data.country
|
|
82
|
+
? {
|
|
83
|
+
id: data.country.id ?? 0,
|
|
84
|
+
title: data.country.title,
|
|
85
|
+
titleEn: data.country.titleEn || data.country.title,
|
|
86
|
+
}
|
|
87
|
+
: undefined;
|
|
88
|
+
setSavedValue({
|
|
89
|
+
code: iata,
|
|
90
|
+
title: data.title,
|
|
91
|
+
titleEn: data.titleEn || "",
|
|
92
|
+
country,
|
|
93
|
+
});
|
|
94
|
+
setQuery(getLabel(data));
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
setQuery(iata);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
catch (e) {
|
|
101
|
+
console.warn("Error loading location by IATA:", iata, e);
|
|
102
|
+
setQuery(iata);
|
|
103
|
+
}
|
|
104
|
+
finally {
|
|
105
|
+
setAllowSearch(true);
|
|
106
|
+
}
|
|
107
|
+
}, [token, lang]);
|
|
108
|
+
useEffect(() => {
|
|
109
|
+
if (value && value !== savedValue.code) {
|
|
110
|
+
setAllowSearch(false);
|
|
111
|
+
fetchLocationByIata(value);
|
|
112
|
+
}
|
|
113
|
+
}, [value]);
|
|
114
|
+
useEffect(() => {
|
|
115
|
+
if (!savedValue.code)
|
|
116
|
+
return;
|
|
117
|
+
const newLabel = getLabel(savedValue);
|
|
118
|
+
setQuery(newLabel);
|
|
119
|
+
}, [lang]);
|
|
120
|
+
const handleSelect = (loc) => {
|
|
121
|
+
const country = loc.country
|
|
122
|
+
? {
|
|
123
|
+
id: loc.country.id ?? 0,
|
|
124
|
+
title: loc.country.title,
|
|
125
|
+
titleEn: loc.country.titleEn || loc.country.title,
|
|
126
|
+
}
|
|
127
|
+
: undefined;
|
|
128
|
+
onChange(loc.code);
|
|
129
|
+
setQuery(getLabel(loc));
|
|
130
|
+
setSavedValue({
|
|
131
|
+
code: loc.code,
|
|
132
|
+
title: loc.title,
|
|
133
|
+
titleEn: loc.titleEn,
|
|
134
|
+
country,
|
|
135
|
+
});
|
|
136
|
+
setIsPopupOpen(false);
|
|
137
|
+
};
|
|
138
|
+
const handleClose = () => {
|
|
139
|
+
if (!query.trim()) {
|
|
140
|
+
setQuery(savedValue.title || savedValue.code);
|
|
141
|
+
}
|
|
142
|
+
setIsPopupOpen(false);
|
|
143
|
+
};
|
|
144
|
+
const isEmpty = !query.trim();
|
|
145
|
+
const isSelected = !!savedValue.title &&
|
|
146
|
+
query.trim() === (lang === "en" ? savedValue.titleEn || savedValue.title : savedValue.title);
|
|
147
|
+
const isSearching = query.trim() && !isSelected;
|
|
148
|
+
const renderLocationItem = ({ item: loc }) => {
|
|
149
|
+
if (!loc.code)
|
|
150
|
+
return null;
|
|
151
|
+
const cityName = getLabel(loc);
|
|
152
|
+
const countryName = loc.country ? getLabel(loc.country) : "";
|
|
153
|
+
return (_jsx(TouchableOpacity, { style: styles.locationItem, onPress: () => handleSelect(loc), activeOpacity: 0.7, children: _jsx(View, { style: styles.locationItemContent, children: _jsxs(View, { style: styles.locationInfo, children: [_jsxs(Text, { style: styles.locationCity, children: [cityName, countryName ? (_jsx(Text, { style: styles.locationCountry, children: ` ${countryName}` })) : null] }), _jsx(Text, { style: styles.locationCode, children: loc.code })] }) }) }));
|
|
154
|
+
};
|
|
155
|
+
const getListData = () => {
|
|
156
|
+
if (loading)
|
|
157
|
+
return { data: [] };
|
|
158
|
+
if (isEmpty) {
|
|
159
|
+
return {
|
|
160
|
+
header: translations["popular_locations"] || "Popular destinations",
|
|
161
|
+
data: POPULAR_LOCATIONS,
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
if (isSelected) {
|
|
165
|
+
const selectedItem = {
|
|
166
|
+
id: "selected",
|
|
167
|
+
code: savedValue.code,
|
|
168
|
+
title: savedValue.title,
|
|
169
|
+
titleEn: savedValue.titleEn || "",
|
|
170
|
+
country: savedValue.country,
|
|
171
|
+
isAirport: true,
|
|
172
|
+
};
|
|
173
|
+
return {
|
|
174
|
+
header: translations["popular_locations"] || "Popular destinations",
|
|
175
|
+
data: [selectedItem, ...POPULAR_LOCATIONS],
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
return { data: locations };
|
|
179
|
+
};
|
|
180
|
+
const listInfo = getListData();
|
|
181
|
+
const triggerContent = (_jsxs(View, { style: minimal ? styles.minimalRow : formStyles.inputTriggerRow, children: [_jsx(Text, { style: [
|
|
182
|
+
minimal ? styles.minimalText : formStyles.inputTriggerText,
|
|
183
|
+
!query && formStyles.inputTriggerPlaceholder,
|
|
184
|
+
], numberOfLines: 1, children: query || label }), savedValue.code ? (_jsx(Text, { style: formStyles.inputTriggerCode, children: savedValue.code })) : null] }));
|
|
185
|
+
return (_jsxs(_Fragment, { children: [minimal ? (_jsx(TouchableOpacity, { style: styles.minimalContainer, onPress: () => setIsPopupOpen(true), activeOpacity: 0.8, children: triggerContent })) : (_jsxs(TouchableOpacity, { style: formStyles.inputTrigger, onPress: () => setIsPopupOpen(true), activeOpacity: 0.8, children: [_jsx(Text, { style: formStyles.label, children: label }), triggerContent] })), _jsx(Modal, { visible: isPopupOpen, animationType: "slide", presentationStyle: "fullScreen", onRequestClose: handleClose, children: _jsxs(View, { style: [styles.modalContainer, { paddingTop: insets.top }], children: [_jsx(TouchableOpacity, { style: styles.closeButton, onPress: handleClose, hitSlop: { top: 8, bottom: 8, left: 8, right: 8 }, children: _jsx(CloseIcon, { size: 16 }) }), _jsxs(View, { style: styles.searchHeader, children: [_jsx(SearchIcon, {}), _jsx(TextInput, { autoFocus: true, style: styles.searchInput, value: query, onChangeText: (text) => {
|
|
186
|
+
setQuery(text);
|
|
187
|
+
setAllowSearch(true);
|
|
188
|
+
}, placeholder: translations["location_popup_placeholder"] ||
|
|
189
|
+
"Enter city or airport", placeholderTextColor: Colors.textTertiary, returnKeyType: "search" })] }), _jsxs(View, { style: styles.modalContent, children: [loading && (_jsxs(View, { style: styles.loadingContainer, children: [_jsx(ActivityIndicator, { size: "small", color: Colors.primary }), _jsx(Text, { style: styles.loadingText, children: translations["location_popup_loading"] || "Loading..." })] })), !loading && isSearching && locations.length === 0 && (_jsx(Text, { style: styles.noResults, children: translations["location_popup_no_results"] ||
|
|
190
|
+
"Nothing found" })), !loading && (_jsxs(_Fragment, { children: [listInfo.header && (_jsx(Text, { style: styles.sectionTitle, children: listInfo.header })), _jsx(FlatList, { data: listInfo.data, renderItem: renderLocationItem, keyExtractor: (item) => String(item.id), keyboardShouldPersistTaps: "handled", showsVerticalScrollIndicator: false })] }))] })] }) })] }));
|
|
191
|
+
};
|
|
192
|
+
const styles = StyleSheet.create({
|
|
193
|
+
minimalContainer: {
|
|
194
|
+
paddingHorizontal: Spacing.lg,
|
|
195
|
+
paddingVertical: Spacing.sm,
|
|
196
|
+
minHeight: 56,
|
|
197
|
+
justifyContent: "center",
|
|
198
|
+
marginBottom: 10,
|
|
199
|
+
},
|
|
200
|
+
minimalRow: {
|
|
201
|
+
flexDirection: "row",
|
|
202
|
+
alignItems: "center",
|
|
203
|
+
justifyContent: "space-between",
|
|
204
|
+
},
|
|
205
|
+
minimalText: {
|
|
206
|
+
fontSize: FontSize.md,
|
|
207
|
+
color: Colors.text,
|
|
208
|
+
flex: 1,
|
|
209
|
+
fontWeight: "400",
|
|
210
|
+
},
|
|
211
|
+
modalContainer: {
|
|
212
|
+
flex: 1,
|
|
213
|
+
backgroundColor: Colors.surface,
|
|
214
|
+
},
|
|
215
|
+
closeButton: {
|
|
216
|
+
alignSelf: "flex-end",
|
|
217
|
+
padding: Spacing.lg,
|
|
218
|
+
},
|
|
219
|
+
closeButtonText: {
|
|
220
|
+
fontSize: FontSize.xl,
|
|
221
|
+
color: Colors.textSecondary,
|
|
222
|
+
fontWeight: "600",
|
|
223
|
+
},
|
|
224
|
+
searchHeader: {
|
|
225
|
+
flexDirection: "row",
|
|
226
|
+
alignItems: "center",
|
|
227
|
+
paddingHorizontal: Spacing.lg,
|
|
228
|
+
paddingVertical: Spacing.md,
|
|
229
|
+
borderBottomWidth: 1,
|
|
230
|
+
borderBottomColor: Colors.border,
|
|
231
|
+
gap: Spacing.md,
|
|
232
|
+
},
|
|
233
|
+
searchInput: {
|
|
234
|
+
flex: 1,
|
|
235
|
+
fontSize: FontSize.lg,
|
|
236
|
+
color: Colors.text,
|
|
237
|
+
paddingVertical: Spacing.sm,
|
|
238
|
+
},
|
|
239
|
+
modalContent: {
|
|
240
|
+
flex: 1,
|
|
241
|
+
paddingHorizontal: Spacing.lg,
|
|
242
|
+
},
|
|
243
|
+
loadingContainer: {
|
|
244
|
+
flexDirection: "row",
|
|
245
|
+
alignItems: "center",
|
|
246
|
+
padding: Spacing.lg,
|
|
247
|
+
gap: Spacing.sm,
|
|
248
|
+
},
|
|
249
|
+
loadingText: {
|
|
250
|
+
fontSize: FontSize.md,
|
|
251
|
+
color: Colors.textSecondary,
|
|
252
|
+
},
|
|
253
|
+
noResults: {
|
|
254
|
+
padding: Spacing.lg,
|
|
255
|
+
fontSize: FontSize.md,
|
|
256
|
+
color: Colors.textTertiary,
|
|
257
|
+
},
|
|
258
|
+
sectionTitle: {
|
|
259
|
+
fontSize: FontSize.sm,
|
|
260
|
+
color: Colors.textTertiary,
|
|
261
|
+
fontWeight: "600",
|
|
262
|
+
textTransform: "uppercase",
|
|
263
|
+
paddingVertical: Spacing.md,
|
|
264
|
+
letterSpacing: 0.5,
|
|
265
|
+
},
|
|
266
|
+
locationItem: {
|
|
267
|
+
paddingVertical: Spacing.md,
|
|
268
|
+
borderBottomWidth: StyleSheet.hairlineWidth,
|
|
269
|
+
borderBottomColor: Colors.borderLight,
|
|
270
|
+
},
|
|
271
|
+
locationItemContent: {
|
|
272
|
+
flexDirection: "row",
|
|
273
|
+
alignItems: "center",
|
|
274
|
+
},
|
|
275
|
+
locationInfo: {
|
|
276
|
+
flex: 1,
|
|
277
|
+
},
|
|
278
|
+
locationCity: {
|
|
279
|
+
fontSize: FontSize.md,
|
|
280
|
+
color: Colors.text,
|
|
281
|
+
fontWeight: "500",
|
|
282
|
+
},
|
|
283
|
+
locationCountry: {
|
|
284
|
+
fontSize: FontSize.md,
|
|
285
|
+
color: Colors.textSecondary,
|
|
286
|
+
fontWeight: "400",
|
|
287
|
+
},
|
|
288
|
+
locationCode: {
|
|
289
|
+
fontSize: FontSize.sm,
|
|
290
|
+
color: Colors.textTertiary,
|
|
291
|
+
marginTop: 2,
|
|
292
|
+
},
|
|
293
|
+
});
|
|
294
|
+
export default LocationInput;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
type Passengers = {
|
|
3
|
+
adults: number;
|
|
4
|
+
children: number;
|
|
5
|
+
infants: number;
|
|
6
|
+
};
|
|
7
|
+
type PassengersPickerProps = {
|
|
8
|
+
label?: string;
|
|
9
|
+
value: Passengers;
|
|
10
|
+
onChange: (val: Passengers) => void;
|
|
11
|
+
cabinClass: string;
|
|
12
|
+
onCabinClassChange: (val: string) => void;
|
|
13
|
+
translations: Record<string, string>;
|
|
14
|
+
};
|
|
15
|
+
declare const PassengersPicker: React.FC<PassengersPickerProps>;
|
|
16
|
+
export default PassengersPicker;
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { View, Text, TouchableOpacity, Modal, StyleSheet, ScrollView, } from "react-native";
|
|
4
|
+
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
5
|
+
import Svg, { Path } from "react-native-svg";
|
|
6
|
+
import { Colors, Spacing, BorderRadius, FontSize } from "../../../theme/colors";
|
|
7
|
+
import { formStyles } from "../../../theme/formStyles";
|
|
8
|
+
const MAX_COUNT = 10;
|
|
9
|
+
const PASSENGER_TYPES = [
|
|
10
|
+
{ key: "adults", labelKey: "adults_label_full", fallback: "Adults (12+)", min: 1 },
|
|
11
|
+
{ key: "children", labelKey: "children_label_full", fallback: "Children (2-12)", min: 0 },
|
|
12
|
+
{ key: "infants", labelKey: "infants_label_full", fallback: "Infants (0-2)", min: 0 },
|
|
13
|
+
];
|
|
14
|
+
const CABIN_OPTIONS = [
|
|
15
|
+
{ value: "economy", labelKey: "cabin_economy_label", fallback: "Economy" },
|
|
16
|
+
{ value: "economy_premium", labelKey: "cabin_premium_label", fallback: "Premium Economy" },
|
|
17
|
+
{ value: "business", labelKey: "cabin_business_label", fallback: "Business" },
|
|
18
|
+
];
|
|
19
|
+
const ChevronDown = () => (_jsx(Svg, { width: 20, height: 20, viewBox: "0 0 20 20", fill: "none", children: _jsx(Path, { d: "M5 8L10 12.5L15 8", stroke: Colors.primary, strokeWidth: 2, strokeLinecap: "round" }) }));
|
|
20
|
+
const PassengersPicker = ({ label, value, onChange, cabinClass, onCabinClassChange, translations, }) => {
|
|
21
|
+
const [isModalOpen, setIsModalOpen] = useState(false);
|
|
22
|
+
const insets = useSafeAreaInsets();
|
|
23
|
+
const updateCount = (key, delta, min, max) => {
|
|
24
|
+
const newValue = Math.min(max, Math.max(min, value[key] + delta));
|
|
25
|
+
onChange({ ...value, [key]: newValue });
|
|
26
|
+
};
|
|
27
|
+
const total = value.adults + value.children + value.infants;
|
|
28
|
+
const labelText = total === 1
|
|
29
|
+
? translations["passenger_label"] || "Passenger"
|
|
30
|
+
: translations["passengers_label"] || "Passengers";
|
|
31
|
+
const labelFinal = label || translations["passengers_label"] || "Passengers";
|
|
32
|
+
const cabinLabel = cabinClass === "business"
|
|
33
|
+
? translations["cabin_business"] || "Business"
|
|
34
|
+
: cabinClass === "economy_premium"
|
|
35
|
+
? translations["cabin_premium"] || "Premium Economy"
|
|
36
|
+
: translations["cabin_economy"] || "Economy";
|
|
37
|
+
return (_jsxs(_Fragment, { children: [_jsxs(TouchableOpacity, { style: formStyles.inputTrigger, onPress: () => setIsModalOpen(true), activeOpacity: 0.8, children: [_jsx(Text, { style: formStyles.label, children: labelFinal }), _jsxs(View, { style: formStyles.inputTriggerRow, children: [_jsxs(Text, { style: styles.triggerText, children: [_jsxs(Text, { style: styles.triggerCount, children: [total, " "] }), _jsxs(Text, { children: [labelText, ", "] }), _jsx(Text, { children: cabinLabel })] }), _jsx(ChevronDown, {})] })] }), _jsx(Modal, { visible: isModalOpen, animationType: "slide", presentationStyle: "fullScreen", onRequestClose: () => setIsModalOpen(false), children: _jsxs(View, { style: [styles.modalContainer, { paddingTop: insets.top }], children: [_jsxs(View, { style: styles.modalHeader, children: [_jsx(TouchableOpacity, { onPress: () => setIsModalOpen(false), hitSlop: { top: 8, bottom: 8, left: 8, right: 8 }, children: _jsx(Svg, { width: 24, height: 24, viewBox: "0 0 24 24", fill: "none", children: _jsx(Path, { d: "M15 18L9 12L15 6", stroke: Colors.textSecondary, strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round" }) }) }), _jsxs(View, { style: styles.modalHeaderInfo, children: [_jsx(Text, { style: styles.modalTitle, children: translations["passengers_popup_title"] || "Passengers & Class" }), _jsxs(Text, { style: styles.modalSubtitle, children: [total, " ", labelText, ", ", cabinLabel] })] })] }), _jsxs(ScrollView, { style: styles.modalContent, showsVerticalScrollIndicator: false, children: [_jsx(Text, { style: styles.sectionTitle, children: translations["passengers_label"] || "Passengers" }), PASSENGER_TYPES.map(({ key, labelKey, fallback, min }) => (_jsxs(View, { style: styles.counterRow, children: [_jsx(Text, { style: styles.counterLabel, children: translations[labelKey] || fallback }), _jsxs(View, { style: styles.counterControls, children: [_jsx(TouchableOpacity, { style: [
|
|
38
|
+
styles.counterButton,
|
|
39
|
+
value[key] <= min && styles.counterButtonDisabled,
|
|
40
|
+
], onPress: () => updateCount(key, -1, min, MAX_COUNT), disabled: value[key] <= min, activeOpacity: 0.7, children: _jsx(Text, { style: [
|
|
41
|
+
styles.counterButtonText,
|
|
42
|
+
value[key] <= min && styles.counterButtonTextDisabled,
|
|
43
|
+
], children: "-" }) }), _jsx(Text, { style: styles.counterValue, children: value[key] }), _jsx(TouchableOpacity, { style: [
|
|
44
|
+
styles.counterButton,
|
|
45
|
+
value[key] >= MAX_COUNT && styles.counterButtonDisabled,
|
|
46
|
+
], onPress: () => updateCount(key, 1, min, MAX_COUNT), disabled: value[key] >= MAX_COUNT, activeOpacity: 0.7, children: _jsx(Text, { style: [
|
|
47
|
+
styles.counterButtonText,
|
|
48
|
+
value[key] >= MAX_COUNT && styles.counterButtonTextDisabled,
|
|
49
|
+
], children: "+" }) })] })] }, key))), _jsx(Text, { style: [styles.sectionTitle, { marginTop: Spacing.xxl }], children: translations["cabin_label"] || "Class" }), CABIN_OPTIONS.map((option) => {
|
|
50
|
+
const isSelected = cabinClass === option.value;
|
|
51
|
+
return (_jsxs(TouchableOpacity, { style: styles.radioRow, onPress: () => onCabinClassChange(option.value), activeOpacity: 0.7, children: [_jsx(View, { style: [styles.radio, isSelected && styles.radioSelected], children: isSelected && _jsx(View, { style: styles.radioInner }) }), _jsx(Text, { style: [
|
|
52
|
+
styles.radioLabel,
|
|
53
|
+
isSelected && styles.radioLabelSelected,
|
|
54
|
+
], children: translations[option.labelKey] || option.fallback })] }, option.value));
|
|
55
|
+
})] }), _jsx(View, { style: styles.modalFooter, children: _jsx(TouchableOpacity, { style: styles.saveButton, onPress: () => setIsModalOpen(false), activeOpacity: 0.8, children: _jsx(Text, { style: styles.saveButtonText, children: translations["save_button"] || "Save" }) }) })] }) })] }));
|
|
56
|
+
};
|
|
57
|
+
const styles = StyleSheet.create({
|
|
58
|
+
triggerText: {
|
|
59
|
+
fontSize: FontSize.md,
|
|
60
|
+
color: Colors.text,
|
|
61
|
+
flex: 1,
|
|
62
|
+
},
|
|
63
|
+
triggerCount: {
|
|
64
|
+
fontWeight: "600",
|
|
65
|
+
},
|
|
66
|
+
modalContainer: {
|
|
67
|
+
flex: 1,
|
|
68
|
+
backgroundColor: Colors.surface,
|
|
69
|
+
},
|
|
70
|
+
modalHeader: {
|
|
71
|
+
flexDirection: "row",
|
|
72
|
+
alignItems: "center",
|
|
73
|
+
paddingHorizontal: Spacing.lg,
|
|
74
|
+
paddingVertical: Spacing.md,
|
|
75
|
+
borderBottomWidth: 1,
|
|
76
|
+
borderBottomColor: Colors.border,
|
|
77
|
+
gap: Spacing.md,
|
|
78
|
+
},
|
|
79
|
+
modalHeaderInfo: {
|
|
80
|
+
flex: 1,
|
|
81
|
+
},
|
|
82
|
+
modalTitle: {
|
|
83
|
+
fontSize: FontSize.lg,
|
|
84
|
+
fontWeight: "600",
|
|
85
|
+
color: Colors.text,
|
|
86
|
+
},
|
|
87
|
+
modalSubtitle: {
|
|
88
|
+
fontSize: FontSize.sm,
|
|
89
|
+
color: Colors.textSecondary,
|
|
90
|
+
marginTop: 2,
|
|
91
|
+
},
|
|
92
|
+
modalContent: {
|
|
93
|
+
flex: 1,
|
|
94
|
+
paddingHorizontal: Spacing.lg,
|
|
95
|
+
paddingTop: Spacing.lg,
|
|
96
|
+
},
|
|
97
|
+
sectionTitle: {
|
|
98
|
+
fontSize: FontSize.sm,
|
|
99
|
+
color: Colors.textTertiary,
|
|
100
|
+
fontWeight: "600",
|
|
101
|
+
textTransform: "uppercase",
|
|
102
|
+
letterSpacing: 0.5,
|
|
103
|
+
marginBottom: Spacing.md,
|
|
104
|
+
},
|
|
105
|
+
counterRow: {
|
|
106
|
+
flexDirection: "row",
|
|
107
|
+
alignItems: "center",
|
|
108
|
+
justifyContent: "space-between",
|
|
109
|
+
paddingVertical: Spacing.md,
|
|
110
|
+
borderBottomWidth: StyleSheet.hairlineWidth,
|
|
111
|
+
borderBottomColor: Colors.borderLight,
|
|
112
|
+
},
|
|
113
|
+
counterLabel: {
|
|
114
|
+
fontSize: FontSize.md,
|
|
115
|
+
color: Colors.text,
|
|
116
|
+
flex: 1,
|
|
117
|
+
},
|
|
118
|
+
counterControls: {
|
|
119
|
+
flexDirection: "row",
|
|
120
|
+
alignItems: "center",
|
|
121
|
+
gap: Spacing.lg,
|
|
122
|
+
},
|
|
123
|
+
counterButton: {
|
|
124
|
+
width: 36,
|
|
125
|
+
height: 36,
|
|
126
|
+
borderRadius: BorderRadius.full,
|
|
127
|
+
borderWidth: 1,
|
|
128
|
+
borderColor: Colors.border,
|
|
129
|
+
alignItems: "center",
|
|
130
|
+
justifyContent: "center",
|
|
131
|
+
backgroundColor: Colors.surface,
|
|
132
|
+
},
|
|
133
|
+
counterButtonDisabled: {
|
|
134
|
+
opacity: 0.4,
|
|
135
|
+
},
|
|
136
|
+
counterButtonText: {
|
|
137
|
+
fontSize: FontSize.xl,
|
|
138
|
+
color: Colors.primary,
|
|
139
|
+
fontWeight: "500",
|
|
140
|
+
},
|
|
141
|
+
counterButtonTextDisabled: {
|
|
142
|
+
color: Colors.textTertiary,
|
|
143
|
+
},
|
|
144
|
+
counterValue: {
|
|
145
|
+
fontSize: FontSize.lg,
|
|
146
|
+
fontWeight: "600",
|
|
147
|
+
color: Colors.text,
|
|
148
|
+
minWidth: 24,
|
|
149
|
+
textAlign: "center",
|
|
150
|
+
},
|
|
151
|
+
radioRow: {
|
|
152
|
+
flexDirection: "row",
|
|
153
|
+
alignItems: "center",
|
|
154
|
+
paddingVertical: Spacing.md,
|
|
155
|
+
gap: Spacing.md,
|
|
156
|
+
borderBottomWidth: StyleSheet.hairlineWidth,
|
|
157
|
+
borderBottomColor: Colors.borderLight,
|
|
158
|
+
},
|
|
159
|
+
radio: {
|
|
160
|
+
width: 22,
|
|
161
|
+
height: 22,
|
|
162
|
+
borderRadius: BorderRadius.full,
|
|
163
|
+
borderWidth: 2,
|
|
164
|
+
borderColor: Colors.border,
|
|
165
|
+
alignItems: "center",
|
|
166
|
+
justifyContent: "center",
|
|
167
|
+
},
|
|
168
|
+
radioSelected: {
|
|
169
|
+
borderColor: Colors.primary,
|
|
170
|
+
},
|
|
171
|
+
radioInner: {
|
|
172
|
+
width: 12,
|
|
173
|
+
height: 12,
|
|
174
|
+
borderRadius: BorderRadius.full,
|
|
175
|
+
backgroundColor: Colors.primary,
|
|
176
|
+
},
|
|
177
|
+
radioLabel: {
|
|
178
|
+
fontSize: FontSize.md,
|
|
179
|
+
color: Colors.textSecondary,
|
|
180
|
+
},
|
|
181
|
+
radioLabelSelected: {
|
|
182
|
+
color: Colors.text,
|
|
183
|
+
fontWeight: "500",
|
|
184
|
+
},
|
|
185
|
+
modalFooter: {
|
|
186
|
+
paddingHorizontal: Spacing.lg,
|
|
187
|
+
paddingVertical: Spacing.md,
|
|
188
|
+
borderTopWidth: 1,
|
|
189
|
+
borderTopColor: Colors.border,
|
|
190
|
+
},
|
|
191
|
+
saveButton: {
|
|
192
|
+
backgroundColor: Colors.primary,
|
|
193
|
+
borderRadius: BorderRadius.md,
|
|
194
|
+
paddingVertical: Spacing.md,
|
|
195
|
+
alignItems: "center",
|
|
196
|
+
},
|
|
197
|
+
saveButtonText: {
|
|
198
|
+
color: Colors.textOnPrimary,
|
|
199
|
+
fontSize: FontSize.lg,
|
|
200
|
+
fontWeight: "600",
|
|
201
|
+
},
|
|
202
|
+
});
|
|
203
|
+
export default PassengersPicker;
|