rework vehicle handling
This commit is contained in:
@@ -14,6 +14,7 @@ import {
|
||||
Fab,
|
||||
FormControl,
|
||||
Grid,
|
||||
IconButton,
|
||||
InputLabel,
|
||||
MenuItem,
|
||||
Paper,
|
||||
|
||||
@@ -216,7 +216,7 @@ export const incidentsApi = {
|
||||
const response = await api.get<{ success: boolean; data: IncidentListResponse }>(
|
||||
`/api/incidents?${params.toString()}`
|
||||
);
|
||||
if (!response.data?.data) {
|
||||
if (response.data?.data === undefined || response.data?.data === null) {
|
||||
throw new Error('Invalid API response');
|
||||
}
|
||||
return response.data.data;
|
||||
@@ -230,7 +230,7 @@ export const incidentsApi = {
|
||||
const response = await api.get<{ success: boolean; data: EinsatzStats }>(
|
||||
`/api/incidents/stats${params}`
|
||||
);
|
||||
if (!response.data?.data) {
|
||||
if (response.data?.data === undefined || response.data?.data === null) {
|
||||
throw new Error('Invalid API response');
|
||||
}
|
||||
return response.data.data;
|
||||
@@ -243,7 +243,7 @@ export const incidentsApi = {
|
||||
const response = await api.get<{ success: boolean; data: EinsatzDetail }>(
|
||||
`/api/incidents/${id}`
|
||||
);
|
||||
if (!response.data?.data) {
|
||||
if (response.data?.data === undefined || response.data?.data === null) {
|
||||
throw new Error('Invalid API response');
|
||||
}
|
||||
return response.data.data;
|
||||
@@ -257,7 +257,7 @@ export const incidentsApi = {
|
||||
'/api/incidents',
|
||||
payload
|
||||
);
|
||||
if (!response.data?.data) {
|
||||
if (response.data?.data === undefined || response.data?.data === null) {
|
||||
throw new Error('Invalid API response');
|
||||
}
|
||||
return response.data.data;
|
||||
@@ -271,7 +271,7 @@ export const incidentsApi = {
|
||||
`/api/incidents/${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;
|
||||
|
||||
@@ -55,7 +55,7 @@ export const membersService = {
|
||||
const response = await api.get<ApiListResponse<MemberListItem>>(
|
||||
`/api/members?${params.toString()}`
|
||||
);
|
||||
if (!response.data?.data) {
|
||||
if (response.data?.data === undefined || response.data?.data === null) {
|
||||
throw new Error('Invalid API response');
|
||||
}
|
||||
return {
|
||||
@@ -72,7 +72,7 @@ export const membersService = {
|
||||
const response = await api.get<ApiItemResponse<MemberWithProfile>>(
|
||||
`/api/members/${userId}`
|
||||
);
|
||||
if (!response.data?.data) {
|
||||
if (response.data?.data === undefined || response.data?.data === null) {
|
||||
throw new Error('Invalid API response');
|
||||
}
|
||||
return response.data.data;
|
||||
@@ -90,7 +90,7 @@ export const membersService = {
|
||||
`/api/members/${userId}/profile`,
|
||||
data
|
||||
);
|
||||
if (!response.data?.data) {
|
||||
if (response.data?.data === undefined || response.data?.data === null) {
|
||||
throw new Error('Invalid API response');
|
||||
}
|
||||
return response.data.data;
|
||||
@@ -109,7 +109,7 @@ export const membersService = {
|
||||
`/api/members/${userId}`,
|
||||
data
|
||||
);
|
||||
if (!response.data?.data) {
|
||||
if (response.data?.data === undefined || response.data?.data === null) {
|
||||
throw new Error('Invalid API response');
|
||||
}
|
||||
return response.data.data;
|
||||
@@ -120,7 +120,7 @@ export const membersService = {
|
||||
*/
|
||||
async getMemberStats(): Promise<MemberStats> {
|
||||
const response = await api.get<ApiItemResponse<MemberStats>>('/api/members/stats');
|
||||
if (!response.data?.data) {
|
||||
if (response.data?.data === undefined || response.data?.data === null) {
|
||||
throw new Error('Invalid API response');
|
||||
}
|
||||
return response.data.data;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user