Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

displaying movie details #12

Merged
merged 1 commit into from
Jun 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,11 @@ li {
border-color: #A34545 !important;
}

.selected-movie-details {
grid-area: side;
background-color: white;
margin-top: 50px;
}



Expand Down
29 changes: 23 additions & 6 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,28 @@ class App extends Component {
}
}

selectMovie = (movieTitle) => {
selectMovie = (movie) => {
// recieve the whole object
this.setState({
selectedMovie: movieTitle,
// take the title of the object
selectedMovie: movie, // take the whole object

});
// send the whole object to a new function to render the movie details
// this.displayMovieDetails(movie)
}

displayMovieDetails = (movie) => {
console.log(movie)
return (
<section className="side-area">
<section className={"selected-movie-details"}>
{/* <p>{movie.title}</p> */}
<p>{movie.title}</p>
<p>{movie.overview}</p>
</section>
</section>
)
}

clearSelected = () => {
Expand Down Expand Up @@ -163,7 +181,6 @@ class App extends Component {
siteAreaStatus: 'message',
messageStatus: true,
})

}

display =() => {
Expand Down Expand Up @@ -210,7 +227,7 @@ class App extends Component {
<Checkout
selectedCustomerName={this.state.selectedCustomerName}
selectedCustomerId={this.state.selectedCustomerId}
selectedMovie={this.state.selectedMovie}
selectedMovie={this.state.selectedMovie.title}
clearSelectedCallback={this.clearSelected}
displayMessages={this.displayMessages}
refreshList={this.componentDidMount}
Expand Down Expand Up @@ -245,10 +262,10 @@ class App extends Component {

{this.state.messageStatus ? this.display() : ''}



{this.state.displaySideBar ? this.displaySideBar() : ''}

{this.state.selectedMovie ? this.displayMovieDetails(this.state.selectedMovie): ''}

<section className={"site-content-" + this.state.siteAreaStatus}>

<Route exact path="/" render={(props) => <Home welcomeMessage={this.state.welcomeMessage}/>}/>
Expand Down
3 changes: 2 additions & 1 deletion src/components/MovieLibrary.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ const MovieLibrary = (props) => {
const updateSelected = (movieId) => {
props.allMovies.forEach((movie) => {
if(movie.id === movieId) {
props.selectedMovie(movie.title);
console.log(movie)
props.selectedMovie(movie); // send the whole object
}
})
}
Expand Down