@@ -106,6 +108,7 @@ ReactDOM.render((
+
diff --git a/src/public/js/components/navbar.js b/src/public/js/components/navbar.js
index 2fb6907..a21ec94 100644
--- a/src/public/js/components/navbar.js
+++ b/src/public/js/components/navbar.js
@@ -10,19 +10,28 @@ export default class NavBar extends React.Component {
constructor(props) {
super(props);
this.handleMovieSearch = this.handleMovieSearch.bind(this);
+ this.handleShowSearch = this.handleShowSearch.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)}`)
+ }
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)
{
displayMovieSearch = true;
}
+ if (isLoggedIn && location.indexOf("shows") > -1)
+ {
+ displayShowSearch = true;
+ }
return (
@@ -72,7 +81,19 @@ export default class NavBar extends React.Component {
+
+
+ }
+ {displayShowSearch &&
+
+
diff --git a/src/public/js/components/shows/list.js b/src/public/js/components/shows/list.js
index 1d83f0c..0dec71a 100644
--- a/src/public/js/components/shows/list.js
+++ b/src/public/js/components/shows/list.js
@@ -20,7 +20,24 @@ function ShowButtons(props) {
export default class ShowList extends React.Component {
componentWillMount() {
- this.props.fetchShows(this.props.showsUrl);
+ if (this.props.showsUrl) {
+ this.props.fetchShows(this.props.showsUrl);
+ } else if (this.props.params && this.props.params.search != "") {
+ this.props.searchShows({
+ key: this.props.params.search
+ });
+ }
+ }
+ componentWillUpdate(nextProps, nextState) {
+ if (!nextProps.params || nextProps.params.search === "") {
+ return
+ }
+ if (this.props.params.search === nextProps.params.search) {
+ return
+ }
+ this.props.searchShows({
+ key: nextProps.params.search
+ });
}
render() {
const shows = this.props.showStore.shows;
diff --git a/src/public/js/reducers/shows.js b/src/public/js/reducers/shows.js
index 43ed2af..dbdbdc7 100644
--- a/src/public/js/reducers/shows.js
+++ b/src/public/js/reducers/shows.js
@@ -6,6 +6,7 @@ const defaultState = {
show: {
seasons: [],
},
+ search: "",
};
export default function showStore(state = defaultState, action) {
@@ -25,6 +26,10 @@ export default function showStore(state = defaultState, action) {
show: sortEpisodes(action.payload.data),
})
return state;
+ case 'SEARCH_SHOWS_FULFILLED':
+ return Object.assign({}, state, {
+ shows: action.payload.data,
+ })
case 'SELECT_SHOW':
// Don't select the show if we're fetching another show's details
if (state.fetchingDetails) {