mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
fix(challenge modal): user could submit empty answer
This commit is contained in:
@@ -45,6 +45,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 {
|
||||
@@ -112,7 +113,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>
|
||||
)}
|
||||
{challenges.length > 1 && (
|
||||
<button disabled={!challenges[currentChallengeIndex - 1]} onClick={() => setCurrentChallengeIndex((prev) => prev - 1)}>
|
||||
{t('previous')}
|
||||
|
||||
Reference in New Issue
Block a user