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