"use client"; import Link from "next/link"; import { Badge } from "@kandev/ui/badge"; import { StatusIcon } from "@/app/office/tasks/[id]/status-icon"; import { topoSort } from "./workflow-sort"; import type { Task } from "@/app/office/tasks/[id]/types"; import type { TreeHold } from "@/lib/api/domains/tree-api"; type SubtaskStepperProps = { items: Task["children"]; activeHold: TreeHold | null; }; export function SubtaskStepper({ items, activeHold }: SubtaskStepperProps) { if (items.length === 0) return null; const sorted = topoSort(items); const completedIds = new Set( items .filter((i) => { const s = i.status?.toLowerCase(); return s === "done" || s === "completed" || s === "cancelled"; }) .map((i) => i.id), ); const holdLabel = activeHold?.mode === "pause" ? "Paused" : "Cancelled (tree)"; return (

Sub-tasks

{sorted.map((child, idx) => { const pendingBlockers = (child.blockedBy ?? []).filter((b) => !completedIds.has(b)); const isBlocked = pendingBlockers.length > 0; let dotClass = "bg-background border-border"; if (completedIds.has(child.id)) { dotClass = "bg-primary border-primary text-primary-foreground"; } else if (isBlocked) { dotClass = "bg-muted border-muted-foreground/30"; } return (
{completedIds.has(child.id) ? "✓" : idx + 1}
{child.identifier} {child.title} {isBlocked && ( Blocked )} {activeHold && !isBlocked && ( {holdLabel} )}
); })}
); }