"use client"; import { useState } from "react"; import { Label } from "@/components/ui/label"; import { Input } from "@/components/ui/input"; import { Button } from "@/components/ui/button"; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"; interface TestCase { id: string; input: string; expectedOutput: string; } interface EditTestcasePanelProps { problemId: string; onUpdate?: (data: { content: string; inputs: Array<{ index: number; name: string; value: string }> }) => void; } export const EditTestcasePanel = ({ problemId, }: EditTestcasePanelProps) => { const [testcases, setTestcases] = useState([ { id: "1", input: "input1", expectedOutput: "output1" }, { id: "2", input: "input2", expectedOutput: "output2" } ]); const [newInput, setNewInput] = useState(""); const [newOutput, setNewOutput] = useState(""); const addTestCase = () => { if (!newInput || !newOutput) return; const newTestCase = { id: (testcases.length + 1).toString(), input: newInput, expectedOutput: newOutput }; setTestcases([...testcases, newTestCase]); setNewInput(""); setNewOutput(""); }; const deleteTestCase = (id: string) => { setTestcases(testcases.filter(tc => tc.id !== id)); }; return (
setNewInput(e.target.value)} placeholder="输入测试用例" />
setNewOutput(e.target.value)} placeholder="预期输出" />
编号 输入 预期输出 操作 {testcases.map((tc) => ( {tc.id} {tc.input} {tc.expectedOutput} ))}
); };