BoxOffice.js 10.5 KB
Newer Older
Jiwon Yoon's avatar
Jiwon Yoon committed
1
import { Link } from "react-router-dom"
Kim, Subin's avatar
Kim, Subin committed
2

3
const BoxOffice = ({ TMDB_TopRated_Data }) => {
Jiwon Yoon's avatar
Jiwon Yoon committed
4

Kim, Subin's avatar
Kim, Subin committed
5
    return (
Jiwon Yoon's avatar
Jiwon Yoon committed
6
        <div className="container text-center my-3">
Jiwon Yoon's avatar
Jiwon Yoon committed
7
            <h2 className="fw-bold text-white text-center my-5">BoxOffice</h2>
8
9
            {console.log(TMDB_TopRated_Data)}
            <div id="carouselExampleControls" className="carousel slide" data-bs-ride="carousel">
Kim, Subin's avatar
Kim, Subin committed
10
                <div className="carousel-inner">
11
                    {TMDB_TopRated_Data.length > 0
Kim, Subin's avatar
Kim, Subin committed
12
                        ?
Jiwon Yoon's avatar
Jiwon Yoon committed
13
                        TMDB_TopRated_Data.map((movie, index) =>
14
                            <div className={`carousel-item ${index === 0 ? " active" : ""}`}>
Jiwon Yoon's avatar
Jiwon Yoon committed
15
16
17
18
19
20
21
22
23
24
25
                                <Link to={{
                                    pathname: `/movie/${movie.id}`,
                                    state: {
                                        ...movie
                                    }
                                }}
                                >
                                    <img src={`https://image.tmdb.org/t/p/original${movie.poster_path}`} style={{ width: "200px" }} className="" alt="Movie Poster" />

                                </Link>
                                <div className="mt-1 text-white">{index + 1}</div>
Jiwon Yoon's avatar
Jiwon Yoon committed
26
                            </div>
Jiwon Yoon's avatar
Jiwon Yoon committed
27
                        )
Kim, Subin's avatar
Kim, Subin committed
28
29
30
31
                        :
                        <div className="carousel-item">
                            {console.log("스틸컷 불러오기 오류")}
                            <img src="/images/none.jpg" className="d-block w-100" alt="등록된 스틸컷이 없습니다." />
Jiwon Yoon's avatar
Jiwon Yoon committed
32
                        </div>
Kim, Subin's avatar
Kim, Subin committed
33
                    }
Kim, Subin's avatar
Kim, Subin committed
34
                </div>
Kim, Subin's avatar
Kim, Subin committed
35
36
37
38
39
40
41
42
                <button className="carousel-control-prev" type="button" data-bs-target="#carouselExampleControls" data-bs-slide="prev">
                    <span className="carousel-control-prev-icon" aria-hidden="true"></span>
                    <span className="visually-hidden">Previous</span>
                </button>
                <button className="carousel-control-next" type="button" data-bs-target="#carouselExampleControls" data-bs-slide="next">
                    <span className="carousel-control-next-icon" aria-hidden="true"></span>
                    <span className="visually-hidden">Next</span>
                </button>
43
            </div>
Kim, Subin's avatar
Kim, Subin committed
44

Jiwon Yoon's avatar
Jiwon Yoon committed
45
        </div>
Kim, Subin's avatar
Kim, Subin committed
46
47
48
    )
}

Kim, Subin's avatar
Kim, Subin committed
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
export default BoxOffice

// import { useState, useEffect } from "react"
// import movieApi from '../../apis/movie.api.js'
// import "./box-office.module.css"

// const BoxOffice = () => {
//     const [TMDB_TopRated_Data, setTMDB_TopRated_Data] = useState()
//     useEffect(() => {
//         // getTMDB_TopRated()
//         let items = document.querySelectorAll('.carousel .carousel-item')
//         // console.log("item", items)
//         items.forEach((el) => {
//             const minPerSlide = 4
//             let next = el.nextElementSibling
//             for (let i = 1; i < minPerSlide; i++) {
//                 if (!next) {
//                     // wrap carousel by using first child
//                     next = items[0]
//                 }
//                 let cloneChild = next.cloneNode(true)
//                 el.appendChild(cloneChild.children[0])
//                 next = next.nextElementSibling
//             }
//         })
//     }, [])

//     async function getTMDB_TopRated() {
//         const category = "popular"
//         try {
//             const data = await movieApi.getMoviesfromTM(category)
//             console.log(data)
//             setTMDB_TopRated_Data(data)
//         } catch (error) {
//             console.log(error)
//         }
//     }

//     return (
//         <div className="container text-center my-3">
//             {console.log(TMDB_TopRated_Data)}
//             <div className="container text-center my-3">
//                 <h2 className="font-weight-light">Bootstrap Multi Slide Carousel</h2>
//                 <div className="row mx-auto my-auto justify-content-center">
//                     <div id="recipeCarousel" className="carousel slide" data-bs-ride="carousel">
//                         <div className="carousel-inner" role="listbox">
//                             <div className="carousel-item active">
//                                 <div className="col-md-3">
//                                     <div className="card">
//                                         <div className="card-img">
//                                             <img src="//via.placeholder.com/500x400/31f?text=1" className="img-fluid" />
//                                         </div>
//                                         <div className="card-img-overlay">Slide 1</div>
//                                     </div>
//                                 </div>
//                             </div>
//                             <div className="carousel-item">
//                                 <div className="col-md-3">
//                                     <div className="card">
//                                         <div className="card-img">
//                                             <img src="//via.placeholder.com/500x400/e66?text=2" className="img-fluid" />
//                                         </div>
//                                         <div className="card-img-overlay">Slide 2</div>
//                                     </div>
//                                 </div>
//                             </div>
//                             <div className="carousel-item">
//                                 <div className="col-md-3">
//                                     <div className="card">
//                                         <div className="card-img">
//                                             <img src="//via.placeholder.com/500x400/7d2?text=3" className="img-fluid" />
//                                         </div>
//                                         <div className="card-img-overlay">Slide 3</div>
//                                     </div>
//                                 </div>
//                             </div>
//                             <div className="carousel-item">
//                                 <div className="col-md-3">
//                                     <div className="card">
//                                         <div className="card-img">
//                                             <img src="//via.placeholder.com/500x400?text=4" className="img-fluid" />
//                                         </div>
//                                         <div className="card-img-overlay">Slide 4</div>
//                                     </div>
//                                 </div>
//                             </div>
//                             <div className="carousel-item">
//                                 <div className="col-md-3">
//                                     <div className="card">
//                                         <div className="card-img">
//                                             <img src="//via.placeholder.com/500x400/aba?text=5" className="img-fluid" />
//                                         </div>
//                                         <div className="card-img-overlay">Slide 5</div>
//                                     </div>
//                                 </div>
//                             </div>
//                             <div className="carousel-item">
//                                 <div className="col-md-3">
//                                     <div className="card">
//                                         <div className="card-img">
//                                             <img src="//via.placeholder.com/500x400/fc0?text=6" className="img-fluid" />
//                                         </div>
//                                         <div className="card-img-overlay">Slide 6</div>
//                                     </div>
//                                 </div>
//                             </div>
//                         </div>
//                         <a className="carousel-control-prev bg-transparent w-aut" href="#recipeCarousel" role="button" data-bs-slide="prev">
//                             <span className="carousel-control-prev-icon" aria-hidden="true"></span>
//                         </a>
//                         <a className="carousel-control-next bg-transparent w-aut" href="#recipeCarousel" role="button" data-bs-slide="next">
//                             <span className="carousel-control-next-icon" aria-hidden="true"></span>
//                         </a>
//                     </div>
//                 </div>
//                 <h5 className="mt-2 fw-light">advances one slide at a time</h5>
//             </div>
//             <div className="row my-auto justify-content-center">
//                 <div id="recipeCarousel" className="carousel slide" data-bs-ride="carousel" data-bs-interval="999999999">
//                     <div className={`carousel-inner`} role="listbox">
//                         {TMDB_TopRated_Data ?
//                             TMDB_TopRated_Data.map((moviePoster, index) => (
//                                 <div className={`carousel-item ${index === 0 ? "active" : ""}`}>
//                                     <div className="col-sm-3">
//                                         <div className="card">
//                                             <div className="card-img">
//                                                 <img src={`https://image.tmdb.org/t/p/original${moviePoster.poster_path}`} className="img-fluid" />
//                                             </div>
//                                         </div>
//                                     </div>
//                                 </div>
//                             ))
//                             : (<div>영화를 불러올 수 없습니다:(</div>)}
//                     </div>
//                     <a className="carousel-control-prev bg-transparent w-aut" href="#recipeCarousel" role="button"
//                         data-bs-slide="prev">
//                         <span className="carousel-control-prev-icon" aria-hidden="true"></span>
//                     </a>
//                     <a className="carousel-control-next bg-transparent w-aut" href="#recipeCarousel" role="button"
//                         data-bs-slide="next">
//                         <span className="carousel-control-next-icon" aria-hidden="true"></span>
//                     </a>
//                 </div>
//             </div>
//         </div>
//     )
// }

// export default BoxOffice