fix(ausruestungsanfrage): correct API paths, assignment navigation, and pre-fill user on Zuweisung page
This commit is contained in:
@@ -82,15 +82,21 @@ export default function AusruestungsanfrageZuweisung() {
|
||||
|
||||
// Initialize assignments when unassigned positions load
|
||||
useMemo(() => {
|
||||
if (unassigned.length > 0 && Object.keys(assignments).length === 0) {
|
||||
if (unassigned.length > 0 && Object.keys(assignments).length === 0 && detail) {
|
||||
const init: Record<number, PositionAssignment> = {};
|
||||
const anfrage = detail.anfrage;
|
||||
for (const p of unassigned) {
|
||||
// Pre-fill eigenschaften from position values
|
||||
const prefilled: Record<number, string> = {};
|
||||
for (const e of p.eigenschaften ?? []) {
|
||||
prefilled[e.eigenschaft_id] = e.wert;
|
||||
}
|
||||
init[p.id] = { typ: 'persoenlich', eigenschaften: prefilled };
|
||||
init[p.id] = {
|
||||
typ: 'persoenlich',
|
||||
eigenschaften: prefilled,
|
||||
userId: anfrage.anfrager_id,
|
||||
benutzerName: anfrage.fuer_benutzer_name || anfrage.anfrager_name,
|
||||
};
|
||||
}
|
||||
setAssignments(init);
|
||||
}
|
||||
|
||||
@@ -341,7 +341,7 @@ function PersoenlicheAusruestungPage() {
|
||||
<Chip label={pos.artikel_id ? 'Ja' : 'Nein'} color={pos.artikel_id ? 'success' : 'warning'} size="small" variant="outlined" />
|
||||
</td>
|
||||
<td>
|
||||
<Button size="small" variant="outlined" onClick={() => navigate(`/ausruestungsanfrage/${pos.anfrage_id}/zuweisen`)}>
|
||||
<Button size="small" variant="outlined" onClick={() => navigate(`/ausruestungsanfrage/${pos.anfrage_id}/zuweisung`)}>
|
||||
Zuweisen
|
||||
</Button>
|
||||
</td>
|
||||
|
||||
@@ -191,12 +191,12 @@ export const ausruestungsanfrageApi = {
|
||||
|
||||
// ── Position linking ──
|
||||
linkPositionToArtikel: async (positionId: number, artikelId: number): Promise<void> => {
|
||||
await api.patch(`/api/ausruestungsanfrage/positionen/${positionId}/artikel`, { artikel_id: artikelId });
|
||||
await api.patch(`/api/ausruestungsanfragen/positionen/${positionId}/artikel`, { artikel_id: artikelId });
|
||||
},
|
||||
|
||||
// ── Unassigned positions ──
|
||||
getUnassignedPositions: async (): Promise<UnassignedPosition[]> => {
|
||||
const r = await api.get<{ success: boolean; data: UnassignedPosition[] }>('/api/ausruestungsanfrage/nicht-zugewiesen');
|
||||
const r = await api.get<{ success: boolean; data: UnassignedPosition[] }>('/api/ausruestungsanfragen/nicht-zugewiesen');
|
||||
return r.data.data;
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user