From 5b9d94583f33795548d37fc890189167713c9a3f Mon Sep 17 00:00:00 2001 From: ks129 <45097959+ks129@users.noreply.github.com> Date: Mon, 18 Jan 2021 11:36:39 +0200 Subject: Provide valid and error message data to TextArea component --- src/components/InputTypes/index.tsx | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/components/InputTypes/index.tsx b/src/components/InputTypes/index.tsx index a597c94..2481d64 100644 --- a/src/components/InputTypes/index.tsx +++ b/src/components/InputTypes/index.tsx @@ -24,6 +24,15 @@ export default function create_input({ question, public_state }: QuestionProp, h // eslint-disable-next-line // @ts-ignore let options: string[] = question.data["options"]; + let valid = true; + if (!public_state.get("valid")) { + valid = false; + } + const rawError = public_state.get("error"); + let error = ""; + if (typeof rawError === "string") { + error = rawError; + } // Catch input types that require options but don't have any if ((options === undefined || typeof options !== "object") && require_options.includes(question.type)) { @@ -34,7 +43,7 @@ export default function create_input({ question, public_state }: QuestionProp, h /* eslint-disable react/react-in-jsx-scope */ switch (question.type) { case QuestionType.TextArea: - result =