feat: implement 'not_started' task status with validation and UI updates

This commit is contained in:
2025-10-07 23:07:15 +02:00
parent a6ef325813
commit 33c5466d77
6 changed files with 31 additions and 4 deletions

View File

@@ -49,6 +49,14 @@ async function updateProjectTaskStatusHandler(req, { params }) {
);
}
const allowedStatuses = ['not_started', 'pending', 'in_progress', 'completed', 'cancelled'];
if (!allowedStatuses.includes(status)) {
return NextResponse.json(
{ error: "Invalid status. Must be one of: " + allowedStatuses.join(', ') },
{ status: 400 }
);
}
updateProjectTaskStatus(id, status, req.user?.id || null);
return NextResponse.json({ success: true });
} catch (error) {

View File

@@ -135,9 +135,10 @@ export default function ProjectTasksList() {
groups.completed.push(taskWithStatus);
} else if (task.status === "in_progress") {
groups.in_progress.push(taskWithStatus);
} else {
} else if (task.status === "pending") {
groups.pending.push(taskWithStatus);
}
// not_started tasks are not displayed in the UI
});
// Sort pending tasks by date_added (newest first)

View File

@@ -25,6 +25,10 @@ export default function TaskStatusDropdown({
}, []);
const statusConfig = {
not_started: {
label: t("taskStatus.not_started"),
variant: "secondary",
},
pending: {
label: t("taskStatus.pending"),
variant: "warning",

View File

@@ -135,6 +135,7 @@ const translations = {
// Task statuses
taskStatus: {
not_started: "Nie rozpoczęte",
pending: "Oczekujące",
in_progress: "W trakcie",
completed: "Ukończone",
@@ -699,6 +700,7 @@ const translations = {
},
taskStatus: {
not_started: "Not Started",
pending: "Pending",
in_progress: "In Progress",
completed: "Completed",

View File

@@ -71,7 +71,7 @@ export default function initializeDatabase() {
task_template_id INTEGER,
custom_task_name TEXT,
custom_max_wait_days INTEGER DEFAULT 0,
status TEXT NOT NULL DEFAULT 'pending',
status TEXT NOT NULL DEFAULT 'not_started' CHECK(status IN ('not_started', 'pending', 'in_progress', 'completed', 'cancelled')),
date_added TEXT DEFAULT CURRENT_TIMESTAMP,
priority TEXT DEFAULT 'normal',
FOREIGN KEY (project_id) REFERENCES projects(project_id),
@@ -279,6 +279,18 @@ export default function initializeDatabase() {
// Column already exists, ignore error
}
// Migration: Update task status system - add 'not_started' status
try {
// First, update all existing 'pending' tasks to 'not_started'
db.exec(`
UPDATE project_tasks SET status = 'not_started' WHERE status = 'pending';
`);
// Note: CHECK constraint will be applied when recreating the table in future migrations
// For now, we'll rely on application-level validation
} catch (e) {
// Migration already done, ignore error
}
// Create indexes for notes user tracking
try {
db.exec(`

View File

@@ -90,7 +90,7 @@ export function createProjectTask(data) {
result = stmt.run(
data.project_id,
data.task_template_id,
data.status || "pending",
data.status || "not_started",
data.priority || "normal",
data.created_by || null,
data.assigned_to || null
@@ -114,7 +114,7 @@ export function createProjectTask(data) {
data.custom_task_name,
data.custom_max_wait_days || 0,
data.custom_description || "",
data.status || "pending",
data.status || "not_started",
data.priority || "normal",
data.created_by || null,
data.assigned_to || null