Derive device voltages from project settings
This commit is contained in:
@@ -5,6 +5,10 @@ import {
|
||||
inferProjectDeviceSectionKey,
|
||||
isProjectDevicePlacementValid,
|
||||
} from "../../domain/services/project-device-placement.service";
|
||||
import {
|
||||
resolveCircuitPhaseType,
|
||||
resolveProjectVoltage,
|
||||
} from "../../domain/services/project-voltage.service";
|
||||
import {
|
||||
getInsertionSortOrder,
|
||||
resolveGridInsertionIntent,
|
||||
@@ -819,6 +823,19 @@ export function CircuitTreeEditor(props: { projectId: string; circuitListId: str
|
||||
values: CreateCircuitInputDto,
|
||||
deviceRowValues: CreateCircuitDeviceRowInputDto[] = []
|
||||
) {
|
||||
const section = data?.sections.find(
|
||||
(entry) => entry.id === values.sectionId
|
||||
);
|
||||
if (!section || !data) {
|
||||
throw new Error("Bereich wurde nicht gefunden.");
|
||||
}
|
||||
const voltage = resolveProjectVoltage(
|
||||
resolveCircuitPhaseType(
|
||||
section.key,
|
||||
deviceRowValues.map((row) => row.phaseType)
|
||||
),
|
||||
data
|
||||
);
|
||||
const circuitId = crypto.randomUUID();
|
||||
const deviceRows = deviceRowValues.map((row, index) =>
|
||||
createDeviceRowSnapshot(circuitId, row, (index + 1) * 10)
|
||||
@@ -826,7 +843,7 @@ export function CircuitTreeEditor(props: { projectId: string; circuitListId: str
|
||||
return buildCircuitInsertSnapshot({
|
||||
id: circuitId,
|
||||
circuitListId,
|
||||
values,
|
||||
values: { ...values, voltage },
|
||||
deviceRows,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user