From c6e76414e3fb9f3410b100d2ccb30ba373eba2c1 Mon Sep 17 00:00:00 2001 From: simo <49877847+saimouu@users.noreply.github.com> Date: Fri, 13 Mar 2026 14:11:07 +0200 Subject: [PATCH] Change manual evaluation human result adding to use redux Fixes bug with papers not showing in few-shot modal before refreshing the page. --- .../src/components/ManualEvaluationModal.tsx | 43 +++++++++---------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/client/src/components/ManualEvaluationModal.tsx b/client/src/components/ManualEvaluationModal.tsx index 68a0804..50b01bd 100644 --- a/client/src/components/ManualEvaluationModal.tsx +++ b/client/src/components/ManualEvaluationModal.tsx @@ -10,7 +10,6 @@ import { Check, CircleQuestionMark, CircleX, X } from "lucide-react"; import { LlmModelCard } from "./LlmModelCard"; import { CriteriaList } from "./CriteriaList"; import { Button } from "./Button"; -import { addPaperHumanResult } from "../services/paperService"; import { JobTaskHumanResult, JobTaskStatus, @@ -19,8 +18,9 @@ import { } from "../state/types"; import axios from "axios"; import { AlertMessage } from "./AlertMessage"; +import { useTypedStoreActions } from "../state/store"; -type JobTaskHumanResult = "INCLUDE" | "EXCLUDE" | "UNSURE"; +// type JobTaskHumanResult = "INCLUDE" | "EXCLUDE" | "UNSURE"; type LLMResult = { overall_decision: { @@ -87,19 +87,18 @@ export const ManualEvaluationModal: React.FC = ({ [], ); - // TODO: Refactor this to use redux - const addHumanResult = useCallback( - async (humanResult: JobTaskHumanResult) => { - if (!paperUuid) return; - try { - await addPaperHumanResult(paperUuid, humanResult); - onEvaluated(); - } catch (error) { - console.error("Error adding human result:", error); - } - }, - [paperUuid, onEvaluated], - ); + const addHumanResult = useTypedStoreActions((actions) => actions.addHumanResult) + + const handleAddHumanResult = useCallback((humanResult: JobTaskHumanResult) => { + if (!paperUuid || !currentPaper) return; + + try { + addHumanResult({projectUuid: currentPaper.project_uuid, paperUuid, humanResult}); + onEvaluated(); + } catch (error) { + console.error("Error adding human result:", error); + } + }, [paperUuid, currentPaper, onEvaluated, addHumanResult]) // TODO: Refactor this to use Redux const getModelSuggestions = useCallback(async (paperUuid: string) => { @@ -143,23 +142,23 @@ export const ManualEvaluationModal: React.FC = ({ useEffect(() => { const handleKeyDown = (e: KeyboardEvent) => { if (e.key === "y" || e.key === "Y" || e.key === "i" || e.key === "I") { - addHumanResult(JobTaskHumanResult.INCLUDE); + handleAddHumanResult(JobTaskHumanResult.INCLUDE); } else if (e.key === "u" || e.key === "U") { - addHumanResult(JobTaskHumanResult.UNSURE); + handleAddHumanResult(JobTaskHumanResult.UNSURE); } else if ( e.key === "n" || e.key === "N" || e.key === "e" || e.key === "E" ) { - addHumanResult(JobTaskHumanResult.EXCLUDE); + handleAddHumanResult(JobTaskHumanResult.EXCLUDE); } else if (e.key === "Escape") { onClose(); } }; window.addEventListener("keydown", handleKeyDown); return () => window.removeEventListener("keydown", handleKeyDown); - }, [addHumanResult, onClose]); + }, [handleAddHumanResult, onClose]); if (!currentPaper) return null; @@ -231,7 +230,7 @@ export const ManualEvaluationModal: React.FC = ({