mirror of
https://github.com/status-im/ens-usernames.git
synced 2025-02-24 08:08:06 +00:00
* Fix redux store configuration * Setup i18n * Add welcome page french and english translation * Rename languages files * Add optimized translation * Add Ethereum network error message translation * Add top navbar translation * Add constants translation * Add move domain translation * Add translation to add domain * Add name lookup translation * Add display box translation * Add edit options translation * Add register sub domain translation * Add release domain translation * Add setup ens translation * Add update controller translation * Add test token translation * Add erc20 token translation * Add ens sub management translation * Add admin mode translation * Add terms translation
63 lines
1.7 KiB
JavaScript
63 lines
1.7 KiB
JavaScript
import lang from 'i18n-js';
|
|
import UsernameRegistrar from 'Embark/contracts/UsernameRegistrar';
|
|
import web3 from 'web3';
|
|
import React from 'react';
|
|
import { Button } from 'react-bootstrap';
|
|
import FieldGroup from '../standard/FieldGroup';
|
|
import { withFormik } from 'formik';
|
|
|
|
const InnerForm = ({
|
|
values,
|
|
errors,
|
|
handleChange,
|
|
handleBlur,
|
|
handleSubmit,
|
|
isSubmitting,
|
|
}) => (
|
|
<form onSubmit={handleSubmit}>
|
|
<FieldGroup
|
|
id="newAddress"
|
|
name="newAddress"
|
|
type="text"
|
|
label={lang.t('domain.new_address.label')}
|
|
onChange={handleChange}
|
|
onBlur={handleBlur}
|
|
value={values.newAddress}
|
|
error={errors.newAddress}
|
|
/>
|
|
<Button bsStyle="primary" type="submit" disabled={isSubmitting || !!Object.keys(errors).length}>{!isSubmitting ? lang.t('action.submit') : lang.t('action.submitting_to_blockchain')}</Button>
|
|
</form>
|
|
)
|
|
|
|
const MoveDomain = withFormik({
|
|
mapPropsToValues: props => ({ newAddress: '' }),
|
|
async validate(values) {
|
|
const { utils: { isAddress } } = web3;
|
|
const { newAddress } = values;
|
|
const errors = {};
|
|
if (!isAddress(newAddress)) errors.newAddress = lang.t('error.valid_address')
|
|
if (Object.keys(errors).length) throw errors;
|
|
},
|
|
async handleSubmit(values, { setSubmitting }) {
|
|
const { newAddress } = values;
|
|
const { methods: { moveDomain } } = UsernameRegistrar;
|
|
console.log(
|
|
`inputs for moveDomain:}`,
|
|
newAddress
|
|
);
|
|
|
|
moveDomain(newAddress)
|
|
.send()
|
|
.then((res) => {
|
|
setSubmitting(false);
|
|
console.log(res);
|
|
})
|
|
.catch((err) => {
|
|
setSubmitting(false);
|
|
console.log(err);
|
|
})
|
|
}
|
|
})(InnerForm);
|
|
|
|
export default MoveDomain;
|