import React from 'react'; import NavBar from 'containers/NavBar'; import AssetPreview from 'components/AssetPreview'; import request from 'utils/request'; class ShowChannel extends React.Component { 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); } componentDidMount () { this.updateChannelData(1); } updateChannelData (page) { const channelName = this.props.channelName; const channelClaimId = this.props.channelClaimId || 'none'; const url = `/api/channel-get-content/${channelName}/${channelClaimId}/${page}`; const that = this; return request(url) .then(({ success, message, data }) => { console.log('get channel data response:', data); if (!success) { return that.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}); }); } render () { return (
{this.state.error}
full channel id: {this.state.longChannelClaimId ? this.state.longChannelClaimId : 'loading...'}
short channel id: {this.state.shortChannelClaimId ? this.state.shortChannelClaimId : 'loading...'}
# of claims in channel: {this.state.totalResults >= 0 ? this.state.totalResults : 'loading...' }