diff --git a/src/features/surveys/managers/surveyAnswerManager.ts b/src/features/surveys/managers/surveyAnswerManager.ts index 02e41de3..879d7914 100644 --- a/src/features/surveys/managers/surveyAnswerManager.ts +++ b/src/features/surveys/managers/surveyAnswerManager.ts @@ -6,7 +6,7 @@ import { db } from 'firebaseConfiguration'; export const useSurveyAnswerManager = () => { const router = useRouter(); - + const [showEmojiError, setShowEmojiError] = useState(false); const { surveyId } = router.query as { surveyId: string }; const [question, setQuestion] = useState(''); @@ -39,11 +39,18 @@ export const useSurveyAnswerManager = () => { const handleIconClick = (icon: string) => { setSelectedIcon(icon); + setShowEmojiError(false); }; const handleSave = async () => { - setButtonDisable(true); - setIsAnswering(true); + if (!selectedIcon) { + setShowEmojiError(true); + return; + } else { + setShowEmojiError(false); + setButtonDisable(true); + setIsAnswering(true); + } try { if (!surveyId) { @@ -80,5 +87,6 @@ export const useSurveyAnswerManager = () => { buttonDisable, handleSave, isAnswering, + showEmojiError, }; }; diff --git a/src/pages/survey/[surveyId]/index.tsx b/src/pages/survey/[surveyId]/index.tsx index 284bc501..008cb749 100644 --- a/src/pages/survey/[surveyId]/index.tsx +++ b/src/pages/survey/[surveyId]/index.tsx @@ -17,9 +17,9 @@ function AnswerPage() { handleIconClick, answer, handleInputAnswer, - buttonDisable, handleSave, isAnswering, + showEmojiError, } = useSurveyAnswerManager(); return ( @@ -43,6 +43,8 @@ function AnswerPage() { /> ))} + {showEmojiError && ( +
Please select an emoji before sending.
)}