import { useState, useEffect } from "react"; import theaterApi from "../../apis/theater.api.js"; import catchErrors from "../../utils/catchErrors.js"; import styles from "./admin.module.scss"; const TheaterTable = ({ setEdit, formRef }) => { const [theaterList, setTheaterList] = useState([]) const [error, setError] = useState("") useEffect(() => { getTheaterList() }, []) async function getTheaterList() { try { setError("") const list = await theaterApi.getAll() setTheaterList(list) } catch (error) { catchErrors(error, setError) } } async function editTheater(theaterId) { try { setError("") const res = await theaterApi.getOne(theaterId) setEdit({ ...res }) formRef?.current.scrollIntoView({ behavior: "smooth", block: "center" }) } catch (error) { catchErrors(error, setError) } } async function deleteTheater(theaterId) { try { setError("") await theaterApi.remove(theaterId) alert("해당 상영관 정보를 성공적으로 삭제했습니다.") getTheaterList() } catch (error) { catchErrors(error, setError) } } return ( {theaterList.length !== 0 ? theaterList.map(info => ) : }
상영관 이름 상영관 종류 좌석 정보
{info.theaterName}관 {info.theatertype.theaterTypeName} {info.rows}행 {info.columns}열
총 {info.rows*info.columns}석
등록된 상영관 정보가 없습니다.
) } export default TheaterTable