Derive project device phases from category
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import type { CircuitGroupCategory } from "../../shared/constants/circuit-group.js";
|
||||
|
||||
export interface ProjectDevicePlacementSource {
|
||||
category?: string | null;
|
||||
phaseType: "single_phase" | "three_phase";
|
||||
category: CircuitGroupCategory;
|
||||
}
|
||||
|
||||
export interface ProjectDevicePlacementSection {
|
||||
@@ -14,11 +15,13 @@ export type DefaultCircuitSectionKey = "lighting" | "single_phase" | "three_phas
|
||||
export function inferProjectDeviceSectionKey(
|
||||
device: ProjectDevicePlacementSource
|
||||
): DefaultCircuitSectionKey {
|
||||
const category = (device.category ?? "").trim().toLowerCase();
|
||||
if (category.includes("light") || category.includes("beleuchtung")) {
|
||||
return "lighting";
|
||||
}
|
||||
return device.phaseType;
|
||||
return device.category;
|
||||
}
|
||||
|
||||
export function resolveProjectDevicePhaseType(
|
||||
category: CircuitGroupCategory
|
||||
): "single_phase" | "three_phase" {
|
||||
return category === "three_phase" ? "three_phase" : "single_phase";
|
||||
}
|
||||
|
||||
export function isProjectDevicePlacementValid(
|
||||
|
||||
Reference in New Issue
Block a user