-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(contribution-form): find global error manually depending on each…
… fields state
- Loading branch information
Showing
13 changed files
with
115 additions
and
31 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
src/app/content/App/Contribute/ContributeScreen/FormErrors.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import React from 'react'; | ||
import { Error } from 'components/atoms/Forms'; | ||
|
||
export interface FormErrorsProps { | ||
errors: string[]; | ||
globalError: string; | ||
} | ||
|
||
export const FormErrors = ({ errors, globalError }: FormErrorsProps) => { | ||
if (errors.length > 0) { | ||
if (errors.length === 1) { | ||
return <Error>{errors[0]}</Error>; | ||
} | ||
|
||
return <Error>{globalError}</Error>; | ||
} | ||
|
||
return null; | ||
}; | ||
|
||
export default FormErrors; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { FieldState } from 'redux-form'; | ||
|
||
export default interface FormMeta { | ||
[name: string]: FieldState & { [name: string]: FieldState }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { RegisteredFieldState } from 'redux-form'; | ||
|
||
export default (registeredFields: RegisteredFieldState[]) => | ||
Object.keys(registeredFields).map(registeredField => | ||
registeredField.split('.') | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,6 @@ | ||
export { default as createSubmissionError } from './createSubmissionError'; | ||
export { default as FormMeta } from './FormMeta'; | ||
export { | ||
default as getRegisteredFieldsPaths | ||
} from './getRegisteredFieldsPaths'; | ||
export { default as handleFormSubmit } from './handleFormSubmit'; |