forked from jappel/leistungsbilanz-ts
36 lines
1.2 KiB
TypeScript
36 lines
1.2 KiB
TypeScript
import type {
|
|
CircuitProtectionSnapshot,
|
|
} from "../../domain/models/circuit-protection-project-command.model";
|
|
import { createDefaultCircuitProtection } from "../../domain/services/protection-device-defaults";
|
|
import type { CircuitGroupCategory } from "../../shared/constants/circuit-group";
|
|
import type {
|
|
CircuitTreeProtectionDeviceDto,
|
|
} from "../types";
|
|
|
|
export function toCircuitProtectionSnapshot(
|
|
circuitId: string,
|
|
protection: CircuitTreeProtectionDeviceDto
|
|
): CircuitProtectionSnapshot {
|
|
return {
|
|
circuitId,
|
|
type: protection.type,
|
|
ratedCurrentA: protection.ratedCurrentA,
|
|
fuseUtilizationCategory:
|
|
protection.fuseUtilizationCategory ?? null,
|
|
tripCharacteristic: protection.tripCharacteristic ?? null,
|
|
rcdType: protection.rcdType ?? null,
|
|
ratedResidualCurrentMa:
|
|
protection.ratedResidualCurrentMa ?? null,
|
|
};
|
|
}
|
|
|
|
export function getCircuitProtectionEditorInitialValue(
|
|
category: CircuitGroupCategory | undefined,
|
|
protection: CircuitTreeProtectionDeviceDto | undefined
|
|
): CircuitTreeProtectionDeviceDto {
|
|
if (protection) {
|
|
return protection;
|
|
}
|
|
const fallback = createDefaultCircuitProtection(category ?? "lighting");
|
|
return { ...fallback };
|
|
}
|