From 752c76fa9da1456b39144ca72b8ca816b285cdb3 Mon Sep 17 00:00:00 2001 From: Louis Knight-Webb Date: Sun, 15 Jun 2025 11:16:49 -0400 Subject: [PATCH] Add review column --- .../migrations/003_add_inreview_status.sql | 2 + backend/src/models/task.rs | 2 + frontend/src/pages/project-tasks.tsx | 60 ++++++++++++------- shared/types.ts | 2 +- 4 files changed, 42 insertions(+), 24 deletions(-) create mode 100644 backend/migrations/003_add_inreview_status.sql diff --git a/backend/migrations/003_add_inreview_status.sql b/backend/migrations/003_add_inreview_status.sql new file mode 100644 index 00000000..7fe9d1fe --- /dev/null +++ b/backend/migrations/003_add_inreview_status.sql @@ -0,0 +1,2 @@ +-- Add 'inreview' to task_status enum +ALTER TYPE task_status ADD VALUE 'inreview'; diff --git a/backend/src/models/task.rs b/backend/src/models/task.rs index 2f0c98ac..b96cad4b 100644 --- a/backend/src/models/task.rs +++ b/backend/src/models/task.rs @@ -6,10 +6,12 @@ use uuid::Uuid; #[derive(Debug, Clone, Type, Serialize, Deserialize, PartialEq, TS)] #[sqlx(type_name = "task_status", rename_all = "lowercase")] +#[serde(rename_all = "lowercase")] #[ts(export)] pub enum TaskStatus { Todo, InProgress, + InReview, Done, Cancelled, } diff --git a/frontend/src/pages/project-tasks.tsx b/frontend/src/pages/project-tasks.tsx index ff4d4123..125ea705 100644 --- a/frontend/src/pages/project-tasks.tsx +++ b/frontend/src/pages/project-tasks.tsx @@ -34,13 +34,14 @@ import { KanbanCard, type DragEndEvent } from '@/components/ui/shadcn-io/kanban' +import type { TaskStatus } from '../../../shared/types' interface Task { id: string project_id: string title: string description: string | null - status: 'Todo' | 'InProgress' | 'Done' | 'Cancelled' + status: TaskStatus created_at: string updated_at: string } @@ -61,18 +62,23 @@ interface ApiResponse { -const statusLabels = { - Todo: 'To Do', - InProgress: 'In Progress', - Done: 'Done', - Cancelled: 'Cancelled' +// All possible task statuses from shared types +const allTaskStatuses: TaskStatus[] = ['todo', 'inprogress', 'inreview', 'done', 'cancelled'] + +const statusLabels: Record = { + todo: 'To Do', + inprogress: 'In Progress', + inreview: 'In Review', + done: 'Done', + cancelled: 'Cancelled' } -const statusBoardColors = { - Todo: '#64748b', - InProgress: '#3b82f6', - Done: '#22c55e', - Cancelled: '#ef4444' +const statusBoardColors: Record = { + todo: '#64748b', + inprogress: '#3b82f6', + inreview: '#f59e0b', + done: '#22c55e', + cancelled: '#ef4444' } export function ProjectTasks() { @@ -91,7 +97,7 @@ export function ProjectTasks() { const [newTaskDescription, setNewTaskDescription] = useState('') const [editTaskTitle, setEditTaskTitle] = useState('') const [editTaskDescription, setEditTaskDescription] = useState('') - const [editTaskStatus, setEditTaskStatus] = useState('Todo') + const [editTaskStatus, setEditTaskStatus] = useState('todo') useEffect(() => { if (projectId) { @@ -276,15 +282,22 @@ export function ProjectTasks() { } const groupTasksByStatus = () => { - const groups: Record = { - Todo: [], - InProgress: [], - Done: [], - Cancelled: [] - } + const groups: Record = {} as Record + + // Initialize groups for all possible statuses + allTaskStatuses.forEach(status => { + groups[status] = [] + }) tasks.forEach(task => { - groups[task.status].push(task) + // Convert old capitalized status to lowercase if needed + const normalizedStatus = task.status.toLowerCase() as TaskStatus + if (groups[normalizedStatus]) { + groups[normalizedStatus].push(task) + } else { + // Default to todo if status doesn't match any expected value + groups['todo'].push(task) + } }) return groups @@ -494,10 +507,11 @@ export function ProjectTasks() { - To Do - In Progress - Done - Cancelled + To Do + In Progress + In Review + Done + Cancelled diff --git a/shared/types.ts b/shared/types.ts index 5eba33ea..3a83185d 100644 --- a/shared/types.ts +++ b/shared/types.ts @@ -13,7 +13,7 @@ type CreateTask = { project_id: string, title: string, description: string | nul type Task = { id: string, project_id: string, title: string, description: string | null, status: TaskStatus, created_at: string, updated_at: string, }; -type TaskStatus = "Todo" | "InProgress" | "Done" | "Cancelled"; +type TaskStatus = "todo" | "inprogress" | "inreview" | "done" | "cancelled"; type UpdateTask = { title: string | null, description: string | null, status: TaskStatus | null, };