Implement collapse functionality in EvaluationDetailPage and DimensionCard components, allowing users to collapse all dimension cards simultaneously for improved usability and organization.

This commit is contained in:
Julien Froidefond
2026-02-20 11:57:18 +01:00
parent 7a0cf76c18
commit edb8125e56
2 changed files with 34 additions and 8 deletions

View File

@@ -51,6 +51,8 @@ interface DimensionCardProps {
index: number;
evaluationId?: string;
onScoreChange: (dimensionId: string, data: Partial<DimensionScore>) => void;
/** Increment to collapse this card (e.g. from "Tout fermer" button) */
collapseAllTrigger?: number;
}
function parseRubric(rubric: string): string[] {
@@ -76,7 +78,7 @@ function parseQuestions(s: string | null | undefined): string[] {
const inputClass =
"w-full rounded border border-zinc-300 dark:border-zinc-600 bg-white dark:bg-zinc-700/80 px-2.5 py-1.5 text-sm text-zinc-900 dark:text-zinc-100 placeholder-zinc-400 dark:placeholder-zinc-500 focus:border-cyan-500 focus:ring-1 focus:ring-cyan-500/30";
export function DimensionCard({ dimension, score, index, evaluationId, onScoreChange }: DimensionCardProps) {
export function DimensionCard({ dimension, score, index, evaluationId, onScoreChange, collapseAllTrigger }: DimensionCardProps) {
const [notes, setNotes] = useState(score?.candidateNotes ?? "");
const hasQuestions = parseQuestions(dimension.suggestedQuestions).length > 0;
const [expanded, setExpanded] = useState(hasQuestions);
@@ -88,6 +90,13 @@ export function DimensionCard({ dimension, score, index, evaluationId, onScoreCh
}
}, [evaluationId, dimension.id]);
useEffect(() => {
if (collapseAllTrigger != null && collapseAllTrigger > 0) {
setExpanded(false);
if (evaluationId) setStoredExpanded(evaluationId, dimension.id, false);
}
}, [collapseAllTrigger, evaluationId, dimension.id]);
const toggleExpanded = () => {
setExpanded((e) => {
const next = !e;