MovieComming.js 2.13 KB
Newer Older
Jiwon Yoon's avatar
Jiwon Yoon committed
1
2
import React,{useState, useEffect} from 'react'
import axios from 'axios'
한규민's avatar
한규민 committed
3
import { baseUrl } from '../../utils/baseUrl.js'
Jiwon Yoon's avatar
Jiwon Yoon committed
4
import { Link } from 'react-router-dom';
Jiwon Yoon's avatar
Jiwon Yoon committed
5
import styles from "./movieComming.module.scss"
Jiwon Yoon's avatar
Jiwon Yoon committed
6

Jiwon Yoon's avatar
Jiwon Yoon committed
7
const MovieComming = () => {
Jiwon Yoon's avatar
Jiwon Yoon committed
8
9
10
11
12
13
14
15
16
17
18
19
    const [TMDB_UpComming_Data, setTMDB_UpComming_Data] = useState()
    useEffect(() => {
        getTMDB_UpComming()
    }, [])

    async function getTMDB_UpComming() {
        try {
            const response = await axios.get(`${baseUrl}/api/movie/upcomming`)
            console.log(response.data)
            setTMDB_UpComming_Data([...response.data])
        } catch (error) {

Jiwon Yoon's avatar
Jiwon Yoon committed
20
        }
Jiwon Yoon's avatar
Jiwon Yoon committed
21
    }
Jiwon Yoon's avatar
Jiwon Yoon committed
22
23
    return (
        <div class="row row-cols-1 row-cols-md-4 g-4">
Jiwon Yoon's avatar
Jiwon Yoon committed
24
            {TMDB_UpComming_Data
Jiwon Yoon's avatar
Jiwon Yoon committed
25
                ?
Jiwon Yoon's avatar
Jiwon Yoon committed
26
                TMDB_UpComming_Data.map(movie => (
Jiwon Yoon's avatar
Jiwon Yoon committed
27
                    <div className="card h-100" style={{ backgroundColor: "black" }}>
Jiwon Yoon's avatar
Jiwon Yoon committed
28
29
30
31
32
33
34
35
36
                        <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>
Jiwon Yoon's avatar
Jiwon Yoon committed
37
                        <div className="card-body text-light">
Jiwon Yoon's avatar
Jiwon Yoon committed
38
39
                            <marquee onmouseover="this.stop()" className={`h2 card-title text-center ${styles.title}`}>{movie.title}</marquee>
                            <p className="card-text text-center">{movie.runtime}</p>
Jiwon Yoon's avatar
Jiwon Yoon committed
40
41
42
43
44
45
46
47
48
49
50
51
                            <p className="card-text text-center"><small className="text-muted">{movie.release_date} 개봉</small></p>
                        </div>
                        <button className="btn btn-warning">예매하기</button>
                    </div>
                ))
                : <div>영화정보를 로딩할  없습니다.</div>
            }
        </div>
    )
}

export default MovieComming