MovieCard.js 1.76 KB
Newer Older
Kim, Subin's avatar
Kim, Subin committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import { useState, useEffect } from "react"
import { Link } from 'react-router-dom'
import styles from './movie-card.module.scss'

const MovieCard = ({ list }) => {
    const [movieList, setMovieList] = useState(list)

    useEffect(() => {
        setMovieList(list)
    }, [list])

    return (
        <>
            {movieList.map(movie => (
                <div className="card h-100" style={{ backgroundColor: "black" }}>
                    <Link to={{
                        pathname: `/movie/${movie.id}`,
                        state: {
                            ...movie
                        }
                    }} className={`${styles.layer}`} >
                        <img src={`https://image.tmdb.org/t/p/original${movie.poster_path}`} className={`card-img-top rounded ${styles.poster}`} alt="Movie Poster" />
                        <div className={`${styles.description}`}>{movie.overview}</div>
                    </Link>
                    <div className="card-body text-light">
Jiwon Yoon's avatar
Jiwon Yoon committed
26
27
                        <marquee className={`h2 card-title text-center ${styles.title}`}>{movie.title}</marquee>
                        <p className={`card-text text-center ${styles.txt}`}>예매율: {movie.ticket_sales}0% | {movie.runtime}</p>
Kim, Subin's avatar
Kim, Subin committed
28
29
                        <p className="card-text text-center"><small className="text-muted">{movie.release_date} 개봉</small></p>
                    </div>
Jiwon Yoon's avatar
Jiwon Yoon committed
30
31
32
33
34
35
                    <Link to={{
                            pathname:`/ticket`,
                            state: {movieId:movie.id,}
                        }} className="text-center">
                            <button className="btn btn-warning">예매하기</button>
                        </Link>
Kim, Subin's avatar
Kim, Subin committed
36
37
38
39
40
41
42
                </div>
            ))}
        </>
    )
}

export default MovieCard