// @flow import React from 'react'; import FileCard from 'component/fileCard'; import Page from 'component/page'; import Button from 'component/button'; import { FormField, FormRow } from 'component/common/form'; import ReactPaginate from 'react-paginate'; type HistoryItem = { uri: string, lastViewed: number, }; type Props = { history: Array, page: number, pageCount: number, navigate: string => void, params: { page: number }, }; class UserHistoryPage extends React.PureComponent { changePage(pageNumber: number) { const { params } = this.props; const newParams = { ...params, page: pageNumber }; this.props.navigate('/user_history', newParams); } paginate(e: SyntheticKeyboardEvent<*>) { const pageFromInput = Number(e.currentTarget.value); if ( pageFromInput && e.keyCode === 13 && !Number.isNaN(pageFromInput) && pageFromInput > 0 && pageFromInput <= this.props.pageCount ) { this.changePage(pageFromInput); } } render() { const { history, page, pageCount, navigate } = this.props; return (
{history && history.length ? ( {history.map(item => ( ))} {pageCount > 1 && ( this.changePage(e.selected)} forcePage={page} initialPage={page} containerClassName="pagination" /> this.paginate(e)} prefix={__('Go to page:')} type="text" /> )} ) : (

{__('You have no saved history. Go')}{' '}

); } } export default UserHistoryPage;