forked from reactplay/react-play
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Added header for all the plays now
- Loading branch information
Showing
2 changed files
with
55 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,45 @@ | ||
|
||
|
||
import { movies } from 'data/movies'; | ||
import { useEffect, useState } from 'react'; | ||
import Movie from './Movie'; | ||
import './movies.css'; | ||
|
||
import PlayHeader from "common/playlists/PlayHeader"; | ||
import { useEffect, useState } from "react"; | ||
import { useLocation } from "react-router-dom"; | ||
import { getPlayById } from "meta/play-meta"; | ||
import { movies } from "data/movies"; | ||
import Movie from "./Movie"; | ||
import "./movies.css"; | ||
|
||
const fetchMovies = () => { | ||
return movies; | ||
}; | ||
|
||
const MovieContainer = () => { | ||
console.log(fetchMovies()); | ||
// The following code is to fetch the current play from the URL | ||
const location = useLocation(); | ||
const { id } = location.state; | ||
const play = getPlayById(id); | ||
|
||
const [movies, setMovies] = useState([]); | ||
|
||
useEffect(() => { | ||
const movies = fetchMovies(); | ||
console.log('MovieContainer: useEffect: movies: ', movies); | ||
console.log("MovieContainer: useEffect: movies: ", movies); | ||
setMovies(movies); | ||
}, []); | ||
|
||
return( | ||
<div className="movie-container"> | ||
<h2>Movies</h2> | ||
<ul className ="movie-list"> | ||
{movies.map(movie => ( | ||
<Movie movie={movie} key={movie.id} /> | ||
))} | ||
</ul> | ||
</div> | ||
return ( | ||
<> | ||
<div className="play-details"> | ||
<PlayHeader play={play} /> | ||
<div className="play-details-body"> | ||
<div className="movie-container"> | ||
<ul className="movie-list"> | ||
{movies.map((movie) => ( | ||
<Movie movie={movie} key={movie.id} /> | ||
))} | ||
</ul> | ||
</div> | ||
</div> | ||
</div> | ||
</> | ||
); | ||
}; | ||
|
||
export default MovieContainer; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters