'use client'; import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from '@/components/ui/dialog'; import { Button } from '@/components/ui/button'; import { ArrowDown, ArrowUp, Link2, X } from 'lucide-react'; import type { Feature } from '@/store/app-store'; import { cn } from '@/lib/utils'; export type DependencyLinkType = 'parent' | 'child'; interface DependencyLinkDialogProps { open: boolean; onOpenChange: (open: boolean) => void; draggedFeature: Feature | null; targetFeature: Feature | null; onLink: (linkType: DependencyLinkType) => void; } export function DependencyLinkDialog({ open, onOpenChange, draggedFeature, targetFeature, onLink, }: DependencyLinkDialogProps) { if (!draggedFeature || !targetFeature) return null; // Check if a dependency relationship already exists const draggedDependsOnTarget = Array.isArray(draggedFeature.dependencies) && draggedFeature.dependencies.includes(targetFeature.id); const targetDependsOnDragged = Array.isArray(targetFeature.dependencies) && targetFeature.dependencies.includes(draggedFeature.id); const existingLink = draggedDependsOnTarget || targetDependsOnDragged; return ( Link Features Create a dependency relationship between these features.
{/* Dragged feature */}
Dragged Feature
{draggedFeature.description}
{draggedFeature.category}
{/* Arrow indicating direction */}
{/* Target feature */}
Target Feature
{targetFeature.description}
{targetFeature.category}
{/* Existing link warning */} {existingLink && (
{draggedDependsOnTarget ? 'The dragged feature already depends on the target feature.' : 'The target feature already depends on the dragged feature.'}
)}
{/* Set as Parent - top */} {/* Set as Child - middle */} {/* Cancel - bottom */}
); }