"use client"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { Card, CardContent, CardHeader } from "@/components/ui/card"; import { cn } from "@/lib/utils"; type BoardGoal = { board_type?: string; objective?: string | null; success_metrics?: Record | null; target_date?: string | null; goal_confirmed?: boolean; }; type BoardGoalPanelProps = { board?: BoardGoal | null; onStartOnboarding?: () => void; onEdit?: () => void; }; const formatTargetDate = (value?: string | null) => { if (!value) return "—"; const date = new Date(value); if (Number.isNaN(date.getTime())) return value; return date.toLocaleDateString(undefined, { month: "short", day: "numeric", year: "numeric", }); }; export function BoardGoalPanel({ board, onStartOnboarding, onEdit, }: BoardGoalPanelProps) { const metricsEntries = (() => { if (!board?.success_metrics) return []; if (Array.isArray(board.success_metrics)) { return board.success_metrics.map((value, index) => [ `Metric ${index + 1}`, value, ]); } if (typeof board.success_metrics === "object") { return Object.entries(board.success_metrics); } return [["Metric", board.success_metrics]]; })(); const isGoalBoard = board?.board_type !== "general"; const isConfirmed = Boolean(board?.goal_confirmed); return (

Board goal

{board ? "Mission overview" : "Loading board goal"}

{board ? ( <> {isGoalBoard ? "Goal board" : "General board"} {isGoalBoard ? ( {isConfirmed ? "Confirmed" : "Needs confirmation"} ) : null} ) : null}
{board ? (

{isGoalBoard ? "Track progress against the board objective and keep agents aligned." : "General boards focus on tasks without formal success metrics."}

) : (
)}

Objective

{board?.objective || (isGoalBoard ? "No objective yet." : "Not required.")}

Success metrics

{metricsEntries.length > 0 ? (
    {metricsEntries.map(([key, value]) => (
  • {key}: {String(value)}
  • ))}
) : (

{isGoalBoard ? "No metrics defined yet." : "Not required."}

)}

Target date

{formatTargetDate(board?.target_date)}

{onStartOnboarding || onEdit ? (
{onStartOnboarding && isGoalBoard && !isConfirmed ? ( ) : null} {onEdit ? ( ) : null}
) : null}
); } export default BoardGoalPanel;