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({ movieId: 0, ...location.state, cinema: "", selectedTheater: "", time: "" }) const [cinemaInfo, setCinemaInfo] = useState({}) const [movieInfo, setMovieInfo] = useState() const [error, setError] = useState("") useEffect(() => { getCinemaInfo() }, []) useEffect(() => { if (ticketInfo.movieId > 0) { 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) { catchErrors(error, setError) } } return (