@autobusal/operator-routes 1.3.1 → 1.3.2
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/CHANGELOG.md +17 -0
- package/Locations/Add/Add.tsx +19 -2
- package/Locations/services.ts +14 -6
- package/Locations/types.ts +13 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.3.2
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- **A stop added in a multi-zone country says so.** Times are stored local
|
|
8
|
+
to their stop, and a country with no zone recorded falls back to the
|
|
9
|
+
application's clock - a duration that reads plausibly and is wrong by
|
|
10
|
+
hours. The API now answers `warning: 'timezone'` and the operator is told,
|
|
11
|
+
because the operator is who sees the wrong number and would otherwise
|
|
12
|
+
"fix" it by editing times that are correct as stored.
|
|
13
|
+
|
|
14
|
+
### Fixed
|
|
15
|
+
|
|
16
|
+
- **`useAddLocation` returns its response.** It was awaited and discarded,
|
|
17
|
+
so `onSuccess` received undefined - harmless while the endpoint answered
|
|
18
|
+
with an empty object, and it would have swallowed the warning above.
|
|
19
|
+
|
|
3
20
|
## [1.3.1] - 2026-08-07
|
|
4
21
|
|
|
5
22
|
### Fixed
|
package/Locations/Add/Add.tsx
CHANGED
|
@@ -2,7 +2,7 @@ import { TFunction } from 'i18next';
|
|
|
2
2
|
import { useForm } from 'react-hook-form';
|
|
3
3
|
import { FiPlus } from 'react-icons/fi';
|
|
4
4
|
import { Button } from '@autobusal/common';
|
|
5
|
-
import { Validate, Display, success } from '@autobusal/utilities';
|
|
5
|
+
import { Validate, Display, success, notify } from '@autobusal/utilities';
|
|
6
6
|
import Loading from './Loading';
|
|
7
7
|
import { getStops } from '../utilities';
|
|
8
8
|
import { Container, Title, ContainerAdd, Choose, Notice } from './styles';
|
|
@@ -28,9 +28,26 @@ const Add = ({ routeId, t, onReload }: Props): JSX.Element => {
|
|
|
28
28
|
|
|
29
29
|
const onSubmit = (data: AddForm): void => {
|
|
30
30
|
Save(data, {
|
|
31
|
-
onSuccess: () => {
|
|
31
|
+
onSuccess: (response) => {
|
|
32
32
|
success(t('locations_manage.messages.added', { ns: 'common' }));
|
|
33
33
|
|
|
34
|
+
/*
|
|
35
|
+
* Edited: Ferjolt Ozuni - Date: 2026-08-07
|
|
36
|
+
*
|
|
37
|
+
* The stop was added - this is a caveat, not a failure, so it comes
|
|
38
|
+
* after the success and does not stop the reload.
|
|
39
|
+
*
|
|
40
|
+
* It is worth saying out loud because the consequence is a wrong
|
|
41
|
+
* NUMBER rather than an error: times at this stop fall back to our
|
|
42
|
+
* clock, so a duration can read short or long by hours. An operator
|
|
43
|
+
* who sees that without being told why is likely to correct it by
|
|
44
|
+
* editing the stored times, and that turns something we can fix
|
|
45
|
+
* centrally into data nobody can untangle later.
|
|
46
|
+
*/
|
|
47
|
+
if (response?.warning === 'timezone') {
|
|
48
|
+
notify(t('locations_manage.messages.timezone', { ns: 'common' }));
|
|
49
|
+
}
|
|
50
|
+
|
|
34
51
|
onReload();
|
|
35
52
|
}
|
|
36
53
|
});
|
package/Locations/services.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { UseMutationResult, UseQueryResult, UseSuspenseQueryResult, useMutation,
|
|
|
2
2
|
import { apiClient } from '@autobusal/providers';
|
|
3
3
|
import { RouteData } from '@autobusal/providers/types/routes';
|
|
4
4
|
import { CountryData } from '@autobusal/providers/types/locations';
|
|
5
|
-
import { AddForm, LocationForm } from './types';
|
|
5
|
+
import { AddForm, AddResponse, LocationForm } from './types';
|
|
6
6
|
|
|
7
7
|
export const useGetLocations = (id: number): UseSuspenseQueryResult<RouteData> => (
|
|
8
8
|
useSuspenseQuery({
|
|
@@ -36,19 +36,27 @@ export const useGetStops = (routeId: number): UseQueryResult<CountryData[]> => (
|
|
|
36
36
|
})
|
|
37
37
|
);
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
/*
|
|
40
|
+
* Edited: Ferjolt Ozuni - Date: 2026-08-07
|
|
41
|
+
*
|
|
42
|
+
* Returns the response instead of discarding it. It was awaited and thrown
|
|
43
|
+
* away, so `onSuccess` was handed undefined - which was invisible while the
|
|
44
|
+
* endpoint answered with an empty object, and would have quietly swallowed
|
|
45
|
+
* the `warning` it can now carry.
|
|
46
|
+
*/
|
|
47
|
+
export const useAddLocation = (id: number): UseMutationResult<AddResponse, Error, AddForm, unknown> => (
|
|
40
48
|
useMutation({
|
|
41
49
|
mutationKey: ['operator-locations-add', { id }],
|
|
42
|
-
mutationFn: async (data: AddForm) =>
|
|
43
|
-
|
|
50
|
+
mutationFn: async (data: AddForm) => (
|
|
51
|
+
apiClient
|
|
44
52
|
.post('/api/locations/operator/add', {
|
|
45
53
|
...data,
|
|
46
54
|
id
|
|
47
55
|
})
|
|
48
56
|
.then(response => (
|
|
49
|
-
response.data
|
|
57
|
+
response.data as AddResponse
|
|
50
58
|
))
|
|
51
|
-
|
|
59
|
+
)
|
|
52
60
|
})
|
|
53
61
|
);
|
|
54
62
|
|
package/Locations/types.ts
CHANGED
|
@@ -2,6 +2,19 @@ export interface AddForm {
|
|
|
2
2
|
group_id: string
|
|
3
3
|
}
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* What adding a stop answers with.
|
|
7
|
+
*
|
|
8
|
+
* Empty on the ordinary path. `warning` is a CODE rather than a sentence -
|
|
9
|
+
* the API has no business writing operator-facing prose in fifteen
|
|
10
|
+
* languages - and 'timezone' means the stop's country spans several zones,
|
|
11
|
+
* so the times shown for it fall back to the application's clock rather
|
|
12
|
+
* than its own.
|
|
13
|
+
*/
|
|
14
|
+
export interface AddResponse {
|
|
15
|
+
warning?: 'timezone'
|
|
16
|
+
}
|
|
17
|
+
|
|
5
18
|
export interface LocationForm {
|
|
6
19
|
tomorrow: number
|
|
7
20
|
departure: string
|