@autobusal/routes-search 1.4.1 → 1.5.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/RoutesSearch.tsx +13 -5
- package/package.json +1 -1
- package/styles.ts +17 -1
package/RoutesSearch.tsx
CHANGED
|
@@ -3,7 +3,7 @@ import { TFunction } from 'i18next';
|
|
|
3
3
|
import { useForm } from 'react-hook-form';
|
|
4
4
|
import { FaArrowUp, FaHistory } from 'react-icons/fa';
|
|
5
5
|
import { AiOutlineSearch } from 'react-icons/ai';
|
|
6
|
-
import { Button, Autocomplete, Calendar, Passengers, setDepartureZone } from '@autobusal/common';
|
|
6
|
+
import { Button, Autocomplete, Calendar, Passengers, setDepartureZone, FormNotice } from '@autobusal/common';
|
|
7
7
|
import { Display, createDate } from '@autobusal/utilities';
|
|
8
8
|
import { getCities } from './utilities';
|
|
9
9
|
import Picker from './Picker';
|
|
@@ -37,6 +37,9 @@ interface Props {
|
|
|
37
37
|
const RoutesSearch = ({ type, from, to, departure, _return, adultsNo, childrenNo, babiesNo, suggest = false, t, onSearch }: Props): JSX.Element => {
|
|
38
38
|
const [ selected, setSelected ] = useState<'departure' | 'return'>(type);
|
|
39
39
|
|
|
40
|
+
// Claude - 2026-11-05: why a search did not go ahead, shown under the form
|
|
41
|
+
const [ notice, setNotice ] = useState<string | null>(null);
|
|
42
|
+
|
|
40
43
|
// Edited: Ferjolt Ozuni - Date: 2026-08-01
|
|
41
44
|
// Tracked in state rather than read from the form, because the return
|
|
42
45
|
// picker's floor has to move the moment the departure date changes -
|
|
@@ -151,15 +154,18 @@ const RoutesSearch = ({ type, from, to, departure, _return, adultsNo, childrenNo
|
|
|
151
154
|
data.to = to[0];
|
|
152
155
|
data.stop_to = to[1];
|
|
153
156
|
|
|
157
|
+
// Claude - 2026-11-05: said under the form in the site's own look, not
|
|
158
|
+
// in a browser alert()
|
|
154
159
|
if (data.adults == 0) {
|
|
155
|
-
|
|
160
|
+
setNotice(t('routes_search.errors.adults'));
|
|
156
161
|
} else if (data.adults + data.children > 5) {
|
|
157
|
-
|
|
162
|
+
setNotice(t('routes_search.errors.max_tickets', { max: 5 }));
|
|
158
163
|
} else if (data.babies > data.adults) {
|
|
159
|
-
|
|
164
|
+
setNotice(t('routes_search.errors.babies'));
|
|
160
165
|
} else if (selected === 'return' && departureDate > _returnDate) {
|
|
161
|
-
|
|
166
|
+
setNotice(t('routes_search.errors.dates'));
|
|
162
167
|
} else {
|
|
168
|
+
setNotice(null);
|
|
163
169
|
onSearch(data);
|
|
164
170
|
}
|
|
165
171
|
};
|
|
@@ -316,6 +322,8 @@ const RoutesSearch = ({ type, from, to, departure, _return, adultsNo, childrenNo
|
|
|
316
322
|
</Action>
|
|
317
323
|
</Column>
|
|
318
324
|
</Columns>
|
|
325
|
+
|
|
326
|
+
<FormNotice message={ notice } />
|
|
319
327
|
</form>
|
|
320
328
|
);
|
|
321
329
|
}
|
package/package.json
CHANGED
package/styles.ts
CHANGED
|
@@ -52,7 +52,23 @@ export const Item = styled.div`
|
|
|
52
52
|
flex: 1;
|
|
53
53
|
`;
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
/*
|
|
56
|
+
* Edited: Claude - Date: 2026-09-16
|
|
57
|
+
*
|
|
58
|
+
* NOT A HEADING. These are the captions over the search fields - "From",
|
|
59
|
+
* "To", "Departure Date", "Passengers" - and they were <h4>s, which told a
|
|
60
|
+
* screen reader the form contained four headings and told PageSpeed the
|
|
61
|
+
* document skips from <h1> to <h4> ("Heading elements are not in a
|
|
62
|
+
* sequentially-descending order", reported on production today). A caption
|
|
63
|
+
* that labels the control under it is not a section title; the fields'
|
|
64
|
+
* accessible names come from the controls themselves.
|
|
65
|
+
*
|
|
66
|
+
* A div rather than a <label>, deliberately: the controls beneath are
|
|
67
|
+
* composite widgets (Autocomplete, Calendar, the passenger picker) that own
|
|
68
|
+
* their own labelling, and a <label> pointing at a wrapper would announce
|
|
69
|
+
* the caption twice. Styling is unchanged.
|
|
70
|
+
*/
|
|
71
|
+
export const Title = styled.div`
|
|
56
72
|
margin-bottom: 8px;
|
|
57
73
|
font-size: ${ props => props.theme.size.s };
|
|
58
74
|
`;
|