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 (
{sub.hypothesis}
)} {status}