All first todos completed
This commit is contained in:
@@ -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,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user