spee.ch/react/containers/ChannelClaimsDisplay/view.jsx

61 lines
1.8 KiB
React
Raw Normal View History

import React from 'react';
import AssetPreview from 'components/AssetPreview';
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-08 22:22:54 +01:00
showNewPage (page) {
console.log(`update claims data with new page ${page}`);
2018-02-09 00:47:10 +01:00
this.props.onChannelPageUpdate(page);
2018-02-03 03:16:18 +01:00
}
showPreviousResultsPage () {
2018-02-03 03:16:18 +01:00
const previousPage = parseInt(this.props.currentPage) - 1;
2018-02-08 22:22:54 +01:00
this.showNewPage(previousPage);
}
showNextResultsPage () {
2018-02-03 03:16:18 +01:00
const nextPage = parseInt(this.props.currentPage) + 1;
2018-02-08 22:22:54 +01:00
this.showNewPage(nextPage);
}
render () {
2018-02-08 22:22:54 +01:00
const { error, claims, currentPage, totalPages } = this.props;
return (
<div>
2018-02-08 22:22:54 +01:00
{error ? (
<div className="row">
<div className="column column--10">
2018-02-08 22:22:54 +01:00
<p>{error}</p>
</div>
</div>
) : (
<div className="row row--tall">
2018-02-08 22:22:54 +01:00
{claims &&
<div>
2018-02-08 22:22:54 +01:00
{claims.map((claim, index) => <AssetPreview
name={claim.name}
claimId={claim.claimId}
fileExt={claim.fileExt}
contentType={claim.contentType}
key={`${claim.name}-${index}`}
/>)}
<div>
2018-02-08 22:22:54 +01:00
{(currentPage > 1) &&
2018-02-07 07:54:06 +01:00
<button className={'button--secondary'} onClick={this.showPreviousResultsPage}>Previous Page</button>
2018-02-07 07:28:17 +01:00
}
2018-02-08 22:22:54 +01:00
{(currentPage < totalPages) &&
2018-02-07 07:54:06 +01:00
<button className={'button--secondary'} onClick={this.showNextResultsPage}>Next Page</button>
2018-02-07 07:28:17 +01:00
}
</div>
</div>
}
</div>
)}
</div>
);
}
};
export default ChannelClaimsDisplay;