add use primary address for setting address in resolver

This commit is contained in:
Barry Gitarts 2018-05-28 13:58:51 -04:00
parent c02a8b5959
commit 7582615a37
2 changed files with 13 additions and 3 deletions

View File

@ -16,6 +16,7 @@ const InnerForm = ({
handleBlur, handleBlur,
handleSubmit, handleSubmit,
isSubmitting, isSubmitting,
setFieldValue
}) => ( }) => (
<form onSubmit={handleSubmit}> <form onSubmit={handleSubmit}>
<FieldGroup <FieldGroup
@ -46,6 +47,7 @@ const InnerForm = ({
onBlur={handleBlur} onBlur={handleBlur}
value={values.address} value={values.address}
error={errors.address} error={errors.address}
button={<Button style={{ marginTop: '5px' }} onClick={() => setFieldValue('address', web3.eth.defaultAccount)}>Use My Primary Address</Button>}
/> />
<Button bsStyle="primary" type="submit" disabled={isSubmitting || !!Object.keys(errors).length}>{!isSubmitting ? 'Submit' : 'Submitting to the Blockchain - (this may take awhile)'}</Button> <Button bsStyle="primary" type="submit" disabled={isSubmitting || !!Object.keys(errors).length}>{!isSubmitting ? 'Submit' : 'Submitting to the Blockchain - (this may take awhile)'}</Button>
</form> </form>

View File

@ -1,10 +1,18 @@
import React from 'react'; import React from 'react';
import { FormGroup, FormControl, HelpBlock, ControlLabel } from 'react-bootstrap'; import { FormGroup, FormControl, HelpBlock, ControlLabel, InputGroup } from 'react-bootstrap';
const FieldGroup = ({ id, label, error, ...props }) => ( const FieldGroup = ({ id, label, button, error, ...props }) => (
<FormGroup controlId={id} validationState={error ? 'error' : null}> <FormGroup controlId={id} validationState={error ? 'error' : null}>
<ControlLabel>{label}</ControlLabel> <ControlLabel>{label}</ControlLabel>
<FormControl {...props} /> {button
? <InputGroup>
<InputGroup.Button>
{button}
</InputGroup.Button>
<FormControl {...props} />
</InputGroup>
: <FormControl {...props} />
}
{error && <HelpBlock>{error}</HelpBlock>} {error && <HelpBlock>{error}</HelpBlock>}
</FormGroup> </FormGroup>
) )