Skip to content
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

Merged
merged 2 commits into from
Jun 4, 2023
Merged

Feature/Required questions #185

merged 2 commits into from
Jun 4, 2023

Conversation

Ryczko
Copy link
Owner

@Ryczko Ryczko commented Jun 2, 2023

No description provided.

@vercel
Copy link

vercel bot commented Jun 2, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
formslab ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 4, 2023 9:54am

@Ryczko Ryczko temporarily deployed to preview June 2, 2023 15:22 — with GitHub Actions Inactive
@Ryczko Ryczko linked an issue Jun 2, 2023 that may be closed by this pull request
<AnswerTableRow key={answer.id} answer={answer} />
))
) : (
<div className="mb-4 mt-5">no answers yet</div>
Copy link
Collaborator

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>
Copy link
Collaborator

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';
Copy link
Collaborator

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..."
Copy link
Collaborator

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"
Copy link
Collaborator

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>
Copy link
Collaborator

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'));
Copy link
Collaborator

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'));
Copy link
Collaborator

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'));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

translation

@pmatyjasik pmatyjasik self-requested a review June 3, 2023 13:54
@Ryczko Ryczko temporarily deployed to preview June 4, 2023 09:53 — with GitHub Actions Inactive
@Ryczko Ryczko merged commit f327ff0 into dev Jun 4, 2023
@Ryczko Ryczko deleted the required-questions branch June 4, 2023 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Option to create optional text question
2 participants