import { useState, useEffect } from "react"; import cinemaApi from "../../apis/cinema.api.js"; import catchErrors from "../../utils/catchErrors.js"; import styles from "./admin.module.scss"; const INIT_CINEMAINFO = { cinemaName: "", transportation: "", parking: "", address: "" } const CinemaEdit = () => { const [cinemaInfo, setCinemaInfo] = useState(INIT_CINEMAINFO) const [error, setError] = useState("") useEffect(() => { getInfo() }, []) function handleChange(e) { const { name, value } = e.target setCinemaInfo({ ...cinemaInfo, [name]: value }) } async function getInfo() { try { setError("") const info = await cinemaApi.getInfo() if (info) setCinemaInfo(info) else setCinemaInfo(INIT_CINEMAINFO) } catch (error) { catchErrors(error, setError) } } async function handleSubmit() { try { setError("") await cinemaApi.edit(cinemaInfo) window.location.reload() } catch (error) { catchErrors(error, setError) } } return ( <>
총 상영관 수: 8개관 | 총 좌석 수: 1,282석