2018-01-30 09:00:02 -08:00
|
|
|
import React from 'react';
|
2018-02-07 11:30:39 -08:00
|
|
|
import ErrorPage from 'components/ErrorPage';
|
2018-01-30 09:00:02 -08:00
|
|
|
import NavBar from 'containers/NavBar';
|
2018-02-02 18:16:18 -08:00
|
|
|
import ChannelClaimsDisplay from 'containers/ChannelClaimsDisplay';
|
2018-01-30 09:00:02 -08:00
|
|
|
|
2018-02-07 21:30:32 -08:00
|
|
|
import { CHANNEL } from 'constants/show_request_types';
|
|
|
|
|
|
|
|
function requestIsAChannelRequest ({ requestType }) {
|
|
|
|
return requestType === CHANNEL;
|
|
|
|
}
|
|
|
|
|
2018-01-30 09:00:02 -08:00
|
|
|
class ShowChannel extends React.Component {
|
|
|
|
componentDidMount () {
|
2018-02-12 19:01:29 -08:00
|
|
|
const { previousRequest, channel, requestId, requestChannelName, requestChannelId } = this.props;
|
|
|
|
if (!previousRequest) {
|
2018-02-12 18:18:56 -08:00
|
|
|
return this.props.onNewChannelRequest(requestId, requestChannelName, requestChannelId);
|
|
|
|
}
|
|
|
|
if (!channel) {
|
2018-02-12 19:01:29 -08:00
|
|
|
const { name, shortId, longId } = previousRequest;
|
2018-02-12 18:18:56 -08:00
|
|
|
return this.props.onShowNewChannel(name, shortId, longId);
|
2018-02-07 21:30:32 -08:00
|
|
|
}
|
2018-01-31 16:00:11 -08:00
|
|
|
}
|
2018-02-02 16:49:39 -08:00
|
|
|
componentWillReceiveProps (nextProps) {
|
2018-02-12 18:18:56 -08:00
|
|
|
if (requestIsAChannelRequest(nextProps)) {
|
2018-02-12 19:01:29 -08:00
|
|
|
const { previousRequest, channel, requestId, requestChannelName, requestChannelId } = nextProps;
|
|
|
|
if (!previousRequest) {
|
2018-02-12 18:18:56 -08:00
|
|
|
return this.props.onNewChannelRequest(requestId, requestChannelName, requestChannelId);
|
|
|
|
}
|
|
|
|
if (!channel) {
|
2018-02-12 19:01:29 -08:00
|
|
|
const { name, shortId, longId } = previousRequest;
|
2018-02-12 18:18:56 -08:00
|
|
|
return this.props.onShowNewChannel(name, shortId, longId);
|
2018-02-07 21:30:32 -08:00
|
|
|
}
|
2018-02-08 10:02:29 -08:00
|
|
|
}
|
2018-01-30 09:00:02 -08:00
|
|
|
}
|
|
|
|
render () {
|
2018-02-12 18:18:56 -08:00
|
|
|
const { channel } = this.props;
|
2018-02-08 16:42:13 -08:00
|
|
|
if (channel) {
|
2018-02-12 18:18:56 -08:00
|
|
|
const { name, longId, shortId } = channel;
|
2018-02-08 16:42:13 -08:00
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<NavBar/>
|
|
|
|
<div className="row row--tall row--padded">
|
|
|
|
<div className="column column--10">
|
|
|
|
<h2>channel name: {name ? name : 'loading...'}</h2>
|
|
|
|
<p className={'fine-print'}>full channel id: {longId ? longId : 'loading...'}</p>
|
|
|
|
<p className={'fine-print'}>short channel id: {shortId ? shortId : 'loading...'}</p>
|
|
|
|
</div>
|
|
|
|
<div className="column column--10">
|
2018-02-12 18:18:56 -08:00
|
|
|
<ChannelClaimsDisplay />
|
2018-02-08 16:42:13 -08:00
|
|
|
</div>
|
2018-01-30 09:00:02 -08:00
|
|
|
</div>
|
2018-02-07 11:30:39 -08:00
|
|
|
</div>
|
2018-02-08 16:42:13 -08:00
|
|
|
);
|
|
|
|
};
|
|
|
|
return (
|
|
|
|
<ErrorPage error={'loading channel data...'}/>
|
2018-01-30 09:00:02 -08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
export default ShowChannel;
|