rework vehicle handling

This commit is contained in:
Matthias Hochmeister
2026-02-28 14:13:56 +01:00
parent 06f94a6a48
commit b7b883649c
7 changed files with 38 additions and 27 deletions

View File

@@ -15,7 +15,7 @@ async function unwrap<T>(
promise: ReturnType<typeof api.get<{ success: boolean; data: T }>>
): Promise<T> {
const response = await promise;
if (!response.data?.data) {
if (response.data?.data === undefined || response.data?.data === null) {
throw new Error('Invalid API response');
}
return response.data.data;
@@ -47,7 +47,7 @@ export const vehiclesApi = {
'/api/vehicles',
payload
);
if (!response.data?.data) {
if (response.data?.data === undefined || response.data?.data === null) {
throw new Error('Invalid API response');
}
return response.data.data;
@@ -58,7 +58,7 @@ export const vehiclesApi = {
`/api/vehicles/${id}`,
payload
);
if (!response.data?.data) {
if (response.data?.data === undefined || response.data?.data === null) {
throw new Error('Invalid API response');
}
return response.data.data;
@@ -83,7 +83,7 @@ export const vehiclesApi = {
`/api/vehicles/${id}/wartung`,
payload
);
if (!response.data?.data) {
if (response.data?.data === undefined || response.data?.data === null) {
throw new Error('Invalid API response');
}
return response.data.data;