import { useState } from "react"; import type { SubExperiment } from "../types"; import { experimentsApi } from "../api"; import Markdown from "./Markdown"; interface Props { sub: SubExperiment; experimentName: string; onBack: () => void; onRefresh: () => void; } export default function SubExperimentView({ sub, experimentName, onBack, onRefresh }: Props) { const [editing, setEditing] = useState(false); const [content, setContent] = useState(sub.content_md || ""); const [hypothesis, setHypothesis] = useState(sub.hypothesis || ""); const [status, setStatus] = useState(sub.status || "active"); const [saving, setSaving] = useState(false); const handleSave = async () => { setSaving(true); try { await experimentsApi.updateSub(sub.experiment_id, sub.id, { content_md: content, hypothesis, status, }); setEditing(false); onRefresh(); } finally { setSaving(false); } }; return (
{/* Breadcrumb + header */}
/ {sub.name}

{sub.name}

{editing ? (
setHypothesis(e.target.value)} placeholder="Hypothesis" className="bg-gray-900 text-gray-200 text-sm rounded px-2 py-1 border border-gray-700 outline-none flex-1" />
) : (
{sub.hypothesis && (

{sub.hypothesis}

)} {status}
)}
{editing ? ( <> ) : ( )}
{/* Content */}
{editing ? (