All first todos completed

This commit is contained in:
2026-05-01 17:58:14 +02:00
parent 65819900b1
commit 18a4fdd893
29 changed files with 1263 additions and 160 deletions
+2
View File
@@ -3,6 +3,8 @@ export interface Consumer {
projectId: string;
distributionBoardId?: string;
circuitListId?: string;
projectDeviceId?: string;
isLinkedToDevice?: boolean;
roomId?: string;
roomNumber?: string;
roomName?: string;
@@ -0,0 +1,36 @@
import type { CreateConsumerInput } from "../../shared/validation/consumer.schemas.js";
type ProjectDeviceForLinking = {
displayName: string;
category: string | null;
quantity: number;
installedPowerPerUnitKw: number;
demandFactor: number;
phaseCount: number | null;
powerFactor: number | null;
note: string | null;
};
export function applyLinkedProjectDeviceValues(
input: CreateConsumerInput,
projectDevice: ProjectDeviceForLinking | null
): CreateConsumerInput {
if (!input.projectDeviceId || !input.isLinkedToDevice || !projectDevice) {
return input;
}
return {
...input,
name: projectDevice.displayName,
category: projectDevice.category ?? undefined,
quantity: projectDevice.quantity,
installedPowerPerUnitKw: projectDevice.installedPowerPerUnitKw,
demandFactor: projectDevice.demandFactor,
phaseCount:
projectDevice.phaseCount === 1 || projectDevice.phaseCount === 3
? (projectDevice.phaseCount as 1 | 3)
: undefined,
powerFactor: projectDevice.powerFactor ?? undefined,
note: projectDevice.note ?? undefined,
};
}