Rewrite frontend, added rooms, voltage selection per project, startet with todos
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import type { Request, Response } from "express";
|
||||
import { FloorRepository } from "../../db/repositories/floor.repository.js";
|
||||
import { createFloorSchema } from "../../shared/validation/consumer.schemas.js";
|
||||
|
||||
const floorRepository = new FloorRepository();
|
||||
|
||||
export async function listFloorsByProject(req: Request, res: Response) {
|
||||
const { projectId } = req.params;
|
||||
if (typeof projectId !== "string") {
|
||||
return res.status(400).json({ error: "Invalid projectId" });
|
||||
}
|
||||
|
||||
const result = await floorRepository.listByProject(projectId);
|
||||
return res.json(result);
|
||||
}
|
||||
|
||||
export async function createFloor(req: Request, res: Response) {
|
||||
const { projectId } = req.params;
|
||||
if (typeof projectId !== "string") {
|
||||
return res.status(400).json({ error: "Invalid projectId" });
|
||||
}
|
||||
|
||||
const parsed = createFloorSchema.safeParse(req.body);
|
||||
if (!parsed.success) {
|
||||
return res.status(400).json({ error: parsed.error.flatten() });
|
||||
}
|
||||
|
||||
const floor = await floorRepository.create(projectId, parsed.data.name);
|
||||
return res.status(201).json(floor);
|
||||
}
|
||||
Reference in New Issue
Block a user