Skip to content

Commit b057210

Browse files
committed
chore: merge main into release for new releases
2 parents ac10ba8 + 413b14c commit b057210

File tree

4 files changed

+22
-31
lines changed

4 files changed

+22
-31
lines changed

apps/app/src/app/(app)/[orgId]/tasks/components/TaskCard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export const ItemTypes = {
1414
};
1515

1616
// Type representing valid task status IDs.
17-
export type StatusId = 'todo' | 'in_progress' | 'done';
17+
export type StatusId = 'todo' | 'in_progress' | 'done' | 'failed' | 'not_relevant';
1818

1919
// Interface for the data transferred during drag operations.
2020
export interface DragItem {

apps/app/src/app/(app)/[orgId]/tasks/components/TaskFilterHeader.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use client';
22

33
import { Button } from '@comp/ui/button';
4-
import { Check, Circle, List, Loader2, Plus } from 'lucide-react';
4+
import { Check, Circle, List, Loader2, Plus, X, XCircle } from 'lucide-react';
55
import { useQueryState } from 'nuqs';
66
import React from 'react';
77

@@ -10,6 +10,8 @@ const statuses = [
1010
{ id: 'in_progress', title: 'In Progress' },
1111
{ id: 'todo', title: 'Todo' },
1212
{ id: 'done', title: 'Done' },
13+
{ id: 'failed', title: 'Failed' },
14+
{ id: 'not_relevant', title: 'Not Relevant' },
1315
] as const;
1416
type StatusId = (typeof statuses)[number]['id'];
1517

@@ -32,6 +34,8 @@ export function TaskFilterHeader() {
3234
in_progress: Loader2,
3335
todo: Circle,
3436
done: Check,
37+
failed: XCircle,
38+
not_relevant: X,
3539
};
3640

3741
// Helper function to determine button styling based on active state.

apps/app/src/app/(app)/[orgId]/tasks/components/TaskList.tsx

Lines changed: 15 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -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],

apps/app/src/app/(app)/[orgId]/tasks/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ const getTasks = async (statusParam?: string) => {
6363

6464
const tasks = await db.task.findMany({
6565
where: whereClause,
66-
orderBy: [{ status: 'asc' }, { order: 'asc' }, { createdAt: 'asc' }],
66+
orderBy: [{ status: 'asc' }, { title: 'asc' }],
6767
});
6868
return tasks;
6969
};

0 commit comments

Comments
 (0)