Skip to content

Commit

Permalink
fix: Error Handle API
Browse files Browse the repository at this point in the history
  • Loading branch information
yasithranusha committed May 20, 2024
1 parent d30906d commit c778aed
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions src/components/puzzle/dialog/dialogContent/ClueAnswerInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,23 @@ const ClueAnswerInput = () => {
newCellValues[cellKeys[i]] =
values.answer[i] === "_" ? "" : values?.answer[i]?.toUpperCase();
}
const res = await updateCrossword(newCellValues);
if (res?.status === 401) {
router.push("/login");
}
if (res?.status === 200) {
dispatch(updatePuzzle(res?.data?.boxes));
router.replace("/play");
dispatch(closePuzzleDialog());
toast({
title: "Update Successful",
description: "Your answer was submitted successfully.",
});
try {
const res = await updateCrossword(newCellValues);
if (res?.status === 401) {
router.push("/login");
}
if (res?.status === 200) {
dispatch(updatePuzzle(res?.data?.boxes));
router.replace("/play");
dispatch(closePuzzleDialog());
toast({
title: "Update Successful",
description: "Your answer was submitted successfully.",
});
setIsLoading(false);
}
} catch (e) {
console.error(e);
setIsLoading(false);
}
}
Expand Down

0 comments on commit c778aed

Please sign in to comment.