const React = require('react'); const PropTypes = require('prop-types'); const classnames = require('classnames'); const NotFound = require('stremio/routes/NotFound'); const { Button, Multiselect, MainNavBars, LibItem, useProfile, routesRegexp } = require('stremio/common'); const useLibrary = require('./useLibrary'); const useSelectableInputs = require('./useSelectableInputs'); const styles = require('./styles'); const Library = ({ model, route, urlParams, queryParams }) => { const profile = useProfile(); const library = useLibrary(model, urlParams, queryParams); const [typeSelect, sortSelect] = useSelectableInputs(route, library); return (
{ profile.auth !== null && library.type_names.length > 0 ?
: null } { profile.auth === null ?
Library is only availavle for logged in users
: library.type_names.length === 0 ?
Empty library
: library.selected === null ?
Please select a type
: library.lib_items.length === 0 ?
There are no items for the selected type
:
{library.lib_items.map((libItem, index) => ( ))}
}
); }; Library.propTypes = { model: PropTypes.oneOf(['library', 'continue_watching']), route: PropTypes.oneOf(['library', 'continuewatching']), urlParams: PropTypes.shape({ type: PropTypes.string }), queryParams: PropTypes.instanceOf(URLSearchParams) }; module.exports = ({ urlParams, queryParams }) => { const [model, route] = React.useMemo(() => { return typeof urlParams.path === 'string' ? urlParams.path.match(routesRegexp.library.regexp) ? ['library', 'library'] : urlParams.path.match(routesRegexp.continuewatching.regexp) ? ['continue_watching', 'continuewatching'] : [null, null] : [null, null]; }, [urlParams.path]); if (typeof model === 'string') { return ( ); } else { return ( ); } };