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 => (
<>
<SelectField {...props} disableError>
{[...Array(Number(owners.size))].map((x, index) => (
<MenuItem key={index} value={`${index + 1}`}>
{index + 1}
</MenuItem>
))}
</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))} validate={composeValidators(required, mustBeInteger, minValue(1), differentFrom(threshold))}
data-testid="threshold-select-input" data-testid="threshold-select-input"
> />
{[...Array(Number(owners.size))].map((x, index) => (
<MenuItem key={index} value={`${index + 1}`}>
{index + 1}
</MenuItem>
))}
</Field>
</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}>
@ -87,7 +96,7 @@ const ChangeThreshold = ({
{' '} {' '}
{owners.size} {owners.size}
{' '} {' '}
owner(s) owner(s)
</Paragraph> </Paragraph>
</Col> </Col>
</Row> </Row>

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,17 +63,19 @@ const ThresholdSettings = ({
{' '} {' '}
owners owners
</Paragraph> </Paragraph>
<Row align="center" className={classes.buttonRow}> {owners.size > 1 && (
<Button <Row align="center" className={classes.buttonRow}>
color="primary" <Button
minWidth={120} color="primary"
className={classes.modifyBtn} minWidth={120}
onClick={toggleModal} className={classes.modifyBtn}
variant="contained" onClick={toggleModal}
> variant="contained"
Modify >
</Button> Modify
</Row> </Button>
</Row>
)}
</Block> </Block>
<Modal <Modal
title="Change Required Confirmations" title="Change Required Confirmations"