2018-02-05 19:40:33 +00:00
|
|
|
import React from 'react';
|
2018-02-08 17:30:30 +00:00
|
|
|
import { connect } from 'react-redux';
|
2018-02-05 19:40:33 +00:00
|
|
|
import { AppState } from 'reducers';
|
|
|
|
import { NameState } from 'libs/ens';
|
|
|
|
import {
|
|
|
|
NameOwned,
|
|
|
|
NameAuction,
|
|
|
|
NameForbidden,
|
|
|
|
NameNotYetAvailable,
|
|
|
|
NameOpen,
|
|
|
|
NameReveal
|
|
|
|
} from './components';
|
|
|
|
import { Spinner } from 'components/ui';
|
2018-02-08 17:30:30 +00:00
|
|
|
import './NameResolve.scss';
|
2018-02-05 19:40:33 +00:00
|
|
|
|
|
|
|
type Props = AppState['ens'];
|
|
|
|
|
|
|
|
const modeResult = {
|
|
|
|
[NameState.Auction]: NameAuction,
|
|
|
|
[NameState.Forbidden]: NameForbidden,
|
|
|
|
[NameState.NotYetAvailable]: NameNotYetAvailable,
|
|
|
|
[NameState.Open]: NameOpen,
|
|
|
|
[NameState.Owned]: NameOwned,
|
|
|
|
[NameState.Reveal]: NameReveal
|
|
|
|
};
|
|
|
|
|
2018-02-08 17:30:30 +00:00
|
|
|
const NameResolve: React.SFC<Props> = props => {
|
2018-02-05 19:40:33 +00:00
|
|
|
const { domainRequests, domainSelector } = props;
|
|
|
|
const { currentDomain } = domainSelector;
|
|
|
|
|
|
|
|
if (!currentDomain || !domainRequests[currentDomain] || domainRequests[currentDomain].error) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
const domainData = domainRequests[currentDomain].data! || false;
|
2018-02-08 17:30:30 +00:00
|
|
|
let content;
|
2018-02-05 19:40:33 +00:00
|
|
|
|
2018-02-08 17:30:30 +00:00
|
|
|
if (domainData) {
|
|
|
|
const Component = modeResult[domainData.mode];
|
|
|
|
content = <Component {...domainData} />;
|
|
|
|
} else {
|
|
|
|
content = (
|
|
|
|
<div className="NameResolve-loader">
|
|
|
|
<Spinner size="x3" />
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return <div className="Tab-content-pane">{content}</div>;
|
2018-02-05 19:40:33 +00:00
|
|
|
};
|
2018-02-08 17:30:30 +00:00
|
|
|
|
|
|
|
export default connect((state: AppState): Props => ({ ...state.ens }))(NameResolve);
|