feat: add task_category field to tasks with validation and update related forms

This commit is contained in:
2025-10-07 22:22:10 +02:00
parent 952caf10d1
commit a6ef325813
6 changed files with 72 additions and 13 deletions

View File

@@ -30,19 +30,23 @@ async function getTaskHandler(req, { params }) {
async function updateTaskHandler(req, { params }) {
const { id } = await params;
try {
const { name, max_wait_days, description } = await req.json();
const { name, max_wait_days, description, task_category } = await req.json();
if (!name) {
return NextResponse.json({ error: "Name is required" }, { status: 400 });
}
if (task_category && !['design', 'construction'].includes(task_category)) {
return NextResponse.json({ error: "Invalid task_category (must be design or construction)" }, { status: 400 });
}
const result = db
.prepare(
`UPDATE tasks
SET name = ?, max_wait_days = ?, description = ?
SET name = ?, max_wait_days = ?, description = ?, task_category = ?
WHERE task_id = ? AND is_standard = 1`
)
.run(name, max_wait_days || 0, description || null, id);
.run(name, max_wait_days || 0, description || null, task_category, id);
if (result.changes === 0) {
return NextResponse.json(