Inline-Nachfüll-Dialog nach Abweichung in der Kontrolle (Karte 07)
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L85hmKbvX7Cqkq47KnQhFt
This commit is contained in:
@@ -2,7 +2,13 @@ import { useEffect, useMemo, useState } from "react";
|
||||
|
||||
import { apiRequest, ApiError } from "../../api/client";
|
||||
import type { Kontrolle, Material, Objekt, Objektposition } from "../../api/types";
|
||||
import { enqueue, eintraegeFuerKontrolle, entferneFehlerEintrag, synchronisiereQueue } from "../../offline/queue";
|
||||
import {
|
||||
aufErgebnisWarten,
|
||||
enqueue,
|
||||
eintraegeFuerKontrolle,
|
||||
entferneFehlerEintrag,
|
||||
synchronisiereQueue,
|
||||
} from "../../offline/queue";
|
||||
import { useOnlineStatus } from "../../offline/useOnlineStatus";
|
||||
import type { PositionZustand, Sperrmeldung } from "./types";
|
||||
|
||||
@@ -22,6 +28,9 @@ export function useKontrolle(objektId: string | undefined) {
|
||||
const [startFehler, setStartFehler] = useState<string | null>(null);
|
||||
const [wirdAbgeschlossen, setWirdAbgeschlossen] = useState(false);
|
||||
const [abschlussFehler, setAbschlussFehler] = useState<string | null>(null);
|
||||
const [nachfuellDialog, setNachfuellDialog] = useState<{ materialId: number; fehlbestandId: string } | null>(
|
||||
null
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (!objektId) return;
|
||||
@@ -113,6 +122,11 @@ export function useKontrolle(objektId: string | undefined) {
|
||||
|
||||
async function positionSenden(materialId: number, zustand: PositionZustand) {
|
||||
if (!kontrolle) return;
|
||||
aufErgebnisWarten(kontrolle.id, materialId, (fehlbestandId, abweichung) => {
|
||||
if (abweichung && fehlbestandId) {
|
||||
setNachfuellDialog({ materialId, fehlbestandId });
|
||||
}
|
||||
});
|
||||
await enqueue(kontrolle.id, materialId, zustand.eingabe, {
|
||||
ablaufdatum: zustand.ablaufdatum || null,
|
||||
chargennummer: zustand.chargennummer || null,
|
||||
@@ -124,6 +138,19 @@ export function useKontrolle(objektId: string | undefined) {
|
||||
void synchronisiereQueue();
|
||||
}
|
||||
|
||||
/** Karte 07: Sofort-Nachfüllung direkt aus dem Dialog nach einer Abweichung. */
|
||||
async function jetztNachfuellen(fehlbestandId: string, menge: string) {
|
||||
await apiRequest(`/fehlbestaende/${fehlbestandId}/nachfuellungen`, {
|
||||
method: "POST",
|
||||
body: { menge },
|
||||
});
|
||||
setNachfuellDialog(null);
|
||||
}
|
||||
|
||||
function nachfuellDialogSchliessen() {
|
||||
setNachfuellDialog(null);
|
||||
}
|
||||
|
||||
async function fehlerErneutVersuchen(materialId: number, zustand: PositionZustand) {
|
||||
if (!kontrolle) return;
|
||||
await entferneFehlerEintrag(kontrolle.id, materialId);
|
||||
@@ -168,11 +195,14 @@ export function useKontrolle(objektId: string | undefined) {
|
||||
wirdAbgeschlossen,
|
||||
abschlussFehler,
|
||||
alleUebertragen,
|
||||
nachfuellDialog,
|
||||
starteKontrolle,
|
||||
eingabeAendern,
|
||||
positionSenden,
|
||||
fehlerErneutVersuchen,
|
||||
abschliessen,
|
||||
abbrechen,
|
||||
jetztNachfuellen,
|
||||
nachfuellDialogSchliessen,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user