import PropTypes from 'prop-types'; import React, { Component } from 'react'; import LoadingIndicator from 'Components/Loading/LoadingIndicator'; import FilterMenu from 'Components/Menu/FilterMenu'; import PageContent from 'Components/Page/PageContent'; import PageContentBody from 'Components/Page/PageContentBody'; import PageToolbar from 'Components/Page/Toolbar/PageToolbar'; import PageToolbarButton from 'Components/Page/Toolbar/PageToolbarButton'; import PageToolbarSection from 'Components/Page/Toolbar/PageToolbarSection'; import Table from 'Components/Table/Table'; import TableBody from 'Components/Table/TableBody'; import TableOptionsModalWrapper from 'Components/Table/TableOptions/TableOptionsModalWrapper'; import TablePager from 'Components/Table/TablePager'; import { align, icons } from 'Helpers/Props'; import translate from 'Utilities/String/translate'; import HistoryRowConnector from './HistoryRowConnector'; class History extends Component { // // Render render() { const { isFetching, isPopulated, error, isMoviesFetching, isMoviesPopulated, moviesError, items, columns, selectedFilterKey, filters, totalRecords, onFilterSelect, onFirstPagePress, ...otherProps } = this.props; const isFetchingAny = isFetching || isMoviesFetching; const isAllPopulated = isPopulated && (isMoviesPopulated || !items.length); const hasError = error || moviesError; return ( { isFetchingAny && !isAllPopulated && } { !isFetchingAny && hasError &&
{translate('UnableToLoadHistory')}
} { // If history isPopulated and it's empty show no history found and don't // wait for the episodes to populate because they are never coming. isPopulated && !hasError && !items.length &&
No history found
} { isAllPopulated && !hasError && !!items.length &&
{ items.map((item) => { return ( ); }) }
}
); } } History.propTypes = { isFetching: PropTypes.bool.isRequired, isPopulated: PropTypes.bool.isRequired, error: PropTypes.object, isMoviesFetching: PropTypes.bool.isRequired, isMoviesPopulated: PropTypes.bool.isRequired, moviesError: PropTypes.object, items: PropTypes.arrayOf(PropTypes.object).isRequired, columns: PropTypes.arrayOf(PropTypes.object).isRequired, selectedFilterKey: PropTypes.string.isRequired, filters: PropTypes.arrayOf(PropTypes.object).isRequired, totalRecords: PropTypes.number, onFilterSelect: PropTypes.func.isRequired, onFirstPagePress: PropTypes.func.isRequired }; export default History;