import axios from 'axios' import { useState, useEffect } from 'react' import { Link } from 'react-router-dom' import movieApi from '../apis/movie.api.js' import cinemaApi from "../apis/cinema.api.js" import TicketingMovie from "../components/TicketingMovie/TicketingMovie.js" import TicketingTheater from "../components/TicketingTheater/TicketingTheater.js" import TicketingTimeTable from "../components/TicketingTimeTable/TicketingTimeTable.js" import catchErrors from "../utils/catchErrors.js" const TicketingPage = ({ location }) => { const [ticketInfo, setTicketInfo] = useState({ ...location.state, cinema: "", selectedTheater: 1, time: "2021/07/21 10:00" }) const [cinemaInfo, setCinemaInfo] = useState({}) const [movieInfo, setMovieInfo] = useState() const [error, setError] = useState("") useEffect(() => { getCinemaInfo() }, []) useEffect(() => { getCinemaInfo() }, []) useEffect(() => { getMovieInfo() }, [ticketInfo]) async function getMovieInfo() { try { const data = await movieApi.getMovieInfofromTM(ticketInfo.movieId) setMovieInfo(data) } catch (error) { catchErrors(error, setError) } } async function getCinemaInfo() { try { const response = await cinemaApi.getCinemaInfo() setCinemaInfo(response.data) } catch (error) { catchErrors(error, setError) } } async function getCinemaInfo() { try { const response = await axios.get('/api/info/cinema') console.log(response.data) setCinemaInfo(response.data) } catch (error) { console.log(error) } } return (