diff --git a/src/app/page.tsx b/src/app/page.tsx index 0b8c5f0..95c8524 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -12,6 +12,15 @@ interface Props { }; } +const statusSortorder = [ + "active", + "pending", + "waiting", + "recurring", + "completed", + "deleted", +] as const; + async function CmdOutput({ cmd }: { cmd: string }) { try { const { stdout, stderr } = await exec(cmd); @@ -21,11 +30,16 @@ async function CmdOutput({ cmd }: { cmd: string }) { const parsed = taskSchema.array().parse(json); return (
- {_.orderBy(parsed, ["status", "urgency"], ["desc", "desc"]).map( - (task) => ( - - ), - )} + {_.orderBy( + parsed, + [ + (item) => statusSortorder.findIndex((s) => s === item.status), + "urgency", + ], + ["asc", "desc"], + ).map((task) => ( + + ))}
); } catch (e) { diff --git a/src/components/task-card.tsx b/src/components/task-card.tsx index 7725506..11b091d 100644 --- a/src/components/task-card.tsx +++ b/src/components/task-card.tsx @@ -103,7 +103,9 @@ export default function TaskCard({ task }: { task: Task }) { - {task.status === "pending" ? task.urgency.toFixed(2) : task.status} + {["pending", "active"].includes(task.status) + ? task.urgency.toFixed(2) + : task.status}