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;
|
|
|
|
this.props.onChannelPageUpdate(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-02-13 03:18:56 +01:00
|
|
|
<div className="row row--tall">
|
|
|
|
{claims &&
|
|
|
|
<div>
|
|
|
|
{claims.map((claim, index) => <AssetPreview
|
|
|
|
name={claim.name}
|
|
|
|
claimId={claim.claimId}
|
|
|
|
fileExt={claim.fileExt}
|
|
|
|
contentType={claim.contentType}
|
|
|
|
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>
|
2018-02-02 21:46:18 +01:00
|
|
|
}
|
|
|
|
</div>
|
2018-02-13 03:18:56 +01:00
|
|
|
</div>
|
|
|
|
}
|
2018-02-02 21:46:18 +01:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
export default ChannelClaimsDisplay;
|