Derive project device phases from category

This commit is contained in:
2026-07-31 14:37:45 +02:00
parent 5fb81bab04
commit 1e3c721cfa
9 changed files with 101 additions and 80 deletions
@@ -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(