Skip to content

Commit

Permalink
Merge pull request #3111 from ONSdigital/EAR-2397-Validation-message-…
Browse files Browse the repository at this point in the history
…not-displaying

EAR-2397-Validation-message-is-not-displaying
  • Loading branch information
sanjeevz3009 authored Oct 14, 2024
2 parents 88d1365 + a2431af commit e974c7e
Showing 1 changed file with 26 additions and 15 deletions.
41 changes: 26 additions & 15 deletions eq-author/src/App/page/Design/answers/BasicAnswer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -136,20 +139,28 @@ 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;
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" && (
<ValidationError key={error.id}>{message}</ValidationError>
Expand Down

0 comments on commit e974c7e

Please sign in to comment.