-
-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/Required questions #185
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
<AnswerTableRow key={answer.id} answer={answer} /> | ||
)) | ||
) : ( | ||
<div className="mb-4 mt-5">no answers yet</div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
translation
onClick={onAnswerChange} | ||
/> | ||
))} | ||
</div> | ||
{isSubmitted && !answer && ( | ||
{isSubmitted && !answer && isRequired && ( | ||
<p className="mt-4 text-sm text-red-500">Please select an answer</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
translation
}: TextAnswersComponentProps) { | ||
const onAnswerChange = (e: ChangeEvent<HTMLInputElement>) => { | ||
e.preventDefault(); | ||
handleAnswerChange(e.target.value, questionId); | ||
}; | ||
|
||
const getAnswerError = () => { | ||
if ((!answer || answer?.trim() === '') && isSubmitted) { | ||
if ((!answer || answer?.trim() === '') && isSubmitted && isRequired) { | ||
return 'Answer is required'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
translation
<div className="flex flex-col items-start gap-2 sm:flex-row sm:gap-4"> | ||
<div className="w-full grow"> | ||
<Input | ||
placeholder="Question..." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
translation
<div className="flex w-full justify-center sm:w-auto"> | ||
<Toggle | ||
classNames="sm:mt-4" | ||
label="Required" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
translation
@@ -80,5 +80,7 @@ export default function BarChart({ data }: BarChartProps) { | |||
</Chart> | |||
</ResponsiveContainer> | |||
</div> | |||
) : null; | |||
) : ( | |||
<div className="mb-4 mt-5">no answers yet</div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
translation
} | ||
|
||
if (!areQuestionsValid(questions)) { | ||
toast.error(t('Fill missing fields')); | ||
return; | ||
toast.error(t('Fill required fields')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
translation
return; | ||
} else { | ||
setIsSubmitted(false); | ||
toast.error(t('Fill required fields')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
translation
(question) => !question.answer || question.answer?.trim() === '' | ||
) | ||
) { | ||
toast.error(t('Fill at least one field')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
translation
No description provided.