mautourco-components 0.2.114 → 0.2.116
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/components/molecules/LocationDropdown/LocationDropdown.js +7 -4
- package/dist/components/organisms/TransferLine/TransferLine.js +6 -4
- package/package.json +1 -1
- package/src/components/molecules/LocationDropdown/LocationDropdown.tsx +9 -4
- package/src/components/organisms/TransferLine/TransferLine.tsx +5 -3
|
@@ -32,6 +32,11 @@ var LocationDropdown = function (_a) {
|
|
|
32
32
|
var dropdownPanelRef = useRef(null);
|
|
33
33
|
var inputRef = useRef(null);
|
|
34
34
|
var searchInputRef = useRef(null);
|
|
35
|
+
var getDefaultLabel = function (id) {
|
|
36
|
+
var _a;
|
|
37
|
+
var option = options.find(function (o) { return o.id === id; });
|
|
38
|
+
return (_a = option === null || option === void 0 ? void 0 : option.label) !== null && _a !== void 0 ? _a : '';
|
|
39
|
+
};
|
|
35
40
|
// Close dropdown when clicking outside
|
|
36
41
|
useEffect(function () {
|
|
37
42
|
var handleClickOutside = function (event) {
|
|
@@ -61,9 +66,8 @@ var LocationDropdown = function (_a) {
|
|
|
61
66
|
if (!selectedValue && defaultValue && !disabled) {
|
|
62
67
|
var defaultLocationData = {
|
|
63
68
|
id: defaultValue.id,
|
|
64
|
-
locationName: defaultValue.
|
|
69
|
+
locationName: getDefaultLabel(defaultValue.id),
|
|
65
70
|
};
|
|
66
|
-
console.log('defaultLocationData ===>', defaultLocationData);
|
|
67
71
|
onSelectionChange(defaultLocationData);
|
|
68
72
|
}
|
|
69
73
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -76,10 +80,9 @@ var LocationDropdown = function (_a) {
|
|
|
76
80
|
var handleOptionSelect = function (option) {
|
|
77
81
|
if (disabled)
|
|
78
82
|
return;
|
|
79
|
-
console.log('option selected ===>', option);
|
|
80
83
|
var locationData = {
|
|
81
84
|
id: option.id,
|
|
82
|
-
locationName: option.
|
|
85
|
+
locationName: getDefaultLabel(option.id),
|
|
83
86
|
};
|
|
84
87
|
onSelectionChange(locationData);
|
|
85
88
|
setIsOpen(false);
|
|
@@ -186,17 +186,19 @@ var TransferLine = function (_a) {
|
|
|
186
186
|
};
|
|
187
187
|
// Helper to convert LocationData to LocationOption
|
|
188
188
|
var toLocationOption = function (locationData, position) {
|
|
189
|
-
|
|
189
|
+
var _a;
|
|
190
190
|
if (!locationData)
|
|
191
191
|
return null;
|
|
192
192
|
// Try to find in the options to get the type
|
|
193
|
-
var
|
|
193
|
+
var _b = filterLocations(position), options = _b.options, groups = _b.groups;
|
|
194
194
|
var allLocations = getAllLocations(options, groups);
|
|
195
195
|
var found = allLocations.find(function (loc) { return loc.id === locationData.id; });
|
|
196
196
|
if (found)
|
|
197
197
|
return found;
|
|
198
|
+
var currentLocationName = allLocations.find(function (l) { return l.id === locationData.id; });
|
|
199
|
+
var locationName = (_a = currentLocationName === null || currentLocationName === void 0 ? void 0 : currentLocationName.label) !== null && _a !== void 0 ? _a : locationData.locationName;
|
|
198
200
|
// If not found, infer the type
|
|
199
|
-
var name =
|
|
201
|
+
var name = locationName.toLowerCase();
|
|
200
202
|
var id = String(locationData.id).toLowerCase();
|
|
201
203
|
var locType = 'accommodation';
|
|
202
204
|
if (name.includes('harbour') ||
|
|
@@ -210,7 +212,7 @@ var TransferLine = function (_a) {
|
|
|
210
212
|
}
|
|
211
213
|
return {
|
|
212
214
|
id: locationData.id,
|
|
213
|
-
label:
|
|
215
|
+
label: locationName,
|
|
214
216
|
type: locType,
|
|
215
217
|
};
|
|
216
218
|
};
|
package/package.json
CHANGED
|
@@ -69,6 +69,11 @@ const LocationDropdown: React.FC<LocationDropdownProps> = ({
|
|
|
69
69
|
const inputRef = useRef<HTMLDivElement>(null);
|
|
70
70
|
const searchInputRef = useRef<HTMLInputElement>(null);
|
|
71
71
|
|
|
72
|
+
const getDefaultLabel = (id: string | number) => {
|
|
73
|
+
const option = options.find((o) => o.id === id);
|
|
74
|
+
return option?.label ?? '';
|
|
75
|
+
};
|
|
76
|
+
|
|
72
77
|
// Close dropdown when clicking outside
|
|
73
78
|
useEffect(() => {
|
|
74
79
|
const handleClickOutside = (event: MouseEvent) => {
|
|
@@ -102,9 +107,9 @@ const LocationDropdown: React.FC<LocationDropdownProps> = ({
|
|
|
102
107
|
if (!selectedValue && defaultValue && !disabled) {
|
|
103
108
|
const defaultLocationData: LocationData = {
|
|
104
109
|
id: defaultValue.id,
|
|
105
|
-
locationName: defaultValue.
|
|
110
|
+
locationName: getDefaultLabel(defaultValue.id),
|
|
106
111
|
};
|
|
107
|
-
|
|
112
|
+
|
|
108
113
|
onSelectionChange(defaultLocationData);
|
|
109
114
|
}
|
|
110
115
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -118,11 +123,11 @@ const LocationDropdown: React.FC<LocationDropdownProps> = ({
|
|
|
118
123
|
|
|
119
124
|
const handleOptionSelect = (option: LocationOption) => {
|
|
120
125
|
if (disabled) return;
|
|
121
|
-
console.log('option selected ===>', option);
|
|
122
126
|
const locationData: LocationData = {
|
|
123
127
|
id: option.id,
|
|
124
|
-
locationName: option.
|
|
128
|
+
locationName: getDefaultLabel(option.id),
|
|
125
129
|
};
|
|
130
|
+
|
|
126
131
|
onSelectionChange(locationData);
|
|
127
132
|
setIsOpen(false);
|
|
128
133
|
setSearchQuery('');
|
|
@@ -291,7 +291,6 @@ const TransferLine: React.FC<TransferLineProps> = ({
|
|
|
291
291
|
locationData: LocationData | null,
|
|
292
292
|
position: 'pickup' | 'dropoff'
|
|
293
293
|
): LocationOption | null => {
|
|
294
|
-
console.log('locationData ===>', locationData);
|
|
295
294
|
if (!locationData) return null;
|
|
296
295
|
|
|
297
296
|
// Try to find in the options to get the type
|
|
@@ -300,8 +299,11 @@ const TransferLine: React.FC<TransferLineProps> = ({
|
|
|
300
299
|
const found = allLocations.find((loc) => loc.id === locationData.id);
|
|
301
300
|
if (found) return found;
|
|
302
301
|
|
|
302
|
+
const currentLocationName = allLocations.find((l) => l.id === locationData.id);
|
|
303
|
+
const locationName = currentLocationName?.label ?? locationData.locationName;
|
|
304
|
+
|
|
303
305
|
// If not found, infer the type
|
|
304
|
-
const name =
|
|
306
|
+
const name = locationName.toLowerCase();
|
|
305
307
|
const id = String(locationData.id).toLowerCase();
|
|
306
308
|
let locType: 'airport' | 'port' | 'accommodation' = 'accommodation';
|
|
307
309
|
if (
|
|
@@ -317,7 +319,7 @@ const TransferLine: React.FC<TransferLineProps> = ({
|
|
|
317
319
|
|
|
318
320
|
return {
|
|
319
321
|
id: locationData.id,
|
|
320
|
-
label:
|
|
322
|
+
label: locationName,
|
|
321
323
|
type: locType,
|
|
322
324
|
};
|
|
323
325
|
};
|