refactored MovieDetails component

This commit is contained in:
andres alcocer
2021-10-08 17:47:11 -04:00
parent 1f570d033f
commit 077903be44
2 changed files with 21 additions and 18 deletions

View File

@@ -3,29 +3,34 @@ import React from 'react'
import AddIcon from '../../static/images/add.svg' import AddIcon from '../../static/images/add.svg'
import PlayIcon from '../../static/images/play-button.svg' import PlayIcon from '../../static/images/play-button.svg'
export default function MovieDetails(props) { export default function MovieDetails({
movie: {
title,
name,
vote_average,
release_date,
first_air_date,
runtime,
episode_run_time,
number_of_episodes,
number_of_seasons,
overview,
},
}) {
return ( return (
<div> <div>
<div className='modal__container'> <div className='modal__container'>
<h1 className='modal__title'> <h1 className='modal__title'>{title || name}</h1>
{props.movie.title || props.movie.name}
</h1>
<p className='modal__info'> <p className='modal__info'>
<span className='modal__rating'> <span className='modal__rating'>Rating: {vote_average * 10}% </span>
Rating: {props.movie.vote_average * 10}%{' '} Release date: {release_date || first_air_date} Runtime:{' '}
</span> {runtime || episode_run_time}m
Release date: {props.movie.release_date || props.movie.first_air_date}{' '}
Runtime: {props.movie.runtime || props.movie.episode_run_time}m
</p> </p>
<p className='modal__episode'> <p className='modal__episode'>
{props.movie.number_of_episodes {number_of_episodes ? ' Episodes: ' + number_of_episodes : ''}
? ' Episodes: ' + props.movie.number_of_episodes {number_of_seasons ? ' Seasons: ' + number_of_seasons : ''}
: ''}
{props.movie.number_of_seasons
? ' Seasons: ' + props.movie.number_of_seasons
: ''}
</p> </p>
<p className='modal__overview'>{props.movie.overview}</p> <p className='modal__overview'>{overview}</p>
<button className='modal__btn modal__btn--red'> <button className='modal__btn modal__btn--red'>
<PlayIcon className='modal__btn--icon' /> <PlayIcon className='modal__btn--icon' />
Play Play

View File

@@ -6,10 +6,8 @@ const Modal = ({
show, show,
modalClosed, modalClosed,
children, children,
movie,
movie: { backdrop_path, poster_path }, movie: { backdrop_path, poster_path },
}) => { }) => {
console.log('Modal.movie', movie)
const backgroundStyle = { const backgroundStyle = {
backgroundSize: 'cover', backgroundSize: 'cover',
backgroundImage: `url(https://image.tmdb.org/t/p/original/${ backgroundImage: `url(https://image.tmdb.org/t/p/original/${