Spaces:
Sleeping
Sleeping
Download frontend/src/components/AmendmentHistory.tsx from Smart-Slate/Systematic-tool-review: direct link, hf CLI and curl.
- Browser
- Download file 2.59 kB
-
https://huggingface.co/spaces/Smart-Slate/Systematic-tool-review/resolve/main/frontend/src/components/AmendmentHistory.tsx
- Command line
-
hf download hf://spaces/Smart-Slate/Systematic-tool-review/frontend/src/components/AmendmentHistory.tsx
-
curl -L -o AmendmentHistory.tsx https://huggingface.co/spaces/Smart-Slate/Systematic-tool-review/resolve/main/frontend/src/components/AmendmentHistory.tsx
2.59 kB
| import type { FieldChange, ProtocolAmendment } from "../types"; | |
| import { ALL_SOURCES } from "../types"; | |
| import "./review-fixes.css"; | |
| const FIELD_LABELS: Record<string, string> = { | |
| title: "Title", | |
| population: "Population", | |
| intervention: "Intervention / Exposure", | |
| comparator: "Comparator", | |
| outcome: "Outcome", | |
| intervention_terms: "Exposure search terms", | |
| outcome_terms: "Outcome search terms", | |
| inclusion_criteria: "Inclusion criteria", | |
| exclusion_criteria: "Exclusion criteria", | |
| sources: "Sources", | |
| reviewers_required: "Reviewers per record", | |
| rob_key_questions_observational: "Risk-of-bias key questions (observational)", | |
| rob_key_questions_experimental: "Risk-of-bias key questions (animal & trials)", | |
| rob_criteria: "Risk-of-bias criteria", | |
| }; | |
| function formatValue(field: string, value: unknown): string { | |
| if (value === null || value === undefined || value === "") return "—"; | |
| if (field === "reviewers_required") return value === 2 ? "2 independent reviewers" : "1 reviewer"; | |
| if (field.startsWith("rob_key_questions") && Array.isArray(value)) return value.map((q) => `Q${q}`).join(", "); | |
| if (Array.isArray(value)) { | |
| if (value.length === 0) return "—"; | |
| const items = | |
| field === "sources" | |
| ? value.map((v) => ALL_SOURCES.find((s) => s.value === v)?.label ?? String(v)) | |
| : value.map(String); | |
| return items.join("; "); | |
| } | |
| return String(value); | |
| } | |
| function ChangeLine({ change }: { change: FieldChange }) { | |
| return ( | |
| <li> | |
| <strong>{FIELD_LABELS[change.field] ?? change.field}:</strong>{" "} | |
| <code>{formatValue(change.field, change.before)}</code> →{" "} | |
| <code>{formatValue(change.field, change.after)}</code> | |
| </li> | |
| ); | |
| } | |
| /** Amendments to a locked protocol (PRISMA 2020 item 24c), newest first. */ | |
| export function AmendmentHistory({ amendments }: { amendments: ProtocolAmendment[] }) { | |
| if (amendments.length === 0) return null; | |
| return ( | |
| <div className="amendment-history"> | |
| <h3>Protocol amendments</h3> | |
| <ul className="history-list"> | |
| {[...amendments].reverse().map((a) => ( | |
| <li key={a.version} className="history-item"> | |
| <div> | |
| <strong>Version {a.version}</strong> · {new Date(a.amended_at).toLocaleString()} | |
| </div> | |
| <div className="history-meta">Reason: {a.reason}</div> | |
| <ul className="history-change"> | |
| {a.changes.map((c) => ( | |
| <ChangeLine key={c.field} change={c} /> | |
| ))} | |
| </ul> | |
| </li> | |
| ))} | |
| </ul> | |
| </div> | |
| ); | |
| } | |