@@ -20,10 +20,12 @@ const statuses = [
2020 { id : 'in_progress' , title : 'In Progress' } ,
2121 { id : 'todo' , title : 'Todo' } ,
2222 { id : 'done' , title : 'Done' } ,
23+ { id : 'failed' , title : 'Failed' } ,
24+ { id : 'not_relevant' , title : 'Not Relevant' } ,
2325] as const ;
2426
2527// Parser for validating StatusId from URL query parameters.
26- const statusIdParser = parseAsStringLiteral < StatusId > ( [ 'in_progress' , 'todo' , 'done' ] ) ;
28+ const statusIdParser = parseAsStringLiteral < StatusId > ( [ 'in_progress' , 'todo' , 'done' , 'failed' , 'not_relevant' ] ) ;
2729
2830/**
2931 * Renders the main task list view, including filtering and drag-and-drop capabilities.
@@ -54,15 +56,21 @@ export function TaskList({
5456 in_progress : [ ] ,
5557 todo : [ ] ,
5658 done : [ ] ,
59+ failed : [ ] ,
60+ not_relevant : [ ] ,
5761 } ;
58- // Sort tasks by the server-provided order before grouping.
59- const sortedTasks = [ ...initialTasks ] . sort ( ( a , b ) => a . order - b . order ) ;
60- for ( const task of sortedTasks ) {
61- // Group tasks into the appropriate status array.
62+ // Group tasks by status first
63+ for ( const task of initialTasks ) {
6264 if ( grouped [ task . status as StatusId ] ) {
6365 grouped [ task . status as StatusId ] . push ( task ) ;
6466 }
6567 }
68+ // Sort each group alphabetically by title (A-Z)
69+ for ( const status in grouped ) {
70+ grouped [ status as StatusId ] . sort ( ( a , b ) =>
71+ a . title . localeCompare ( b . title , undefined , { sensitivity : 'base' } )
72+ ) ;
73+ }
6674 return grouped ;
6775 } , [ initialTasks ] ) ;
6876
@@ -75,32 +83,11 @@ export function TaskList({
7583 hoverIndex,
7684 } ) ;
7785 if ( item . status !== targetStatus && updateTaskStatus !== 'executing' ) {
78- // Find the target group tasks and calculate new order
79- const targetGroup = tasksByStatus [ targetStatus ] || [ ] ;
80- // Find the order of the task we are hovering over (if any)
81- // Note: This assumes tasks are already sorted by order in tasksByStatus
82- const hoverTaskOrder =
83- hoverIndex < targetGroup . length ? targetGroup [ hoverIndex ] . order : null ;
84-
85- let newOrder : number ;
86- if ( hoverTaskOrder !== null ) {
87- // Simple approach: take the order of the hovered item
88- // More complex: calculate midpoint between hoverItem and item before/after
89- newOrder = hoverTaskOrder ;
90- } else {
91- // Dropped at the end, find max order + 1
92- newOrder = targetGroup . length > 0 ? Math . max ( ...targetGroup . map ( ( t ) => t . order ) ) + 1 : 0 ;
93- }
94-
95- // TODO: Update the server action (updateTask) to accept and set the 'order'
96- // For now, just updating status
86+ // Update task status (tasks will be sorted alphabetically on next render)
9787 updateTaskExecute ( {
9888 id : item . id ,
99- status : targetStatus /*, order: newOrder */ ,
89+ status : targetStatus ,
10090 } ) ;
101-
102- // Optional: Re-index orders in the source and target groups if needed
103- // (Requires another server action or more complex update logic)
10491 }
10592 } ,
10693 [ updateTaskExecute , updateTaskStatus , tasksByStatus ] ,
0 commit comments