From 041c656c673b9cc96908d2e0a6aeaa18b18dd13d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Delattre?= Date: Sat, 21 Jan 2017 00:13:45 +0100 Subject: [PATCH] Refactor navbar in modules --- src/public/js/components/navbar.js | 202 ++++++++++++++++------------- 1 file changed, 114 insertions(+), 88 deletions(-) diff --git a/src/public/js/components/navbar.js b/src/public/js/components/navbar.js index a21ec94..3f9bbab 100644 --- a/src/public/js/components/navbar.js +++ b/src/public/js/components/navbar.js @@ -6,102 +6,128 @@ import { Nav, Navbar, NavItem, NavDropdown, MenuItem } from 'react-bootstrap' import { LinkContainer } from 'react-router-bootstrap' import { Control, Form } from 'react-redux-form'; -export default class NavBar extends React.Component { +export default function NavBar(props) { + return ( +
+ + + + Canapé + + + + + + + + + + + +
+ ); +} + +class Search extends React.Component { constructor(props) { super(props); - this.handleMovieSearch = this.handleMovieSearch.bind(this); - this.handleShowSearch = this.handleShowSearch.bind(this); + this.handleSearch = this.handleSearch.bind(this); } - handleMovieSearch() { - this.props.router.push(`/movies/search/${encodeURI(this.props.movieStore.search)}`) - } - handleShowSearch() { - this.props.router.push(`/shows/search/${encodeURI(this.props.showStore.search)}`) + handleSearch() { + this.props.router.push(`${this.props.path}/${encodeURI(this.props.search)}`) } render() { - const username = this.props.userStore.username; - const isLoggedIn = username !== "" ? true : false; const location = this.props.router.getCurrentLocation().pathname; - let displayMovieSearch = false; - let displayShowSearch = false; - if (isLoggedIn && location.indexOf("movies") > -1) + if (location.indexOf(this.props.pathMatch) === -1) { - displayMovieSearch = true; + return null; } - if (isLoggedIn && location.indexOf("shows") > -1) - { - displayShowSearch = true; - } - return ( -
- - - - Canapé - - - - - - - {displayMovieSearch && - -
this.handleMovieSearch()}> - - -
- } - {displayShowSearch && - -
this.handleShowSearch()}> - - -
- } -
-
-
+ + return( + +
+ + +
+ ); + } +} + +function MoviesDropdown(props) { + return( + + ); +} + +function ShowsDropdown(props) { + return( + + ); +} + +function UserDropdown(props) { + if (props.username !== "") { + return ( + + ); + } else { + return( + ); } }