fix: set update loading state before request

This commit is contained in:
2026-08-03 19:01:04 +01:00
parent 74fc6d1457
commit 3a83944006
2 changed files with 12 additions and 3 deletions
+10 -3
View File
@@ -231,6 +231,16 @@ export default function ScenarioForm() {
const handleUpdate = async (e) => {
e.preventDefault();
// Guard empty answer before showing loading state
if (!answer?.trim()) {
setUpdateStatus("error");
setUpdateError({ error: "Please enter an answer before updating." });
return;
}
setUpdateStatus("loading");
setUpdateError(null);
const submission = await submitAnswerForUpdateCase(fetch, {
situationGraph: result?.situationGraph,
previousQuestion: result?.selectedQuestion,
@@ -243,9 +253,6 @@ export default function ScenarioForm() {
return;
}
setUpdateStatus("loading");
setUpdateError(null);
try {
const outcome = submission.data;