"use client"; import { useState } from "react"; import { Button } from "@/components/ui/button"; import { Tooltip, TooltipContent, TooltipTrigger, } from "@/components/ui/tooltip"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Plus, X, GripVertical } from "lucide-react"; interface AcceptanceCriteriaEditorProps { criteria: string[]; onChange: (criteria: string[]) => void; error?: string; } export function AcceptanceCriteriaEditor({ criteria, onChange, error, }: AcceptanceCriteriaEditorProps) { const [newCriterion, setNewCriterion] = useState(""); const handleAdd = () => { const trimmed = newCriterion.trim(); if (trimmed && !criteria.includes(trimmed)) { onChange([...criteria, trimmed]); setNewCriterion(""); } }; const handleRemove = (index: number) => { const updated = criteria.filter((_, i) => i !== index); onChange(updated); }; const handleKeyDown = (e: React.KeyboardEvent) => { if (e.key === "Enter") { e.preventDefault(); handleAdd(); } }; const handleUpdate = (index: number, value: string) => { const updated = [...criteria]; updated[index] = value; onChange(updated); }; return (
{criteria.length} item{criteria.length !== 1 ? "s" : ""}
{/* Existing criteria list */} {criteria.length > 0 && (
{criteria.map((criterion, index) => (
{index + 1}. handleUpdate(index, e.target.value)} className="flex-1 h-8" /> Remove this criterion
))}
)} {/* Add new criterion */}
setNewCriterion(e.target.value)} onKeyDown={handleKeyDown} placeholder="Enter acceptance criterion and press Enter..." className="flex-1" />
{/* Helper text */}

Define at least one acceptance criterion. Each criterion should describe a specific, testable condition for task completion.

{/* Error message */} {error &&

{error}

}
); }