feat: Add user tracking to project tasks and notes
- Implemented user tracking columns in project_tasks and notes tables. - Added created_by and assigned_to fields to project_tasks. - Introduced created_by field and is_system flag in notes. - Updated API endpoints to handle user tracking during task and note creation. - Enhanced database initialization to include new columns and indexes. - Created utility functions to fetch users for task assignment. - Updated front-end components to display user information for tasks and notes. - Added tests for project-tasks API endpoints to verify functionality.
This commit is contained in:
@@ -43,11 +43,20 @@ async function createProjectTaskHandler(req) {
|
||||
);
|
||||
}
|
||||
|
||||
const result = createProjectTask(data);
|
||||
// Add user tracking information from authenticated session
|
||||
const taskData = {
|
||||
...data,
|
||||
created_by: req.user?.id || null,
|
||||
// If no assigned_to is specified, default to the creator
|
||||
assigned_to: data.assigned_to || req.user?.id || null,
|
||||
};
|
||||
|
||||
const result = createProjectTask(taskData);
|
||||
return NextResponse.json({ success: true, id: result.lastInsertRowid });
|
||||
} catch (error) {
|
||||
console.error("Error creating project task:", error);
|
||||
return NextResponse.json(
|
||||
{ error: "Failed to create project task" },
|
||||
{ error: "Failed to create project task", details: error.message },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user