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
All checks were successful
Deploy with Docker Compose / deploy (push) Successful in 1m46s
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user