2018-01-30 18:00:02 +01:00
|
|
|
import React from 'react';
|
|
|
|
import NavBar from 'containers/NavBar';
|
2018-01-30 20:46:22 +01:00
|
|
|
import AssetPreview from 'components/AssetPreview';
|
|
|
|
import request from 'utils/request';
|
2018-01-30 18:00:02 +01:00
|
|
|
|
|
|
|
class ShowChannel extends React.Component {
|
2018-01-30 20:46:22 +01:00
|
|
|
constructor (props) {
|
|
|
|
super(props);
|
|
|
|
this.state = {
|
|
|
|
error : null,
|
|
|
|
channelName : null,
|
|
|
|
claims : null,
|
|
|
|
currentPage : null,
|
|
|
|
longChannelClaimId : null,
|
|
|
|
nextPage : null,
|
|
|
|
previousPage : null,
|
|
|
|
shortChannelClaimId: null,
|
|
|
|
totalPages : null,
|
|
|
|
totalResults : null,
|
|
|
|
};
|
|
|
|
this.updateChannelData = this.updateChannelData.bind(this);
|
|
|
|
}
|
2018-01-30 18:00:02 +01:00
|
|
|
componentDidMount () {
|
|
|
|
console.log(this.props);
|
2018-01-30 20:46:22 +01:00
|
|
|
this.updateChannelData(1);
|
|
|
|
}
|
|
|
|
updateChannelData (page) {
|
|
|
|
const that = this;
|
|
|
|
const channelName = this.props.channelName;
|
|
|
|
const channelClaimId = this.props.channelClaimId || 'none';
|
|
|
|
const url = `/api/channel-get-content/${channelName}/${channelClaimId}/${page}`;
|
|
|
|
return request(url)
|
|
|
|
.then(({ success, message, data }) => {
|
|
|
|
console.log('get channel data response:', data);
|
|
|
|
if (!success) {
|
|
|
|
return this.setState({error: message});
|
|
|
|
}
|
|
|
|
that.setState({
|
|
|
|
channelName : data.channelName,
|
|
|
|
claims : data.claims,
|
|
|
|
currentPage : data.currentPage,
|
|
|
|
longChannelClaimId : data.longChannelClaimId,
|
|
|
|
nextPage : data.nextPage,
|
|
|
|
previousPage : data.previousPage,
|
|
|
|
shortChannelClaimId: data.shortChannelClaimId,
|
|
|
|
totalPages : data.totalPages,
|
|
|
|
totalResults : data.totalResults,
|
|
|
|
});
|
|
|
|
})
|
|
|
|
.catch((error) => {
|
|
|
|
that.setState({error: error.message});
|
|
|
|
});
|
2018-01-30 18:00:02 +01:00
|
|
|
}
|
|
|
|
render () {
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<NavBar/>
|
2018-01-30 20:46:22 +01:00
|
|
|
{this.state.error ? (
|
|
|
|
<div className="row row--tall row--padded">
|
|
|
|
<div className="column column--10">
|
|
|
|
<p>{this.state.error}</p>
|
|
|
|
</div>
|
2018-01-30 18:00:02 +01:00
|
|
|
</div>
|
2018-01-30 20:46:22 +01:00
|
|
|
) : (
|
|
|
|
<div className="row row--tall row--padded">
|
|
|
|
<div className="column column--10">
|
|
|
|
<h2>channel name: {this.props.channelName}</h2>
|
|
|
|
<p>full channel id: {this.state.longChannelClaimId ? this.state.longChannelClaimId : 'loading...'}</p>
|
|
|
|
<p>short channel id: {this.state.shortChannelClaimId ? this.state.shortChannelClaimId : 'loading...'}</p>
|
|
|
|
<p># of claims in channel: {this.state.totalResults ? this.state.totalResults : 'loading...' }</p>
|
|
|
|
</div>
|
|
|
|
<div className="column column--10">
|
2018-01-30 18:00:02 +01:00
|
|
|
<div>
|
2018-01-30 20:46:22 +01:00
|
|
|
{/* claims here */}
|
2018-01-30 20:54:29 +01:00
|
|
|
{this.state.claims && this.state.claims.map((claim, index) => <AssetPreview
|
|
|
|
name={claim.name}
|
|
|
|
claimId={claim.claimId}
|
|
|
|
contentType={claim.contentType}
|
|
|
|
key={index}
|
|
|
|
/>)}
|
2018-01-30 20:46:22 +01:00
|
|
|
</div>
|
2018-01-30 18:00:02 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
2018-01-30 20:46:22 +01:00
|
|
|
)}
|
2018-01-30 18:00:02 +01:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// required props
|
|
|
|
// channelName
|
2018-01-30 20:46:22 +01:00
|
|
|
// channelClaimId
|
|
|
|
|
2018-01-30 18:00:02 +01:00
|
|
|
|
|
|
|
export default ShowChannel;
|