Commit 7262e03c authored by Kim, Subin's avatar Kim, Subin
Browse files

영화관람표 관련 컴포넌트 추가

parent 6493078a
import { useState, useEffect } from "react"; import { useState, useEffect } from "react";
import TicketEditForm from "./TicketEditForm.js";
import TicketFeeTable from "./TicketFeeTable.js";
import cinemaApi from "../../apis/cinema.api.js"; import cinemaApi from "../../apis/cinema.api.js";
import catchErrors from "../../utils/catchErrors.js"; import catchErrors from "../../utils/catchErrors.js";
import styles from "./admin.module.scss"; import styles from "./admin.module.scss";
const INIT_CINEMAINFO = { const INIT_CINEMAINFO = {
cinemaName: "", cinemaName: "",
transportation: "", transportation: "",
parking: "", parking: "",
address: "" address: "",
moreFeeInfo: ""
} }
const CinemaEdit = () => { const CinemaEdit = () => {
const [cinemaInfo, setCinemaInfo] = useState(INIT_CINEMAINFO) const [cinemaInfo, setCinemaInfo] = useState(INIT_CINEMAINFO)
const [ticketFee, setTicketFee] = useState({})
const [error, setError] = useState("") const [error, setError] = useState("")
useEffect(() => { useEffect(() => {
...@@ -26,7 +30,7 @@ const CinemaEdit = () => { ...@@ -26,7 +30,7 @@ const CinemaEdit = () => {
async function getInfo() { async function getInfo() {
try { try {
setError("") setError("")
const info = await cinemaApi.getInfo() const info = await cinemaApi.getCinemaInfo()
if (info) setCinemaInfo(info) if (info) setCinemaInfo(info)
else setCinemaInfo(INIT_CINEMAINFO) else setCinemaInfo(INIT_CINEMAINFO)
} catch (error) { } catch (error) {
...@@ -37,7 +41,7 @@ const CinemaEdit = () => { ...@@ -37,7 +41,7 @@ const CinemaEdit = () => {
async function handleSubmit() { async function handleSubmit() {
try { try {
setError("") setError("")
await cinemaApi.edit(cinemaInfo) await cinemaApi.editCinema(cinemaInfo)
window.location.reload() window.location.reload()
} catch (error) { } catch (error) {
catchErrors(error, setError) catchErrors(error, setError)
...@@ -65,6 +69,14 @@ const CinemaEdit = () => { ...@@ -65,6 +69,14 @@ const CinemaEdit = () => {
<span className="input-group-text" id="address"><i className="bi bi-geo-alt-fill"></i></span> <span className="input-group-text" id="address"><i className="bi bi-geo-alt-fill"></i></span>
<input type="text" className={`form-control ${styles.shadowNone}`} id="address" name="address" value={cinemaInfo.address} onChange={handleChange} value={cinemaInfo.address} /> <input type="text" className={`form-control ${styles.shadowNone}`} id="address" name="address" value={cinemaInfo.address} onChange={handleChange} value={cinemaInfo.address} />
</div> </div>
<p className="mb-0">영화관람료 설정</p>
<p className="text-danger">*추가금액 정보를 입력바랍니다. 필요에 따라 기본가격 또한 변경 가능합니다.</p>
<TicketEditForm editFee={ticketFee} />
<TicketFeeTable editFee={ticketFee} setEditFee={setTicketFee} />
<div className="mb-3">
<label for="moreFeeInfo" className="form-label">관람료 추가정보</label>
<textarea className={`form-control ${styles.shadowNone} ${styles.textarea}`} rows="7" id="moreFeeInfo" name="moreFeeInfo" value={cinemaInfo.moreFeeInfo} onChange={handleChange}></textarea>
</div>
<div className="d-grid gap-2 mb-5"> <div className="d-grid gap-2 mb-5">
<button type="submit" className={`btn btn-dark shadow-none ${styles.customBtn}`} onClick={handleSubmit}>수정</button> <button type="submit" className={`btn btn-dark shadow-none ${styles.customBtn}`} onClick={handleSubmit}>수정</button>
</div> </div>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment