@autobusal/routes-search 1.4.2 → 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.
Files changed (2) hide show
  1. package/RoutesSearch.tsx +13 -5
  2. package/package.json +1 -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
- alert(t('routes_search.errors.adults'));
160
+ setNotice(t('routes_search.errors.adults'));
156
161
  } else if (data.adults + data.children > 5) {
157
- alert(t('routes_search.errors.max_tickets', { max: 5 }));
162
+ setNotice(t('routes_search.errors.max_tickets', { max: 5 }));
158
163
  } else if (data.babies > data.adults) {
159
- alert(t('routes_search.errors.babies'));
164
+ setNotice(t('routes_search.errors.babies'));
160
165
  } else if (selected === 'return' && departureDate > _returnDate) {
161
- alert(t('routes_search.errors.dates'));
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autobusal/routes-search",
3
- "version": "1.4.2",
3
+ "version": "1.5.0",
4
4
  "author": "Ferjolt Ozuni",
5
5
  "type": "module",
6
6
  "main": "index.ts",