import { useState, useEffect, useRef } from "react"; import TicketEditForm from "./TicketEditForm.js"; import TicketFeeTable from "./TicketFeeTable.js"; import cinemaApi from "../../apis/cinema.api.js"; import theaterApi from "../../apis/theater.api.js"; import catchErrors from "../../utils/catchErrors.js"; import styles from "./admin.module.scss"; const INIT_CINEMAINFO = { cinemaName: "", transportation: "", parking: "", address: "", moreFeeInfo: "" } const CinemaEdit = () => { const [cinemaInfo, setCinemaInfo] = useState(INIT_CINEMAINFO) const [theaterTypeList, setTheaterTypeList] = useState([]) const [selectTheater, setSelectTheater] = useState(0) const [ticketFee, setTicketFee] = useState({}) const [error, setError] = useState("") const formRef = useRef(null) useEffect(() => { getInfo() getTicketFeeInfo() }, []) function handleChange(e) { const { name, value } = e.target setCinemaInfo({ ...cinemaInfo, [name]: value }) } async function getInfo() { try { setError("") const info = await cinemaApi.getCinemaInfo() if (info) setCinemaInfo(info) else setCinemaInfo(INIT_CINEMAINFO) } catch (error) { catchErrors(error, setError) } } async function handleSubmit() { try { setError("") await cinemaApi.editCinema(cinemaInfo) window.location.reload() } catch (error) { catchErrors(error, setError) } } async function getTicketFeeInfo() { try { setError("") const res = await theaterApi.getTheaterType() setTheaterTypeList(res) } catch (error) { catchErrors(error, setError) } } return ( <>

현재 영화관 정보

총 상영관 수: 8개관 | 총 좌석 수: 1,282석

영화관람료 설정

*추가금액 정보를 입력바랍니다. 필요에 따라 기본가격 또한 변경 가능합니다.

) } export default CinemaEdit