Rewrite frontend, added rooms, voltage selection per project, startet with todos

This commit is contained in:
2026-05-01 17:07:56 +02:00
parent 81d47ce16f
commit 65819900b1
49 changed files with 3695 additions and 394 deletions
+28 -4
View File
@@ -2,20 +2,44 @@ import crypto from "node:crypto";
import { eq } from "drizzle-orm";
import { db } from "../client.js";
import { projects } from "../schema/projects.js";
import type {
CreateProjectInput,
UpdateProjectSettingsInput,
} from "../../shared/validation/consumer.schemas.js";
export class ProjectRepository {
async list() {
return db.select().from(projects);
}
async create(name: string) {
async create(input: CreateProjectInput) {
const id = crypto.randomUUID();
await db.insert(projects).values({ id, name });
return { id, name };
const project = {
id,
name: input.name,
singlePhaseVoltageV: input.singlePhaseVoltageV ?? 230,
threePhaseVoltageV: input.threePhaseVoltageV ?? 400,
};
await db.insert(projects).values(project);
return project;
}
async findById(projectId: string) {
const [row] = await db.select().from(projects).where(eq(projects.id, projectId)).limit(1);
return row ?? null;
}
async updateSettings(projectId: string, input: UpdateProjectSettingsInput) {
await db
.update(projects)
.set({
singlePhaseVoltageV: input.singlePhaseVoltageV,
threePhaseVoltageV: input.threePhaseVoltageV,
})
.where(eq(projects.id, projectId));
}
async delete(projectId: string) {
await db.delete(projects).where(eq(projects.id, projectId));
}
}