2018-01-30 18:00:02 +01:00
|
|
|
import React from 'react';
|
2018-02-07 20:30:39 +01:00
|
|
|
import ErrorPage from 'components/ErrorPage';
|
2018-01-30 18:00:02 +01:00
|
|
|
import NavBar from 'containers/NavBar';
|
2018-02-03 03:16:18 +01:00
|
|
|
import ChannelClaimsDisplay from 'containers/ChannelClaimsDisplay';
|
2018-01-30 20:46:22 +01:00
|
|
|
import request from 'utils/request';
|
2018-01-30 18:00:02 +01:00
|
|
|
|
|
|
|
class ShowChannel extends React.Component {
|
|
|
|
componentDidMount () {
|
2018-02-02 21:46:18 +01:00
|
|
|
this.getAndStoreChannelData(this.props.requestName, this.props.requestId);
|
2018-02-01 01:00:11 +01:00
|
|
|
}
|
2018-02-03 01:49:39 +01:00
|
|
|
componentWillReceiveProps (nextProps) {
|
|
|
|
if (nextProps.requestName !== this.props.requestName || nextProps.requestId !== this.props.requestId) {
|
|
|
|
this.getAndStoreChannelData(nextProps.requestName, nextProps.requestId);
|
|
|
|
}
|
|
|
|
}
|
2018-02-02 03:42:03 +01:00
|
|
|
getAndStoreChannelData (name, id) {
|
|
|
|
if (!id) id = 'none';
|
2018-02-07 06:55:04 +01:00
|
|
|
const url = `/api/channel/data/${name}/${id}`;
|
2018-01-30 20:46:22 +01:00
|
|
|
return request(url)
|
|
|
|
.then(({ success, message, data }) => {
|
2018-02-07 20:30:39 +01:00
|
|
|
console.log('api/channel/data/ response:', data);
|
2018-01-30 20:46:22 +01:00
|
|
|
if (!success) {
|
2018-02-07 20:30:39 +01:00
|
|
|
return this.props.onShowChannelError(message);
|
2018-01-30 20:46:22 +01:00
|
|
|
}
|
2018-02-07 00:05:31 +01:00
|
|
|
this.props.onChannelDataUpdate(data.channelName, data.longChannelClaimId, data.shortChannelClaimId);
|
2018-01-30 20:46:22 +01:00
|
|
|
})
|
|
|
|
.catch((error) => {
|
2018-02-07 20:30:39 +01:00
|
|
|
return this.props.onShowChannelError(error.message);
|
2018-01-30 20:46:22 +01:00
|
|
|
});
|
2018-01-30 18:00:02 +01:00
|
|
|
}
|
2018-02-03 03:16:18 +01:00
|
|
|
componentWillUnmount () {
|
|
|
|
this.props.onChannelDataClear();
|
|
|
|
}
|
2018-01-30 18:00:02 +01:00
|
|
|
render () {
|
2018-02-07 20:30:39 +01:00
|
|
|
const { error, name, longId, shortId } = this.props;
|
|
|
|
if (error) {
|
|
|
|
return (
|
|
|
|
<ErrorPage error={error}/>
|
|
|
|
);
|
|
|
|
};
|
2018-01-30 18:00:02 +01:00
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<NavBar/>
|
2018-02-07 20:30:39 +01:00
|
|
|
<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>
|
2018-01-30 18:00:02 +01:00
|
|
|
</div>
|
2018-02-07 20:30:39 +01:00
|
|
|
<div className="column column--10">
|
|
|
|
{(name && longId) && <ChannelClaimsDisplay />}
|
2018-01-30 18:00:02 +01:00
|
|
|
</div>
|
2018-02-07 20:30:39 +01:00
|
|
|
</div>
|
2018-01-30 18:00:02 +01:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
export default ShowChannel;
|