mirror of
https://github.com/status-im/ens-usernames.git
synced 2025-03-03 11:30:43 +00:00
use render addresses after registration
This commit is contained in:
parent
89f84a4991
commit
e3511e397f
@ -37,6 +37,31 @@ const backButton = {
|
|||||||
cursor: 'pointer'
|
cursor: 'pointer'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class RenderAddresses extends PureComponent {
|
||||||
|
state = { copied: false }
|
||||||
|
|
||||||
|
render() {
|
||||||
|
const { domainName, address, statusAccount } = this.props
|
||||||
|
const { copied } = this.state
|
||||||
|
const markCopied = (v) => { this.setState({ copied: v }) }
|
||||||
|
const isCopied = address => address == copied;
|
||||||
|
const renderCopied = address => isCopied(address) && <span style={{ color: theme.positive }}><IconCheck/>Copied!</span>;
|
||||||
|
return (
|
||||||
|
<div style={{ display: 'flex', flexDirection: 'column' }}>
|
||||||
|
<Info.Action title="Click to copy"><b>{formatName(domainName).toUpperCase()}</b> Resolves To:</Info.Action>
|
||||||
|
{address && <Text style={{ marginTop: '1em' }}>Ethereum Address {renderCopied(address)}</Text>}
|
||||||
|
<CopyToClipboard text={address} onCopy={markCopied}>
|
||||||
|
<div style={addressStyle}>{address}</div>
|
||||||
|
</CopyToClipboard>
|
||||||
|
{validStatusAddress(statusAccount) && <Text style={{ marginTop: '1em' }}>Status Address {renderCopied(statusAccount)}</Text>}
|
||||||
|
{validStatusAddress(statusAccount) && <CopyToClipboard text={statusAccount} onCopy={markCopied}>
|
||||||
|
<div style={{ ...addressStyle, color: isCopied ? theme.primary : null }}>{statusAccount}</div>
|
||||||
|
</CopyToClipboard>}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class Register extends PureComponent {
|
class Register extends PureComponent {
|
||||||
state = { domainPrice: null };
|
state = { domainPrice: null };
|
||||||
|
|
||||||
@ -49,57 +74,40 @@ class Register extends PureComponent {
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { domainName, setStatus } = this.props;
|
const { domainName, setStatus } = this.props;
|
||||||
const { domainPrice } = this.state;
|
const { domainPrice, registered } = this.state;
|
||||||
const formattedDomain = formatName(domainName);
|
const formattedDomain = formatName(domainName);
|
||||||
const formattedDomainArray = formattedDomain.split('.')
|
const formattedDomainArray = formattedDomain.split('.')
|
||||||
return (
|
return (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
<Info.Action title="No address is associated with this domain">
|
{!registered ?
|
||||||
{formattedDomain.toUpperCase()} can be registered for {domainPrice} SNT
|
<Fragment>
|
||||||
</Info.Action>
|
<Info.Action title="No address is associated with this domain">
|
||||||
<RegisterSubDomain
|
{formattedDomain.toUpperCase()} can be registered for {domainPrice} SNT
|
||||||
subDomain={formattedDomainArray[0]}
|
</Info.Action>
|
||||||
domainName={formattedDomainArray.slice(1).join('.')}
|
<RegisterSubDomain
|
||||||
domainPrice={domainPrice}
|
subDomain={formattedDomainArray[0]}
|
||||||
registeredCallbackFn={(address, statusAccount) => this.setState({ registered: { address, statusAccount } })} />
|
domainName={formattedDomainArray.slice(1).join('.')}
|
||||||
|
domainPrice={domainPrice}
|
||||||
|
registeredCallbackFn={(address, statusAccount) => this.setState({ registered: { address, statusAccount } })} />
|
||||||
|
</Fragment> :
|
||||||
|
<RenderAddresses {...this.props} address={registered.address} statusAccount={registered.statusAccount} />}
|
||||||
<div style={backButton} onClick={() => setStatus(null)}>←</div>
|
<div style={backButton} onClick={() => setStatus(null)}>←</div>
|
||||||
</Fragment>
|
</Fragment>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class DisplayAddress extends PureComponent {
|
const DisplayAddress = ({ domainName, address, statusAccount, setStatus }) => (
|
||||||
state = { copied: false }
|
<Fragment>
|
||||||
|
{validAddress(address) ?
|
||||||
render() {
|
<RenderAddresses {...this.props} />
|
||||||
const { copied } = this.state
|
:
|
||||||
const { domainName, address, statusAccount, setStatus } = this.props
|
<Info.Action title="No address is associated with this domain">
|
||||||
const markCopied = (v) => { this.setState({ copied: v }) }
|
{domainName.toUpperCase()}
|
||||||
const isCopied = address => address == copied;
|
</Info.Action>}
|
||||||
const renderCopied = address => isCopied(address) && <span style={{ color: theme.positive }}><IconCheck/>Copied!</span>;
|
<div style={backButton} onClick={() => setStatus(null)}>←</div>
|
||||||
return (
|
</Fragment>
|
||||||
<Fragment>
|
)
|
||||||
{validAddress(address) ?
|
|
||||||
<div style={{ display: 'flex', flexDirection: 'column' }}>
|
|
||||||
<Info.Action title="Click to copy"><b>{formatName(domainName).toUpperCase()}</b> Resolves To:</Info.Action>
|
|
||||||
{address && <Text style={{ marginTop: '1em' }}>Ethereum Address {renderCopied(address)}</Text>}
|
|
||||||
<CopyToClipboard text={address} onCopy={markCopied}>
|
|
||||||
<div style={addressStyle}>{address}</div>
|
|
||||||
</CopyToClipboard>
|
|
||||||
{validStatusAddress(statusAccount) && <Text style={{ marginTop: '1em' }}>Status Address {renderCopied(statusAccount)}</Text>}
|
|
||||||
{validStatusAddress(statusAccount) && <CopyToClipboard text={statusAccount} onCopy={markCopied}>
|
|
||||||
<div style={{ ...addressStyle, color: isCopied ? theme.primary : null }}>{statusAccount}</div>
|
|
||||||
</CopyToClipboard>}
|
|
||||||
</div>
|
|
||||||
:
|
|
||||||
<Info.Action title="No address is associated with this domain">
|
|
||||||
{domainName.toUpperCase()}
|
|
||||||
</Info.Action>}
|
|
||||||
<div style={backButton} onClick={() => setStatus(null)}>←</div>
|
|
||||||
</Fragment>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const InnerForm = ({
|
const InnerForm = ({
|
||||||
values,
|
values,
|
||||||
|
@ -128,7 +128,8 @@ const RegisterSubDomain = withFormik({
|
|||||||
console.log("Register send errored. :( Out of gas?")
|
console.log("Register send errored. :( Out of gas?")
|
||||||
console.dir(err)
|
console.dir(err)
|
||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
registeredCallbackFn(resolveToAddr, resolveToStatusAddr);
|
// REQUIRED UNTIL THIS ISSUES IS RESOLVED: https://github.com/jaredpalmer/formik/issues/597
|
||||||
|
setTimeout(() => { registeredCallbackFn(resolveToAddr, resolveToStatusAddr); }, 200);
|
||||||
setSubmitting(false);
|
setSubmitting(false);
|
||||||
});
|
});
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user