import React, { useState } from "react";
import { Route } from "react-router-dom";
import { connect } from "react-redux";
import { LinkContainer } from "react-router-bootstrap";
import PropTypes from "prop-types";
import Nav from "react-bootstrap/Nav";
import Navbar from "react-bootstrap/Navbar";
import NavDropdown from "react-bootstrap/NavDropdown";
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 = ({ path, placeholder, setExpanded, history }) => {
const [search, setSearch] = useState("");
const handleSearch = (ev) => {
ev.preventDefault();
history.push(`${path}/${encodeURI(search)}`);
setExpanded(false);
};
return (
);
};
Search.propTypes = {
placeholder: PropTypes.string.isRequired,
setExpanded: PropTypes.func.isRequired,
path: PropTypes.string.isRequired,
history: PropTypes.object,
};
const MoviesDropdown = () => (
Discover
My movies
);
const ShowsDropdown = () => (
Discover
My shows
);
const UserDropdown = (props) => (
);
UserDropdown.propTypes = {
username: PropTypes.string.isRequired,
isAdmin: PropTypes.bool.isRequired,
};
const WishlistDropdown = () => (
Movies
Shows
);
const TorrentsDropdown = (props) => {
const title = ;
return (
Downloads
Search
);
};
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,
};