import { useState, useEffect } from "react"; import cinemaApi from "../../apis/cinema.api.js"; import catchErrors from "../../utils/catchErrors.js"; import { useAuth } from '../../context/auth_context' import styles from "./admin.module.scss"; const TicketFeeTable = ({ setEditFee, formRef }) => { const [ticketFee, setTicketFee] = useState([]) const [error, setError] = useState("") const { user } = useAuth() useEffect(() => { getInfo() }, []) async function getInfo() { try { const res = await cinemaApi.getTicketFee() setTicketFee(res) } catch (error) { catchErrors(error, setError) } } async function editRow(theatertypeId) { try { setError("") const res = await cinemaApi.getTicketFeeOne(theatertypeId) setEditFee({ ...res }) formRef?.current.scrollIntoView({ behavior: "smooth", block: "center" }) } catch (error) { catchErrors(error, setError) } } async function deleteData(theatertypeId) { try { setError("") await cinemaApi.removeTicketFee(theatertypeId) alert("해당 관람료 정보를 성공적으로 삭제했습니다.") getInfo() } catch (error) { catchErrors(error, setError) } } function priceToString(price) { return price.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ','); } return (
상영관 종류 | 주중 / 주말 | 시간대 | 청소년 | 일반 | 경로 | {user.role === "admin" ?: <>>} |
---|---|---|---|---|---|---|
{info.theatertype.theaterTypeName} | 주중(월~목) | 조조 (06:00 ~ ) | {priceToString(info.weekdays + info.morning + info.youth + info.defaultPrice)}원 | {priceToString(info.weekdays + info.morning + info.adult + info.defaultPrice)}원 | {priceToString(info.weekdays + info.morning + info.senior + info.defaultPrice)}원 | {user.role === "admin" ?
|
: <>>}
일반 (11:00 ~ ) | {priceToString(info.weekdays + info.day + info.youth + info.defaultPrice)}원 | {priceToString(info.weekdays + info.day + info.adult + info.defaultPrice)}원 | {priceToString(info.weekdays + info.day + info.senior + info.defaultPrice)}원 | |||
심야 (00:00 ~ ) | {priceToString(info.weekdays + info.night + info.youth + info.defaultPrice)}원 | {priceToString(info.weekdays + info.night + info.adult + info.defaultPrice)}원 | {priceToString(info.weekdays + info.night + info.senior + info.defaultPrice)}원 | |||
주말(금~일) 및 공휴일 | 조조 (06:00 ~ ) | {priceToString(info.weekend + info.morning + info.youth + info.defaultPrice)}원 | {priceToString(info.weekend + info.morning + info.adult + info.defaultPrice)}원 | {priceToString(info.weekend + info.morning + info.senior + info.defaultPrice)}원 | ||
일반 (11:00 ~ ) | {priceToString(info.weekend + info.day + info.youth + info.defaultPrice)}원 | {priceToString(info.weekend + info.day + info.adult + info.defaultPrice)}원 | {priceToString(info.weekend + info.day + info.senior + info.defaultPrice)}원 | |||
심야 (00:00 ~ ) | {priceToString(info.weekend + info.night + info.youth + info.defaultPrice)}원 | {priceToString(info.weekend + info.night + info.adult + info.defaultPrice)}원 | {priceToString(info.weekend + info.night + info.senior + info.defaultPrice)}원 | {user.role === "admin" ?
|
: <>>}
||
등록된 관람료 관련 정보가 없습니다. |