Skip to content

Commit

Permalink
fix(challenge modal): user could submit empty answer
Browse files Browse the repository at this point in the history
  • Loading branch information
plebeius-eth committed Jan 24, 2025
1 parent c510345 commit f952044
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/components/challenge-modal/challenge-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const Challenge = ({ challenge, closeModal }: ChallengeProps) => {

const onEnterKey = (e: React.KeyboardEvent<HTMLInputElement>) => {
if (e.key !== 'Enter') return;
if (!answers[currentChallengeIndex]) return;
if (challenges[currentChallengeIndex + 1]) {
setCurrentChallengeIndex((prev) => prev + 1);
} else {
Expand Down Expand Up @@ -80,7 +81,11 @@ const Challenge = ({ challenge, closeModal }: ChallengeProps) => {
<div className={styles.challengeFooter}>
<div className={styles.counter}>{t('challenge_counter', { index: currentChallengeIndex + 1, total: challenges?.length })}</div>
<span className={styles.buttons}>
{!challenges[currentChallengeIndex + 1] && <button onClick={onSubmit}>{t('submit')}</button>}
{!challenges[currentChallengeIndex + 1] && (
<button onClick={onSubmit} disabled={!answers[currentChallengeIndex]}>
{t('submit')}
</button>
)}
<button onClick={closeModal}>{t('cancel')}</button>
{challenges.length > 1 && (
<button disabled={!challenges[currentChallengeIndex - 1]} onClick={() => setCurrentChallengeIndex((prev) => prev - 1)}>
Expand Down

0 comments on commit f952044

Please sign in to comment.