show validation error

This commit is contained in:
mmv 2019-06-18 16:49:50 +04:00
parent 72c8611cc5
commit f20a9602f4
4 changed files with 41 additions and 22 deletions

View File

@ -18,9 +18,10 @@ const SelectInput = ({
formControlProps, formControlProps,
classes, classes,
renderValue, renderValue,
disableError,
...rest ...rest
}: SelectFieldProps) => { }: SelectFieldProps) => {
const showError = ((meta.submitError && !meta.dirtySinceLastSubmit) || meta.error) && meta.touched const showError = ((meta.submitError && !meta.dirtySinceLastSubmit) || meta.error) && meta.touched && !disableError
const inputProps = { const inputProps = {
...restInput, ...restInput,
name, name,

View File

@ -66,20 +66,29 @@ const ChangeThreshold = ({
Any transaction over any daily limit requires the confirmation of: Any transaction over any daily limit requires the confirmation of:
</Paragraph> </Paragraph>
</Row> </Row>
<Row margin="xl" align="center"> <Row margin="xl" align="center" className={classes.inputRow}>
<Col xs={2}> <Col xs={2}>
<Field <Field
name={THRESHOLD_FIELD_NAME} name={THRESHOLD_FIELD_NAME}
component={SelectField} render={props => (
validate={composeValidators(required, mustBeInteger, minValue(1), differentFrom(threshold))} <>
data-testid="threshold-select-input" <SelectField {...props} disableError>
>
{[...Array(Number(owners.size))].map((x, index) => ( {[...Array(Number(owners.size))].map((x, index) => (
<MenuItem key={index} value={`${index + 1}`}> <MenuItem key={index} value={`${index + 1}`}>
{index + 1} {index + 1}
</MenuItem> </MenuItem>
))} ))}
</Field> </SelectField>
{props.meta.error && props.meta.touched && (
<Paragraph className={classes.errorText} noMargin color="error">
{props.meta.error}
</Paragraph>
)}
</>
)}
validate={composeValidators(required, mustBeInteger, minValue(1), differentFrom(threshold))}
data-testid="threshold-select-input"
/>
</Col> </Col>
<Col xs={10}> <Col xs={10}>
<Paragraph size="lg" color="primary" noMargin className={classes.ownersText}> <Paragraph size="lg" color="primary" noMargin className={classes.ownersText}>

View File

@ -34,4 +34,11 @@ export const styles = () => ({
bottom: 0, bottom: 0,
width: '100%', width: '100%',
}, },
inputRow: {
position: 'relative',
},
errorText: {
position: 'absolute',
bottom: '-25px',
},
}) })

View File

@ -63,6 +63,7 @@ const ThresholdSettings = ({
{' '} {' '}
owners owners
</Paragraph> </Paragraph>
{owners.size > 1 && (
<Row align="center" className={classes.buttonRow}> <Row align="center" className={classes.buttonRow}>
<Button <Button
color="primary" color="primary"
@ -74,6 +75,7 @@ const ThresholdSettings = ({
Modify Modify
</Button> </Button>
</Row> </Row>
)}
</Block> </Block>
<Modal <Modal
title="Change Required Confirmations" title="Change Required Confirmations"