rework vehicle handling

This commit is contained in:
Matthias Hochmeister
2026-02-28 13:57:41 +01:00
parent 41fc41bee4
commit 1e478479be
12 changed files with 85 additions and 26 deletions

View File

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