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_TICKETFEE = { theaterType: "", weekdays: "", weekend: "", morning: "", day: "", night: "", youth: "", adult: "", senior: "", defaultPrice: 5000 } const TicketEditForm = ({ editFee, formRef }) => { const [ticketFee, setTicketFee] = useState(INIT_TICKETFEE) const [error, setError] = useState("") useEffect(() => { setTicketFee({ ...ticketFee, ...editFee }) }, [editFee]) function handleChange(e) { const { name, value } = e.target setTicketFee({ ...ticketFee, [name]: value }) } async function handleSubmit(e) { e.preventDefault() try { setError("") await cinemaApi.editTicketFee(ticketFee) alert("해당 관람료 정보 등록이 성공적으로 완료되었습니다.") window.location.reload() } catch (error) { catchErrors(error, setError) } } return (
) } export default TicketEditForm