feat: vehicle/equipment type system, equipment checklist support, and checklist overview redesign
This commit is contained in:
37
frontend/src/services/ausruestungTypen.ts
Normal file
37
frontend/src/services/ausruestungTypen.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import { api } from './api';
|
||||
|
||||
export interface AusruestungTyp {
|
||||
id: number;
|
||||
name: string;
|
||||
beschreibung?: string;
|
||||
icon?: string;
|
||||
}
|
||||
|
||||
export const ausruestungTypenApi = {
|
||||
getAll: async (): Promise<AusruestungTyp[]> => {
|
||||
const r = await api.get('/api/ausruestung-typen');
|
||||
return r.data.data ?? r.data;
|
||||
},
|
||||
getById: async (id: number): Promise<AusruestungTyp> => {
|
||||
const r = await api.get(`/api/ausruestung-typen/${id}`);
|
||||
return r.data.data ?? r.data;
|
||||
},
|
||||
create: async (data: { name: string; beschreibung?: string; icon?: string }): Promise<AusruestungTyp> => {
|
||||
const r = await api.post('/api/ausruestung-typen', data);
|
||||
return r.data.data ?? r.data;
|
||||
},
|
||||
update: async (id: number, data: Partial<{ name: string; beschreibung: string; icon: string }>): Promise<AusruestungTyp> => {
|
||||
const r = await api.patch(`/api/ausruestung-typen/${id}`, data);
|
||||
return r.data.data ?? r.data;
|
||||
},
|
||||
delete: async (id: number): Promise<void> => {
|
||||
await api.delete(`/api/ausruestung-typen/${id}`);
|
||||
},
|
||||
getTypesForEquipment: async (ausruestungId: string): Promise<AusruestungTyp[]> => {
|
||||
const r = await api.get(`/api/ausruestung-typen/equipment/${ausruestungId}`);
|
||||
return r.data.data ?? r.data;
|
||||
},
|
||||
setTypesForEquipment: async (ausruestungId: string, typIds: number[]): Promise<void> => {
|
||||
await api.put(`/api/ausruestung-typen/equipment/${ausruestungId}`, { typIds });
|
||||
},
|
||||
};
|
||||
@@ -5,6 +5,7 @@ import type {
|
||||
FahrzeugChecklistItem,
|
||||
ChecklistAusfuehrung,
|
||||
ChecklistFaelligkeit,
|
||||
ChecklistOverviewResponse,
|
||||
ChecklistVorlageFilter,
|
||||
ChecklistAusfuehrungFilter,
|
||||
CreateVorlagePayload,
|
||||
@@ -17,6 +18,12 @@ import type {
|
||||
} from '../types/checklist.types';
|
||||
|
||||
export const checklistenApi = {
|
||||
// ── Overview ──
|
||||
getOverview: async (): Promise<ChecklistOverviewResponse> => {
|
||||
const r = await api.get('/api/checklisten/overview');
|
||||
return r.data.data ?? r.data;
|
||||
},
|
||||
|
||||
// ── Vorlagen (Templates) ──
|
||||
getVorlagen: async (filter?: ChecklistVorlageFilter): Promise<ChecklistVorlage[]> => {
|
||||
const params = new URLSearchParams();
|
||||
@@ -86,6 +93,31 @@ export const checklistenApi = {
|
||||
await api.delete(`/api/checklisten/fahrzeug-items/${id}`);
|
||||
},
|
||||
|
||||
// ── Equipment-specific Items ──
|
||||
getTemplatesForEquipment: async (ausruestungId: string): Promise<ChecklistVorlage[]> => {
|
||||
const r = await api.get(`/api/checklisten/equipment/${ausruestungId}/vorlagen`);
|
||||
return r.data.data;
|
||||
},
|
||||
|
||||
getEquipmentItems: async (ausruestungId: string): Promise<FahrzeugChecklistItem[]> => {
|
||||
const r = await api.get(`/api/checklisten/equipment/${ausruestungId}/items`);
|
||||
return r.data.data;
|
||||
},
|
||||
|
||||
addEquipmentItem: async (ausruestungId: string, data: CreateFahrzeugItemPayload): Promise<FahrzeugChecklistItem> => {
|
||||
const r = await api.post(`/api/checklisten/equipment/${ausruestungId}/items`, data);
|
||||
return r.data.data;
|
||||
},
|
||||
|
||||
updateEquipmentItem: async (ausruestungId: string, itemId: number, data: UpdateFahrzeugItemPayload): Promise<FahrzeugChecklistItem> => {
|
||||
const r = await api.patch(`/api/checklisten/equipment/${ausruestungId}/items/${itemId}`, data);
|
||||
return r.data.data;
|
||||
},
|
||||
|
||||
deleteEquipmentItem: async (ausruestungId: string, itemId: number): Promise<void> => {
|
||||
await api.delete(`/api/checklisten/equipment/${ausruestungId}/items/${itemId}`);
|
||||
},
|
||||
|
||||
// ── Checklists for a Vehicle ──
|
||||
getChecklistenForVehicle: async (fahrzeugId: string): Promise<ChecklistVorlage[]> => {
|
||||
const r = await api.get(`/api/checklisten/fahrzeug/${fahrzeugId}/checklisten`);
|
||||
@@ -93,8 +125,12 @@ export const checklistenApi = {
|
||||
},
|
||||
|
||||
// ── Executions ──
|
||||
startExecution: async (fahrzeugId: string, vorlageId: number): Promise<ChecklistAusfuehrung> => {
|
||||
const r = await api.post('/api/checklisten/ausfuehrungen', { fahrzeug_id: fahrzeugId, vorlage_id: vorlageId });
|
||||
startExecution: async (vorlageId: number, opts: { fahrzeugId?: string; ausruestungId?: string }): Promise<ChecklistAusfuehrung> => {
|
||||
const r = await api.post('/api/checklisten/ausfuehrungen', {
|
||||
vorlage_id: vorlageId,
|
||||
fahrzeugId: opts.fahrzeugId,
|
||||
ausruestungId: opts.ausruestungId,
|
||||
});
|
||||
return r.data.data;
|
||||
},
|
||||
|
||||
|
||||
@@ -25,4 +25,13 @@ export const fahrzeugTypenApi = {
|
||||
delete: async (id: number): Promise<void> => {
|
||||
await api.delete(`/api/fahrzeug-typen/${id}`);
|
||||
},
|
||||
|
||||
getTypesForVehicle: async (fahrzeugId: string): Promise<FahrzeugTyp[]> => {
|
||||
const r = await api.get(`/api/fahrzeug-typen/vehicle/${fahrzeugId}`);
|
||||
return r.data.data ?? r.data;
|
||||
},
|
||||
|
||||
setTypesForVehicle: async (fahrzeugId: string, typIds: number[]): Promise<void> => {
|
||||
await api.put(`/api/fahrzeug-typen/vehicle/${fahrzeugId}`, { typIds });
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user