2018-02-07 10:52:09 -08:00
|
|
|
import React from 'react';
|
|
|
|
import AssetPreview from 'components/AssetPreview';
|
2018-02-02 12:46:18 -08:00
|
|
|
|
|
|
|
class ChannelClaimsDisplay extends React.Component {
|
|
|
|
constructor (props) {
|
|
|
|
super(props);
|
2018-02-06 22:28:17 -08:00
|
|
|
this.showNextResultsPage = this.showNextResultsPage.bind(this);
|
|
|
|
this.showPreviousResultsPage = this.showPreviousResultsPage.bind(this);
|
2018-02-02 12:46:18 -08:00
|
|
|
}
|
2018-02-02 16:06:21 -08:00
|
|
|
showPreviousResultsPage () {
|
2018-02-09 10:02:13 -08:00
|
|
|
const { channel: { claimsData: { currentPage } } } = this.props;
|
|
|
|
const previousPage = parseInt(currentPage) - 1;
|
2018-02-08 13:22:54 -08:00
|
|
|
this.showNewPage(previousPage);
|
2018-02-02 16:06:21 -08:00
|
|
|
}
|
|
|
|
showNextResultsPage () {
|
2018-02-09 10:02:13 -08:00
|
|
|
const { channel: { claimsData: { currentPage } } } = this.props;
|
|
|
|
const nextPage = parseInt(currentPage) + 1;
|
2018-02-08 13:22:54 -08:00
|
|
|
this.showNewPage(nextPage);
|
2018-02-02 16:06:21 -08:00
|
|
|
}
|
2018-02-09 10:02:13 -08:00
|
|
|
showNewPage (page) {
|
2018-02-12 18:18:56 -08:00
|
|
|
const { channelKey, channel: { name, longId } } = this.props;
|
2018-02-14 09:19:22 -08:00
|
|
|
this.props.onUpdateChannelClaims(channelKey, name, longId, page);
|
2018-02-09 10:02:13 -08:00
|
|
|
}
|
2018-02-02 12:46:18 -08:00
|
|
|
render () {
|
2018-02-12 18:18:56 -08:00
|
|
|
const { channel: { claimsData: { claims, currentPage, totalPages } } } = this.props;
|
2018-02-02 12:46:18 -08:00
|
|
|
return (
|
2018-03-07 20:31:10 -08:00
|
|
|
<div className='row row--tall'>
|
2018-02-12 19:08:17 -08:00
|
|
|
{(claims.length > 0) ? (
|
2018-02-12 18:18:56 -08:00
|
|
|
<div>
|
2018-02-12 19:08:17 -08:00
|
|
|
{claims.map((claim, index) => <AssetPreview
|
2018-03-02 09:36:28 -08:00
|
|
|
claimData={claim}
|
2018-02-12 19:08:17 -08:00
|
|
|
key={`${claim.name}-${index}`}
|
|
|
|
/>)}
|
|
|
|
<div>
|
|
|
|
{(currentPage > 1) &&
|
|
|
|
<button className={'button--secondary'} onClick={this.showPreviousResultsPage}>Previous Page</button>
|
|
|
|
}
|
|
|
|
{(currentPage < totalPages) &&
|
|
|
|
<button className={'button--secondary'} onClick={this.showNextResultsPage}>Next Page</button>
|
|
|
|
}
|
|
|
|
</div>
|
2018-02-02 12:46:18 -08:00
|
|
|
</div>
|
2018-02-12 19:08:17 -08:00
|
|
|
) : (
|
|
|
|
<p>There are no claims in this channel</p>
|
|
|
|
)}
|
2018-02-02 12:46:18 -08:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
export default ChannelClaimsDisplay;
|