From aecac5c2148aaa6a58b0aaf3a32a02ce3f2fee2f Mon Sep 17 00:00:00 2001 From: Farhanam76 Date: Tue, 30 Apr 2024 11:03:40 +0100 Subject: [PATCH 1/3] fixed the bug issue which now displays the validation message --- .../App/page/Design/answers/BasicAnswer/index.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/eq-author/src/App/page/Design/answers/BasicAnswer/index.js b/eq-author/src/App/page/Design/answers/BasicAnswer/index.js index 842e129e71..920870bda4 100644 --- a/eq-author/src/App/page/Design/answers/BasicAnswer/index.js +++ b/eq-author/src/App/page/Design/answers/BasicAnswer/index.js @@ -57,8 +57,11 @@ import ValidationError from "components/ValidationError"; import gql from "graphql-tag"; import RichTextEditor from "components/RichTextEditor"; -const { PIPING_TITLE_DELETED, ERR_VALID_PIPED_ANSWER_REQUIRED } = - richTextEditorErrors; +const { + PIPING_TITLE_DELETED, + ERR_VALID_PIPED_ANSWER_REQUIRED, + PIPING_TITLE_MOVED, +} = richTextEditorErrors; const Caption = styled.div` margin-bottom: 0.2em; @@ -150,9 +153,14 @@ export const StatelessBasicAnswer = ({ if (error.errorCode === "PIPING_TITLE_DELETED") { message = PIPING_TITLE_DELETED.message; } + if (error.errorCode === "PIPING_TITLE_MOVED") { + message = PIPING_TITLE_MOVED.message; + } return ( error.field === "label" && ( - {message} + + {PIPING_TITLE_MOVED.message} + ) ); })} From 11c5bcae23ceba0cec825aca870b169f61235d0a Mon Sep 17 00:00:00 2001 From: Farhanam76 Date: Tue, 30 Apr 2024 11:17:26 +0100 Subject: [PATCH 2/3] updated code --- eq-author/src/App/page/Design/answers/BasicAnswer/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eq-author/src/App/page/Design/answers/BasicAnswer/index.js b/eq-author/src/App/page/Design/answers/BasicAnswer/index.js index 920870bda4..8ec2cc671d 100644 --- a/eq-author/src/App/page/Design/answers/BasicAnswer/index.js +++ b/eq-author/src/App/page/Design/answers/BasicAnswer/index.js @@ -158,8 +158,8 @@ export const StatelessBasicAnswer = ({ } return ( error.field === "label" && ( - - {PIPING_TITLE_MOVED.message} + + {message} ) ); From 4131aefd52acbd17d2da564dd19ef3e8cef0f575 Mon Sep 17 00:00:00 2001 From: Farhanam76 Date: Tue, 30 Apr 2024 15:21:25 +0100 Subject: [PATCH 3/3] Changed the if statments to case statements --- .../page/Design/answers/BasicAnswer/index.js | 41 ++++++++++--------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/eq-author/src/App/page/Design/answers/BasicAnswer/index.js b/eq-author/src/App/page/Design/answers/BasicAnswer/index.js index 8ec2cc671d..de7502c73d 100644 --- a/eq-author/src/App/page/Design/answers/BasicAnswer/index.js +++ b/eq-author/src/App/page/Design/answers/BasicAnswer/index.js @@ -139,28 +139,31 @@ export const StatelessBasicAnswer = ({ {answer.validationErrorInfo?.errors?.map((error) => { let message; - if (error.errorCode === "ERR_VALID_REQUIRED") { - message = buildLabelError( - MISSING_LABEL, - `${lowerCase(type)}`, - 8, - 7 - ); - } - if (error.errorCode === "ERR_VALID_PIPED_ANSWER_REQUIRED") { - message = ERR_VALID_PIPED_ANSWER_REQUIRED.message; - } - if (error.errorCode === "PIPING_TITLE_DELETED") { - message = PIPING_TITLE_DELETED.message; - } - if (error.errorCode === "PIPING_TITLE_MOVED") { - message = PIPING_TITLE_MOVED.message; + switch (error.errorCode) { + case "ERR_VALID_REQUIRED": + message = buildLabelError( + MISSING_LABEL, + `${lowerCase(type)}`, + 8, + 7 + ); + break; + case "ERR_VALID_PIPED_ANSWER_REQUIRED": + message = ERR_VALID_PIPED_ANSWER_REQUIRED.message; + break; + case "PIPING_TITLE_DELETED": + message = PIPING_TITLE_DELETED.message; + break; + case "PIPING_TITLE_MOVED": + message = PIPING_TITLE_MOVED.message; + break; + default: + message = ""; } + return ( error.field === "label" && ( - - {message} - + {message} ) ); })}