import React from "react"; import { Link } from "react-router-dom"; import { ArrowRightIcon } from "../../icons"; import Button from "../ui/button/Button"; export interface RelationshipData { taskId: number; taskTitle: string; clusterId?: number | null; clusterName?: string | null; ideaId?: number | null; ideaTitle?: string | null; keywordIds?: number[]; keywordNames?: string[]; } interface RelationshipMapProps { task: RelationshipData; onNavigate?: (type: "cluster" | "idea" | "keyword", id: number) => void; className?: string; } const RelationshipMap: React.FC = ({ task, onNavigate, className = "", }) => { const hasRelationships = task.clusterId || task.ideaId || (task.keywordIds && task.keywordIds.length > 0); if (!hasRelationships) { return (
No relationships mapped
); } return (
{/* Keywords → Cluster → Idea → Task Flow */}
{/* Keywords */} {task.keywordIds && task.keywordIds.length > 0 && ( <>
{task.keywordNames?.slice(0, 3).map((keyword, idx) => ( ))} {task.keywordIds.length > 3 && ( +{task.keywordIds.length - 3} )}
{task.clusterId && } )} {/* Cluster */} {task.clusterId && ( <> { if (onNavigate) { e.preventDefault(); onNavigate("cluster", task.clusterId!); } }} className="px-2 py-0.5 rounded bg-brand-50 dark:bg-brand-500/15 text-brand-600 dark:text-brand-400 hover:bg-brand-100 dark:hover:bg-brand-500/25 transition-colors font-medium" > {task.clusterName || `Cluster #${task.clusterId}`} {task.ideaId && } )} {/* Idea */} {task.ideaId && ( <> { if (onNavigate) { e.preventDefault(); onNavigate("idea", task.ideaId!); } }} className="px-2 py-0.5 rounded bg-success-50 dark:bg-success-500/15 text-success-600 dark:text-success-400 hover:bg-success-100 dark:hover:bg-success-500/25 transition-colors font-medium" > {task.ideaTitle || `Idea #${task.ideaId}`} )} {/* Task (current) */} Task
{/* Relationship Summary */}
{task.clusterId && ( Cluster: {task.clusterName || `#${task.clusterId}`} )} {task.ideaId && ( Idea: {task.ideaTitle || `#${task.ideaId}`} )} {task.keywordIds && task.keywordIds.length > 0 && ( Keywords: {task.keywordIds.length} )}
); }; export default RelationshipMap;