diff --git a/app/components/ens/addDomain.js b/app/components/ens/addDomain.js new file mode 100644 index 0000000..c45e12c --- /dev/null +++ b/app/components/ens/addDomain.js @@ -0,0 +1,73 @@ +import ENSSubdomainRegistry from 'Embark/contracts/ENSSubdomainRegistry'; +import React, { Fragment } from 'react'; +import { Form, FormGroup, FormControl, HelpBlock, Button, ControlLabel } from 'react-bootstrap'; +import { withFormik } from 'formik'; +import { hash } from 'eth-ens-namehash' + +const FieldGroup = ({ id, label, error, ...props }) => ( + + {label} + + {error && {error}} + +) + +const InnerForm = ({ + values, + errors, + touched, + handleChange, + handleBlur, + handleSubmit, + isSubmitting, +}) => ( +
+ + + + +) + +const AddDomain = withFormik({ + mapPropsToValues: props => ({ domainName: '', domainPrice: '' }), + validate(values, props) { + const errors = {}; + if (!values.domainName) errors.domainName = 'Required'; + return errors; + }, + handleSubmit(values, { setSubmitting }) { + const { domainName, domainPrice } = values + const { methods: { addDomain } } = ENSSubdomainRegistry + addDomain(hash(domainName), domainPrice || 0) + .send() + .then(res => { + setSubmitting(false); + console.log(res); + }) + .catch(err => { + setSubmitting(false); + console.log(err); + }) + } +})(InnerForm) + +setTimeout(() => {ENSSubdomainRegistry.methods.controller().call().then(console.log)}, 2000) +export default AddDomain; diff --git a/app/components/ensSubManagement.js b/app/components/ensSubManagement.js index ab39e2b..189dde7 100644 --- a/app/components/ensSubManagement.js +++ b/app/components/ensSubManagement.js @@ -14,7 +14,7 @@ const FieldGroup = ({ id, label, help, ...props }) => ( const ENSSubManagement = (props) => ( -

Subdomain management

+

Subdomain Management

Add Domain