Skip to content

Commit

Permalink
Fix bug where alert pop up would stay permanently after triggering tw…
Browse files Browse the repository at this point in the history
…ice before can disappear
  • Loading branch information
chdonncha committed Apr 11, 2024
1 parent b389458 commit 15f41b0
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions front-end/src/pages/KanaQuiz.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -199,27 +199,26 @@ export const KanaQuiz = () => {
}

function messageHelper(Correct: any, Incorrect: any, EmptyInput: any) {
if (!Correct && !Incorrect && !EmptyInput) {
setShowAlert(false);
}
setShowCorrect(Correct);
setShowIncorrect(Incorrect);
setShowEmptyInput(EmptyInput);

if (Correct) {
setShowAlert(true);
setShowCorrect(Correct);
setAlertMessage('Correct!');
setAlertVariant('success');
}
if (Incorrect) {
setShowAlert(true);
setShowIncorrect(Incorrect);
} else if (Incorrect) {
setAlertMessage('Incorrect Answer!');
setAlertVariant('danger');
}
if (EmptyInput) {
setShowAlert(true);
setShowEmptyInput(EmptyInput);
} else if (EmptyInput) {
setAlertMessage('Cannot leave input empty');
setAlertVariant('danger');
}

setShowAlert(true);

setTimeout(() => {
setShowAlert(false);
}, 1000);
}

function clearAllMessages() {
Expand Down

0 comments on commit 15f41b0

Please sign in to comment.