Skip to content

Commit

Permalink
fixed isValid
Browse files Browse the repository at this point in the history
  • Loading branch information
mdshamoon committed May 28, 2021
1 parent d6927e9 commit 2a0948f
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/containers/Form/FormLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ export const FormLayout: React.SFC<FormLayoutProps> = ({
let itemUpdatedObject: any = Object.keys(data)[0];
itemUpdatedObject = data[itemUpdatedObject];
const updatedItem = itemUpdatedObject[listItem];
const { isValid } = updatedItem;
const { errors } = itemUpdatedObject;

if (itemUpdatedObject && errors) {
Expand All @@ -176,7 +175,7 @@ export const FormLayout: React.SFC<FormLayoutProps> = ({
} else {
setErrorMessage(client, errors[0]);
}
} else if (typeof isValid === 'boolean' && !isValid) {
} else if (updatedItem && typeof updatedItem.isValid === 'boolean' && !updatedItem.isValid) {
if (customError) {
// this is a custom error for extensions. We need to move this out of this component
const codeErrors = { code: 'Failed to compile code. Please check again' };
Expand Down Expand Up @@ -221,15 +220,15 @@ export const FormLayout: React.SFC<FormLayoutProps> = ({
let itemCreatedObject: any = `create${camelCaseItem}`;
itemCreatedObject = data[itemCreatedObject];
const itemCreated = itemCreatedObject[listItem];
const { isValid } = itemCreated;

const { errors } = itemCreatedObject;
if (errors) {
if (customHandler) {
customHandler(client, errors);
} else {
setErrorMessage(client, errors[0]);
}
} else if (typeof isValid === 'boolean' && !isValid) {
} else if (itemCreated && typeof itemCreated.isValid === 'boolean' && !itemCreated.isValid) {
if (customError) {
const codeErrors = { code: 'Failed to compile code. Please check again' };
customError.setErrors(codeErrors);
Expand Down

0 comments on commit 2a0948f

Please sign in to comment.