"use client";
import { WorkspaceTree, InitiativeSummary, TodoSummary, IdeaSummary } from "@/core/types";
interface SidebarProps {
workspaceTree: WorkspaceTree | null;
selectedItem: { type: string; name: string; state?: string } | null;
onSelectInitiative: (summary: InitiativeSummary) => void;
onSelectTodo: (summary: TodoSummary) => void;
onSelectIdea: (summary: IdeaSummary) => void;
onCreate: (type: "initiative" | "todo" | "idea") => void;
}
export function Sidebar({
workspaceTree,
selectedItem,
onSelectInitiative,
onSelectTodo,
onSelectIdea,
onCreate,
}: SidebarProps) {
if (!workspaceTree) return null;
const { initiatives, todos, ideas } = workspaceTree;
return (
{/* Scrollable content */}
{/* Active Initiatives */}
onCreate("initiative")}
>
{initiatives.active.map((item) => (
onSelectInitiative(item)}
/>
))}
{/* Backlog Initiatives */}
{initiatives.backlog.map((item) => (
onSelectInitiative(item)}
/>
))}
{/* Completed Initiatives */}
{initiatives.completed.map((item) => (
onSelectInitiative(item)}
/>
))}
{/* Todos */}
onCreate("todo")}
>
{todos.map((item) => (
onSelectTodo(item)}
/>
))}
{/* Ideas */}
onCreate("idea")}
>
{ideas.map((item) => (
onSelectIdea(item)}
/>
))}
);
}
// Section component
interface SectionProps {
title: string;
count: number;
color: "emerald" | "indigo" | "gray" | "amber" | "violet";
collapsed?: boolean;
onAdd?: () => void;
children: React.ReactNode;
}
function Section({ title, count, color, collapsed, onAdd, children }: SectionProps) {
const colorClasses = {
emerald: "bg-emerald-500",
indigo: "bg-indigo-500",
gray: "bg-gray-500",
amber: "bg-amber-500",
violet: "bg-violet-500",
};
return (
{title}
({count})
{onAdd && (
)}
{children}
);
}
// Initiative item
interface InitiativeItemProps {
item: InitiativeSummary;
selected: boolean;
onClick: () => void;
}
function InitiativeItem({ item, selected, onClick }: InitiativeItemProps) {
return (
);
}
// Todo item
interface TodoItemProps {
item: TodoSummary;
selected: boolean;
onClick: () => void;
}
function TodoItem({ item, selected, onClick }: TodoItemProps) {
const priorityColors = {
high: "text-red-500",
medium: "text-yellow-500",
low: "text-green-500",
};
return (
);
}
// Idea item
interface IdeaItemProps {
item: IdeaSummary;
selected: boolean;
onClick: () => void;
}
function IdeaItem({ item, selected, onClick }: IdeaItemProps) {
return (
);
}