import React, { useState } from "react" import { Route, Link } from "react-router-dom" import { connect } from "react-redux" import { Nav, Navbar, NavItem, NavDropdown, MenuItem } from "react-bootstrap" import { LinkContainer } from "react-router-bootstrap" import PropTypes from "prop-types" const mapStateToProps = (state) => { let torrentCount = 0; if (state.torrentStore.has("torrents") && state.torrentStore.get("torrents") !== undefined) { torrentCount = state.torrentStore.get("torrents").size; } return { username: state.userStore.get("username"), isAdmin: state.userStore.get("isAdmin"), torrentCount: torrentCount, } }; const AppNavBar = (props) => { const [expanded, setExpanded] = useState(false); return ( setExpanded(!expanded)}> Canapé }/> }/> ) } AppNavBar.propTypes = { torrentCount: PropTypes.number.isRequired, username: PropTypes.string.isRequired, isAdmin: PropTypes.bool.isRequired, history: PropTypes.object, }; export default connect(mapStateToProps)(AppNavBar); const Search = (props) => { const [search, setSearch] = useState(""); const handleSearch = (ev) => { ev.preventDefault(); props.history.push(`${props.path}/${encodeURI(search)}`); } return(
handleSearch(ev)}> setSearch(e.target.value)} />
); } Search.propTypes = { placeholder: PropTypes.string.isRequired, path: PropTypes.string.isRequired, history: PropTypes.object, }; const MoviesDropdown = () => ( ) const ShowsDropdown = () => ( ); function UserDropdown(props) { return ( ); } UserDropdown.propTypes = { username: PropTypes.string.isRequired, isAdmin: PropTypes.bool.isRequired, }; const WishlistDropdown = () => ( ); const TorrentsDropdown = (props) => { const title = () return( ); } TorrentsDropdown.propTypes = { torrentsCount: PropTypes.number.isRequired }; const TorrentsDropdownTitle = (props) => { if (props.torrentsCount === 0) { return ( Torrents ); } return ( Torrents   {props.torrentsCount} ); } TorrentsDropdownTitle.propTypes = { torrentsCount: PropTypes.number.isRequired };