forked from jappel/leistungsbilanz-ts
Configure circuit protection
This commit is contained in:
parent
18ca5eb3d4
commit
8898117ed4
18 changed files with 642 additions and 14 deletions
|
|
@ -8,6 +8,8 @@ import type {
|
|||
CreateCircuitDeviceRowInputDto,
|
||||
CreateCircuitInputDto,
|
||||
} from "../types.js";
|
||||
import type { CircuitGroupCategory } from "../../shared/constants/circuit-group";
|
||||
import { createDefaultCircuitProtection } from "../../domain/services/protection-device-defaults";
|
||||
|
||||
export function buildCircuitDeviceRowInsertSnapshot(input: {
|
||||
id: string;
|
||||
|
|
@ -46,8 +48,12 @@ export function buildCircuitInsertSnapshot(input: {
|
|||
circuitListId: string;
|
||||
values: CreateCircuitInputDto;
|
||||
deviceRows: CircuitDeviceRowSnapshot[];
|
||||
category?: CircuitGroupCategory;
|
||||
}): CircuitSnapshot {
|
||||
const { id, circuitListId, values, deviceRows } = input;
|
||||
const { id, circuitListId, values, deviceRows, category } = input;
|
||||
const defaultProtection = category
|
||||
? createDefaultCircuitProtection(category)
|
||||
: null;
|
||||
return {
|
||||
id,
|
||||
circuitListId,
|
||||
|
|
@ -69,5 +75,30 @@ export function buildCircuitInsertSnapshot(input: {
|
|||
isReserve: deviceRows.length === 0,
|
||||
remark: values.remark ?? null,
|
||||
deviceRows,
|
||||
...(defaultProtection
|
||||
? {
|
||||
protectionDevice: {
|
||||
circuitId: id,
|
||||
type: defaultProtection.type,
|
||||
ratedCurrentA: defaultProtection.ratedCurrentA,
|
||||
fuseUtilizationCategory:
|
||||
"fuseUtilizationCategory" in defaultProtection
|
||||
? defaultProtection.fuseUtilizationCategory
|
||||
: null,
|
||||
tripCharacteristic:
|
||||
"tripCharacteristic" in defaultProtection
|
||||
? defaultProtection.tripCharacteristic
|
||||
: null,
|
||||
rcdType:
|
||||
"rcdType" in defaultProtection
|
||||
? defaultProtection.rcdType
|
||||
: null,
|
||||
ratedResidualCurrentMa:
|
||||
"ratedResidualCurrentMa" in defaultProtection
|
||||
? defaultProtection.ratedResidualCurrentMa
|
||||
: null,
|
||||
},
|
||||
}
|
||||
: {}),
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue