ReservationDetails.js 2.26 KB
Newer Older
한규민's avatar
한규민 committed
1
2
import { useState, useEffect } from "react";
import reservationApi from "../../apis/reservation.api";
한규민's avatar
한규민 committed
3
import styles from "./reservation-details.module.scss";
한규민's avatar
한규민 committed
4
5
import moment from 'moment';

한규민's avatar
한규민 committed
6
const ReservationDetails = () => {
한규민's avatar
한규민 committed
7
8
9
10
11
12
13
14
15

    const [movies, setMovies] = useState([]);
    const findReservaion = async () => {
        const movieList = await reservationApi.findOneReservation();
        setMovies(movieList);
    }
    useEffect(() => {
        findReservaion();
    }, [])
16
17
18
    return (
        <div className={`d-flex flex-column align-items-center ${styles.width}`}>
            <div className={`${styles.header}`}>나의 예매 내역</div>
한규민's avatar
한규민 committed
19
20
21
22
23
24
25
26
27
            {movies.length > 0
                ? movies.map(movie => (
                    <div className={`${styles.body}`}>
                        <div className={`d-flex justify-content-around align-items-center py-3`}>
                            <div className={`${styles.span} d-flex justify-content-center`}>
                                <img src={`https://image.tmdb.org/t/p/original${movie.poster_path}`} className={`card-img-top rounded ${styles.poster}`} alt="Movie Poster" />
                            </div>
                            <div className={`${styles.span} d-flex flex-column`}>
                                <span className={`${styles.layout}`}>{movie.title}</span>
한규민's avatar
한규민 committed
28
29
30
31
32
                                <span className={`${styles.layout}`}>{moment(movie.data).format('YYYY-MM-DD')}</span>
                                <span className={`${styles.layout}`}>{moment(movie.start_time).format('HH:mm')} ~ {moment(movie.end_time).format('HH:mm')}</span>
                                <span className={`${styles.layout}`}>{movie.theaterName}</span>
                                <span className={`${styles.layout}`}>{ String.fromCharCode(movie.row + 64)} {movie.col}</span>
                                <span className={`${styles.layout}`}>{movie.totalFee}</span>
한규민's avatar
한규민 committed
33
34
35
                                <span className={`${styles.layout}`}>{movie.payment}</span>
                            </div>
                        </div>
36
                    </div>
한규민's avatar
한규민 committed
37
38
                ))
                : <div className={`${styles.layout}`}>예매 내역이 존재하지 않습니다.</div>}
39
        </div>
한규민's avatar
한규민 committed
40
41
42
43
    )
}

export default ReservationDetails