import type { Meta, StoryObj } from "@storybook/react-vite"; import { useState } from "react"; import { ChevronRight } from "lucide-react"; import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@/components/ui/collapsible"; import { RoutineListRow, type RoutineListAgentSummary, type RoutineListProjectSummary, type RoutineListRowItem, } from "@/components/RoutineList"; const projectById = new Map([ ["p1", { name: "Board UI", color: "#6366f1" }], ["p2", { name: "Growth", color: "#10b981" }], ]); const agentById = new Map([ ["a1", { name: "CodexCoder", icon: null }], ["a2", { name: "Digest Bot", icon: null }], ]); type Group = { key: string; label: string | null; items: RoutineListRowItem[] }; const GROUPS: Group[] = [ { key: "p1", label: "Board UI", items: [ { id: "r1", title: "Weekly digest", status: "active", projectId: "p1", assigneeAgentId: "a2", lastRun: { triggeredAt: "2026-06-09T08:00:00Z", status: "succeeded" } }, { id: "r2", title: "Triage stale issues", status: "active", projectId: "p1", assigneeAgentId: "a1", lastRun: { triggeredAt: "2026-06-08T08:00:00Z", status: "succeeded" } }, { id: "r3", title: "Nightly changelog draft", status: "paused", projectId: "p1", assigneeAgentId: "a1", lastRun: null }, ], }, { key: "p2", label: "Growth", items: [ { id: "r4", title: "Lead enrichment sweep", status: "active", projectId: "p2", assigneeAgentId: "a1", lastRun: { triggeredAt: "2026-06-09T06:00:00Z", status: "running" } }, { id: "r5", title: "Outbound follow-ups", status: "active", projectId: "p2", assigneeAgentId: "a2", lastRun: { triggeredAt: "2026-06-07T06:00:00Z", status: "failed" } }, ], }, ]; function GroupedList() { const [collapsed, setCollapsed] = useState([]); return (
{GROUPS.map((group) => { const isOpen = !collapsed.includes(group.key); return ( setCollapsed((prev) => (open ? prev.filter((k) => k !== group.key) : [...prev, group.key])) } > {group.label ? (
{group.label} {group.items.length}
) : null} {group.items.map((routine) => ( {}} onToggleEnabled={() => {}} onToggleArchived={() => {}} /> ))}
); })}
); } const meta: Meta = { title: "Product/Routines ยท List (grouped cards)", component: GroupedList, parameters: { layout: "fullscreen" }, }; export default meta; type Story = StoryObj; export const GroupedCards: Story = {};