Commit 0bf6eed2 authored by Jiwon Yoon's avatar Jiwon Yoon
Browse files

영화관 정보 수정

parent d54d94d2
...@@ -17,6 +17,7 @@ const INIT_CINEMAINFO = { ...@@ -17,6 +17,7 @@ const INIT_CINEMAINFO = {
const CinemaEdit = () => { const CinemaEdit = () => {
const [cinemaInfo, setCinemaInfo] = useState(INIT_CINEMAINFO) const [cinemaInfo, setCinemaInfo] = useState(INIT_CINEMAINFO)
const [theaterTypeList, setTheaterTypeList] = useState([]) const [theaterTypeList, setTheaterTypeList] = useState([])
const [theaterInfo, setTheaterInfo] = useState({ theaterCount: 0, seatCount: 0 })
const [selectTheater, setSelectTheater] = useState(0) const [selectTheater, setSelectTheater] = useState(0)
const [ticketFee, setTicketFee] = useState({}) const [ticketFee, setTicketFee] = useState({})
const [error, setError] = useState("") const [error, setError] = useState("")
...@@ -25,6 +26,7 @@ const CinemaEdit = () => { ...@@ -25,6 +26,7 @@ const CinemaEdit = () => {
useEffect(() => { useEffect(() => {
getInfo() getInfo()
getTicketFeeInfo() getTicketFeeInfo()
getTheaterInfo()
}, []) }, [])
function handleChange(e) { function handleChange(e) {
...@@ -63,13 +65,27 @@ const CinemaEdit = () => { ...@@ -63,13 +65,27 @@ const CinemaEdit = () => {
} }
} }
async function getTheaterInfo() {
try {
const theaterInfo = await theaterApi.getAll()
if (theaterInfo) {
const theaterCount = theaterInfo.length
const seatCount = theaterInfo.map(el=>el.rows*el.columns).reduce((acc, cur, idx) => { return acc += cur }, 0)
console.log(seatCount)
setTheaterInfo({ theaterCount: theaterCount, seatCount: seatCount })
}
} catch (error) {
catchErrors(error, setError)
}
}
return ( return (
<> <>
<h2 className="border-bottom border-2 text-center pb-2 me-2">현재 영화관 정보</h2> <h2 className="border-bottom border-2 text-center pb-2 me-2">현재 영화관 정보</h2>
<div className="mb-3"> <div className="mb-3">
<label htmlfor="cinemaName" className="form-label">영화관 이름</label> <label htmlfor="cinemaName" className="form-label">영화관 이름</label>
<input type="text" className={`form-control mb-2 ${styles.shadowNone}`} id="cinemaName" name="cinemaName" value={cinemaInfo.cinemaName} onChange={handleChange} /> <input type="text" className={`form-control mb-2 ${styles.shadowNone}`} id="cinemaName" name="cinemaName" value={cinemaInfo.cinemaName} onChange={handleChange} />
<p> 상영관 : 8개관 | 좌석 : 1,282</p> <p> 상영관 : {theaterInfo.theaterCount}개관 | 좌석 : {theaterInfo.seatCount}</p>
</div> </div>
<div className="mb-3"> <div className="mb-3">
<label htmlfor="transportation" className="form-label">대중교통 안내</label> <label htmlfor="transportation" className="form-label">대중교통 안내</label>
...@@ -89,7 +105,7 @@ const CinemaEdit = () => { ...@@ -89,7 +105,7 @@ const CinemaEdit = () => {
<TicketEditForm editFee={ticketFee} formRef={formRef} /> <TicketEditForm editFee={ticketFee} formRef={formRef} />
<label className="form-label">영화관람료 안내</label> <label className="form-label">영화관람료 안내</label>
<nav aria-label="breadcrumb"> <nav aria-label="breadcrumb">
<ol className={"breadcrumb" + (theaterTypeList.length === 0 ? " d-flex justify-content-center" : "" )}> <ol className={"breadcrumb" + (theaterTypeList.length === 0 ? " d-flex justify-content-center" : "")}>
{theaterTypeList.length !== 0 ? theaterTypeList.map(theater => <li className={`breadcrumb-item ${styles.cursor}`} key={theater.id} onClick={() => setSelectTheater(theater.id)}>{theater.theaterTypeName}</li>) {theaterTypeList.length !== 0 ? theaterTypeList.map(theater => <li className={`breadcrumb-item ${styles.cursor}`} key={theater.id} onClick={() => setSelectTheater(theater.id)}>{theater.theaterTypeName}</li>)
: <li>등록된 관람료 관련 정보가 없습니다.</li>} : <li>등록된 관람료 관련 정보가 없습니다.</li>}
</ol> </ol>
......
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