create form error component

This commit is contained in:
fernandomg 2020-05-29 21:43:56 -03:00
parent 4de3308069
commit 394a98b424
1 changed files with 27 additions and 0 deletions

View File

@ -0,0 +1,27 @@
import { makeStyles } from '@material-ui/core/styles'
import React from 'react'
import { useFormState } from 'react-final-form'
import Row from 'src/components/layout/Row'
import Paragraph from 'src/components/layout/Paragraph'
import { styles } from 'src/routes/safe/components/Balances/SendModal/screens/ContractInteraction/style'
const useStyles = makeStyles(styles as any)
const FormErrorMessage = () => {
const classes = useStyles()
const { modifiedSinceLastSubmit, submitError } = useFormState({
subscription: { modifiedSinceLastSubmit: true, submitError: true },
})
const hasNewSubmitError = !!submitError && !modifiedSinceLastSubmit
return hasNewSubmitError ? (
<Row align="center" className={classes.fullWidth} margin="xs">
<Paragraph color="error" noMargin size="md" style={{ letterSpacing: '-0.5px' }}>
{submitError}
</Paragraph>
</Row>
) : null
}
export default FormErrorMessage