feat: add task_category field to tasks with validation and update related forms
This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user