| // src/components/data-hub/PreregistrationForm.tsx | |
| import { useState } from "react"; | |
| import { usePreregistration } from "@/hooks/usePreregistration"; | |
| import { FileCheck, Send, Eye, Plus, Loader2 } from "lucide-react"; | |
| import { PreregistrationPreview } from "./PreregistrationPreview"; | |
| import type { PreregistrationTemplate } from "@/types/data-hub"; | |
| const TEMPLATE_OPTIONS: { value: PreregistrationTemplate; label: string }[] = [ | |
| { value: "osf-standard", label: "OSF Standard Pre-Data Collection" }, | |
| { value: "aspredicted", label: "AsPredicted" }, | |
| { value: "clinical-trials", label: "Clinical Trials" }, | |
| { value: "qualitative", label: "Qualitative Research" }, | |
| ]; | |
| export function PreregistrationForm() { | |
| const { draft, createDraft, updateSection, submitPreregistration } = usePreregistration(); | |
| const [title, setTitle] = useState(""); | |
| const [template, setTemplate] = useState<PreregistrationTemplate>("osf-standard"); | |
| const [showPreview, setShowPreview] = useState(false); | |
| const handleCreate = () => { | |
| if (!title.trim()) return; | |
| createDraft(template, title.trim()); | |
| }; | |
| return ( | |
| <div className="space-y-4"> | |
| <h2 className="text-xl font-bold flex items-center gap-2"><FileCheck className="w-5 h-5 text-primary"/> Preregistration</h2> | |
| {!draft ? ( | |
| <div className="glass rounded-xl p-6 space-y-4 max-w-lg"> | |
| <p className="text-sm text-gray-500">Create a time‑stamped, immutable, citable preregistration of your study design.</p> | |
| <input type="text" value={title} onChange={e => setTitle(e.target.value)} placeholder="Study title" className="input" /> | |
| <select aria-label="Select option" value={template} onChange={e => setTemplate(e.target.value as PreregistrationTemplate)} className="input"> | |
| {TEMPLATE_OPTIONS.map(o => <option key={o.value} value={o.value}>{o.label}</option>)} | |
| </select> | |
| <button onClick={handleCreate} disabled={!title.trim()} className="btn btn-primary w-full gap-2"> | |
| <Plus className="w-4 h-4"/> Start Preregistration | |
| </button> | |
| </div> | |
| ) : ( | |
| <div className="space-y-4"> | |
| <div className="flex items-center justify-between"> | |
| <h3 className="font-bold">{draft.title}</h3> | |
| <div className="flex gap-2"> | |
| <button onClick={() => setShowPreview(!showPreview)} className="btn btn-ghost btn-sm gap-1"><Eye className="w-4 h-4"/> Preview</button> | |
| <button onClick={submitPreregistration} className="btn btn-primary btn-sm gap-1"><Send className="w-4 h-4"/> Submit & Get DOI</button> | |
| </div> | |
| </div> | |
| <div className="space-y-4"> | |
| {draft.sections.map(section => ( | |
| <div key={section.id} className="glass rounded-xl p-4"> | |
| <h4 className="font-semibold text-sm">{section.title} {section.required && <span className="text-red-500">*</span>}</h4> | |
| <p className="text-xs text-gray-500 mb-2">{section.description}</p> | |
| <textarea | |
| value={section.content} | |
| onChange={e => updateSection(section.id, e.target.value)} | |
| placeholder="Write your plan here..." | |
| rows={3} | |
| className="input text-sm" | |
| /> | |
| </div> | |
| ))} | |
| </div> | |
| </div> | |
| )} | |
| {showPreview && draft && <PreregistrationPreview prereg={draft} onClose={() => setShowPreview(false)} />} | |
| </div> | |
| ); | |
| } |
Xet Storage Details
- Size:
- 3.51 kB
- Xet hash:
- 09c832ef519698d82bccfeec9b23dd9398d5ede63c36c6d07e9b3e0f779c0f9c
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.