Enhance evaluation detail page to support adding new dimension scores if they do not exist; refactor score update logic for improved clarity and maintainability.
All checks were successful
Deploy with Docker Compose / deploy (push) Successful in 1m46s

This commit is contained in:
Julien Froidefond
2026-02-20 10:20:19 +01:00
parent c14a8cc870
commit b257011e8f

View File

@@ -116,9 +116,25 @@ export default function EvaluationDetailPage() {
if (!evaluation) return;
setEvaluation((e) => {
if (!e) return null;
const scores = e.dimensionScores.map((ds) =>
ds.dimensionId === dimensionId ? { ...ds, ...data } : ds
);
const existing = e.dimensionScores.find((ds) => ds.dimensionId === dimensionId);
const dim = e.template?.dimensions?.find((d) => d.id === dimensionId);
const scores = existing
? e.dimensionScores.map((ds) =>
ds.dimensionId === dimensionId ? { ...ds, ...data } : ds
)
: [
...e.dimensionScores,
{
id: `temp-${dimensionId}`,
dimensionId,
score: (data as { score?: number }).score ?? null,
justification: (data as { justification?: string }).justification ?? null,
examplesObserved: (data as { examplesObserved?: string }).examplesObserved ?? null,
confidence: (data as { confidence?: string }).confidence ?? null,
candidateNotes: (data as { candidateNotes?: string }).candidateNotes ?? null,
dimension: dim ?? { id: dimensionId, slug: "", title: "", rubric: "" },
},
];
const next = { ...e, dimensionScores: scores };
if (data.score !== undefined) {
setTimeout(() => handleSave(next, { skipRefresh: true }), 0);