forked from jappel/leistungsbilanz-ts
Persist circuit cell edits
This commit is contained in:
parent
3977a6e6e1
commit
76d8d59391
24 changed files with 348 additions and 301 deletions
|
|
@ -3,7 +3,6 @@ import { circuitWriteService } from "../composition/circuit-write-service.js";
|
|||
import {
|
||||
createCircuitSchema,
|
||||
createCircuitWithDeviceRowsSchema,
|
||||
updateCircuitSchema,
|
||||
} from "../../shared/validation/circuit.schemas.js";
|
||||
|
||||
export async function createCircuit(req: Request, res: Response) {
|
||||
|
|
@ -53,25 +52,6 @@ export async function createCircuitWithDeviceRows(req: Request, res: Response) {
|
|||
}
|
||||
}
|
||||
|
||||
export async function updateCircuit(req: Request, res: Response) {
|
||||
const { circuitId } = req.params;
|
||||
if (typeof circuitId !== "string") {
|
||||
return res.status(400).json({ error: "Invalid circuitId" });
|
||||
}
|
||||
|
||||
const parsed = updateCircuitSchema.safeParse(req.body);
|
||||
if (!parsed.success) {
|
||||
return res.status(400).json({ error: parsed.error.flatten() });
|
||||
}
|
||||
|
||||
try {
|
||||
const updated = await circuitWriteService.updateCircuit(circuitId, parsed.data);
|
||||
return res.json(updated);
|
||||
} catch (error) {
|
||||
return res.status(400).json({ error: error instanceof Error ? error.message : "Failed to update circuit." });
|
||||
}
|
||||
}
|
||||
|
||||
export async function deleteCircuit(req: Request, res: Response) {
|
||||
const { circuitId } = req.params;
|
||||
if (typeof circuitId !== "string") {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue