import { Link, useHistory } from 'react-router-dom' import { useState, useEffect, useRef } from 'react' import { Modal } from 'bootstrap' import CountButton from '../components/CountButton' import SeatTable from '../components/SeatTable/SeatTable' import styles from '../components/SeatTable/seatTable.module.scss' import axios from 'axios' import { useAuth } from '../context/auth_context.js' const TicketingSeatPage = ({ location }) => { const history = useHistory() const modalRef = useRef(null) const modal = useRef() const { user } = useAuth() const [ticketInfo, setTicketInfo] = useState({ ...location.state }) const [theaterInfo, setTheaterInfo] = useState() const [selectedSeats, setSelectedSeats] = useState([]) const [reservedSeats, setReservedSeats] = useState([]) const [count, setCount] = useState({ adult: 0, teenager: 0, elderly: 0 }) useEffect(() => { getInfo() }, []) async function getInfo() { try { const response = await axios.post('/api/theater/getInfo', { theaterNum: ticketInfo.selectedTheater }) console.log(response.data) setTheaterInfo(response.data) const response2 = await axios.post('/api/reservation/findreservation', { timetable: 1 }) console.log(response2.data) const reserve = response2.data.map((el) => el.row + '-' + el.col ) setReservedSeats(reserve) } catch (error) { console.log(error) } } function loginModal() { if (user) { history.push("/payment", { ...ticketInfo, selectedSeats: selectedSeats, ...count }); } else { modal.current = new Modal(modalRef.current) modal.current?.show() } } return ( <>
{ }
로그인이 필요한 서비스입니다.
로그인을 하시겠습니까? 비회원예매로 진행하시겠습니까?
{console.log(ticketInfo)} {console.log(reservedSeats)}

좌석선택

일반
청소년
경로우대
{ticketInfo.cinema} | {ticketInfo.selectedTheater}관
{ticketInfo.title}
{ticketInfo.time}
선택됨
선택불가
{ticketInfo ? 영화포스터 :
영화선택
}
극장선택
{ticketInfo ?
  • 영화: {ticketInfo.title}
  • 극장: {ticketInfo.cinema}
  • 일시: 2021/07/21 10:00
  • 상영관: 3관
  • 좌석: {selectedSeats}
:
}
결제하기
{ticketInfo ? : }
) } export default TicketingSeatPage