import React from 'react'; import NavBar from 'containers/NavBar'; import AssetPreview from 'components/AssetPreview'; import request from 'utils/request'; class ChannelClaimsDisplay extends React.Component { constructor (props) { super(props); this.state = { error: null, page : 1, }; this.getAndStoreChannelClaims = this.getAndStoreChannelClaims.bind(this); } componentDidMount () { const channelName = this.props.channelName; const channelClaimId = this.props.channelClaimId || 'none'; const page = this.state.page; this.getAndStoreChannelClaims(channelName, channelClaimId, page); } getAndStoreChannelClaims (channelName, channelClaimId, page) { const url = `/api/channel-claims/${channelName}/${channelClaimId}/${page}`; const that = this; return request(url) .then(({ success, message, data }) => { console.log('api/channel-claims response:', data); if (!success) { return that.setState({error: message}); } that.setState({ claims : data.claims, currentPage : data.currentPage, nextPage : data.nextPage, previousPage: data.previousPage, totalPages : data.totalPages, totalResults: data.totalResults, }); }) .catch((error) => { that.setState({error: error.message}); }); } render () { return (
{this.state.error ? (

{this.state.error}

) : (

# of claims in channel: {this.state.totalResults >= 0 ? this.state.totalResults : 'loading...' }

{this.state.claims && this.state.claims.map((claim, index) => )}
)}
); } }; // required props // channelName // channelClaimId export default ChannelClaimsDisplay;