Commit 6d72fc1e authored by Jiwon Yoon's avatar Jiwon Yoon
Browse files

영화 정보페이지 수정

parent e8ffb067
...@@ -7,10 +7,9 @@ const MoviePage = ({ location }) => { ...@@ -7,10 +7,9 @@ const MoviePage = ({ location }) => {
const [movieInfo, setMovieInfo] = useState({ const [movieInfo, setMovieInfo] = useState({
...location.state, ...location.state,
stillCuts: [], stillCuts: [],
cast: "", cast: [],
director: "", director: [],
// genres: [], // attendance: ""
attendance: ""
}) })
const [state, setState] = useState(0) const [state, setState] = useState(0)
...@@ -24,23 +23,14 @@ const MoviePage = ({ location }) => { ...@@ -24,23 +23,14 @@ const MoviePage = ({ location }) => {
const still = images.backdrops.map(el => el.file_path) const still = images.backdrops.map(el => el.file_path)
const credits = await movieApi.getCreditsfromTM(movieInfo.id) const credits = await movieApi.getCreditsfromTM(movieInfo.id)
const castsInfo = credits.cast.map(el => el.name) const castsInfo = credits.cast.map(el => el.name)
const casts = castsInfo.reduce((acc, cur, idx) => {
if (idx !== 0) return acc + ', ' + cur
else return acc + cur
}, "")
console.log(castsInfo) console.log(castsInfo)
const directorsInfo = await credits.crew.filter(element => element.job === "Director") const directorsInfo = await credits.crew.filter(element => element.job === "Director").map(el=>el.name)
const directors = directorsInfo.reduce((acc, cur, idx) => {
if (idx !== 0) return acc + ', ' + cur.name
else return acc + cur.name
}, "")
console.log("directorInfo=", directorsInfo) console.log("directorInfo=", directorsInfo)
setMovieInfo({ setMovieInfo({
...movieInfo, ...movieInfo,
stillCuts: still, stillCuts: still,
cast: casts, cast: castsInfo,
director: directors director: directorsInfo
}) })
} catch (error) { } catch (error) {
console.log(error) console.log(error)
...@@ -76,11 +66,18 @@ const MoviePage = ({ location }) => { ...@@ -76,11 +66,18 @@ const MoviePage = ({ location }) => {
<div className="col-sm-3 mb-5"> <div className="col-sm-3 mb-5">
<img className="img-thumbnail" src={`https://image.tmdb.org/t/p/original${movieInfo.poster_path}`} alt="영화포스터" /> <img className="img-thumbnail" src={`https://image.tmdb.org/t/p/original${movieInfo.poster_path}`} alt="영화포스터" />
</div> </div>
<div className="col-sm-6 " style={{ color: "white" }}> <div className="col-sm-6" style={{ color: "white" }}>
<h1 className="pb-3">{movieInfo.title}</h1> <h1 className="pb-3">{movieInfo.title}</h1>
<p>예매율:{Math.round((movieInfo.ticket_sales/movieInfo.totalReservationRate.totalReservationRate)*100)}% 누적관객수: {movieInfo.attendance}</p> <p>예매율:{Math.round((movieInfo.ticket_sales / movieInfo.totalReservationRate.totalReservationRate) * 100)}% 누적관객수: {movieInfo.ticket_sales}</p>
<p>감독: {movieInfo.director}</p> {movieInfo.director || movieInfo.cast
<p>출연: {movieInfo.cast}</p> ?
<>
<p>감독: {movieInfo.director.map(el => el)+' '}</p>
<p>출연: {movieInfo.cast.slice(0, 5).map(el => el)+' '}</p>
</>
:
<></>
}
<p>장르: {movieInfo.genres.reduce((acc, cur, idx) => { <p>장르: {movieInfo.genres.reduce((acc, cur, idx) => {
if (idx !== 0) return acc + ', ' + cur.name if (idx !== 0) return acc + ', ' + cur.name
else return acc + cur.name else return acc + cur.name
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment