Support decimal commas and cell units

This commit is contained in:
Julian Appel 2026-07-31 14:33:47 +02:00
parent 734a2bcfc4
commit 5fb81bab04
4 changed files with 36 additions and 10 deletions

View file

@ -351,6 +351,24 @@ export function formatValue(value: GridValue, key?: CellKey): string {
return String(value);
}
export function formatCellValue(value: GridValue, key: CellKey): string {
const formatted = formatValue(value, key);
if (formatted === "-" || typeof value !== "number") {
return formatted;
}
if (key === "quantity") {
return `${formatted} St.`;
}
if (
key === "powerPerUnit" ||
key === "rowTotalPower" ||
key === "circuitTotalPower"
) {
return `${formatted} kW`;
}
return formatted;
}
export function formatPhaseTypeLabel(value: string): string {
if (value === "single_phase") {
return "1-phasig";
@ -378,7 +396,7 @@ export function parseNumeric(cellKey: CellKey, draft: string): number | undefine
if (trimmed === "") {
return undefined;
}
const parsed = Number(trimmed);
const parsed = Number(trimmed.replace(",", "."));
if (Number.isNaN(parsed)) {
throw new Error(`Ungültiger Zahlenwert in ${cellKey}`);
}