Fixed text and resetting form.
parent
be165144ad
commit
ffd30aefee
|
|
@ -29,13 +29,13 @@ interface KPIFormProps {
|
|||
resetTrigger?: number;
|
||||
}
|
||||
|
||||
const emptyKPI: Partial<Kennzahl> = {
|
||||
const createEmptyKPI = (): Partial<Kennzahl> => ({
|
||||
name: "",
|
||||
mandatory: false,
|
||||
type: "string",
|
||||
active: true,
|
||||
examples: [{ sentence: "", value: "" }],
|
||||
};
|
||||
});
|
||||
|
||||
export function KPIForm({
|
||||
mode,
|
||||
|
|
@ -44,7 +44,7 @@ export function KPIForm({
|
|||
onCancel,
|
||||
loading = false,
|
||||
}: KPIFormProps) {
|
||||
const [formData, setFormData] = useState<Partial<Kennzahl>>(emptyKPI);
|
||||
const [formData, setFormData] = useState<Partial<Kennzahl>>(createEmptyKPI());
|
||||
const [originalExamples, setOriginalExamples] = useState<
|
||||
Array<{ sentence: string; value: string }>
|
||||
>([]);
|
||||
|
|
@ -64,7 +64,7 @@ export function KPIForm({
|
|||
});
|
||||
} else if (mode === "add") {
|
||||
setOriginalExamples([]);
|
||||
setFormData(emptyKPI);
|
||||
setFormData(createEmptyKPI());
|
||||
}
|
||||
}, [mode, initialData]);
|
||||
|
||||
|
|
@ -167,9 +167,10 @@ export function KPIForm({
|
|||
examples: allExamples,
|
||||
is_trained: false,
|
||||
});
|
||||
|
||||
// Formular zurücksetzen:
|
||||
if (mode === "add") {
|
||||
setFormData(emptyKPI);
|
||||
setFormData(createEmptyKPI());
|
||||
} else {
|
||||
setFormData((prev) => ({
|
||||
...prev,
|
||||
|
|
@ -206,7 +207,7 @@ export function KPIForm({
|
|||
};
|
||||
|
||||
const handleCancel = () => {
|
||||
setFormData(emptyKPI);
|
||||
setFormData(createEmptyKPI());
|
||||
onCancel();
|
||||
};
|
||||
|
||||
|
|
@ -407,7 +408,7 @@ export function KPIForm({
|
|||
</Typography>
|
||||
<Typography variant="body2" mt={1}>
|
||||
<strong>Tipp:</strong> Sie können jederzeit weitere Beispielsätze
|
||||
hinzufügen oder vorhandene in der Kennzahlenverwaltung bearbeiten.
|
||||
hinzufügen.
|
||||
</Typography>
|
||||
</Box>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue