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