TheaterPage.js 4.03 KB
Newer Older
Kim, Subin's avatar
Kim, Subin committed
1
import { useState, useEffect } from 'react'
Kim, Subin's avatar
Kim, Subin committed
2
3
import TicketFeeTable from '../components/Admin/TicketFeeTable'
import TheaterInfo from '../components/TheaterInfo'
Kim, Subin's avatar
Kim, Subin committed
4
5
import theaterApi  from '../apis/theater.api.js'
import catchErrors from "../utils/catchErrors.js";
Jiwon Yoon's avatar
Jiwon Yoon committed
6

7
const TheaterPage = () => {
Kim, Subin's avatar
Kim, Subin committed
8
    const [theaterTypeList, setTheaterTypeList] = useState([])
Jiwon Yoon's avatar
Jiwon Yoon committed
9
    const [state, setState] = useState(0)
Kim, Subin's avatar
Kim, Subin committed
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
    const [selectTheater, setSelectTheater] = useState(0)
    const [error, setError] = useState("")

    useEffect(() => {
        getTicketFeeInfo()
    }, [])

    async function getTicketFeeInfo() {
        try {
            setError("")
            const res = await theaterApi.getTheaterType()
            setTheaterTypeList(res)
        } catch (error) {
            catchErrors(error, setError)
        }
    }

27
28
    return (
        <div>
Kim, Subin's avatar
Kim, Subin committed
29
            <div>
Jiwon Yoon's avatar
Jiwon Yoon committed
30
31
32
33
34
35
36
37
38
39
40
41
42
43
                <ul className="nav nav-tabs justify-content-center my-4 border-0" id="myTab" role="tablist">
                    <li className="nav-item" role="presentation">
                        <button className="nav-link active mx-auto" style={{ color: "white", borderColor: "black", backgroundColor: "black", borderBottom: state === 0 ? "3px solid" : "none", borderBottomColor: state === 0 ? "#FEDC00" : "black" }} id="overview-tab" data-bs-toggle="tab" data-bs-target="#overview" type="button" role="tab" aria-controls="overview" aria-selected="true" onClick={() => setState(0)}>극장정보</button>
                    </li>
                    <li className="nav-item" role="presentation">
                        <button className="nav-link mx-auto" style={{ color: "white", borderColor: "black", backgroundColor: "black", borderBottom: state === 1 ? "3px solid" : "none", borderBottomColor: state === 1 ? "#FEDC00" : "black" }} id="stillcut-tab" data-bs-toggle="tab" data-bs-target="#stillcut" type="button" role="tab" aria-controls="stillcut" aria-selected="false" onClick={() => setState(1)}>상영시간표</button>
                    </li>
                    <li className="nav-item" role="presentation">
                        <button className="nav-link mx-auto" style={{ color: "white", borderColor: "black", backgroundColor: "black", borderBottom: state === 2 ? "3px solid" : "none", borderBottomColor: state === 2 ? "#FEDC00" : "black" }} id="review-tab" data-bs-toggle="tab" data-bs-target="#review" type="button" role="tab" aria-controls="review" aria-selected="false" onClick={() => setState(2)}>관람료</button>
                    </li>
                </ul>
            </div>
            <div className="tab-content text-center" id="myTabContent" style={{ color: "white" }}>
                <div className="tab-pane fade show active" id="overview" role="tabpanel" aria-labelledby="overview-tab">
Kim, Subin's avatar
Kim, Subin committed
44
                    <TheaterInfo />
Jiwon Yoon's avatar
Jiwon Yoon committed
45
46
                </div>
                <div className="tab-pane fade" id="stillcut" role="tabpanel" aria-labelledby="stillcut-tab">
47
                    <div className="pb-5">상영시간표</div>
Jiwon Yoon's avatar
Jiwon Yoon committed
48
49
                </div>
                <div className="tab-pane fade" id="review" role="tabpanel" aria-labelledby="review-tab">
Kim, Subin's avatar
Kim, Subin committed
50
                    <div className="d-flex justify-content-center">
Kim, Subin's avatar
Kim, Subin committed
51
                        <div className="col-sm-9 pb-5">
Kim, Subin's avatar
Kim, Subin committed
52
53
54
55
56
57
58
                            <nav aria-label="breadcrumb">
                                <ol className={"breadcrumb" + (theaterTypeList.length === 0 ? " d-flex justify-content-center" : "")}>
                                    {theaterTypeList.length !== 0 ? theaterTypeList.map(theater => <li className="breadcrumb-item" key={theater.id} onClick={() => setSelectTheater(theater.id)} style={{ cursor: "pointer" }}>{theater.theaterTypeName}</li>)
                                        : <li>등록된 관람료 관련 정보가 없습니다.</li>}
                                </ol>
                            </nav>
                            <TicketFeeTable selectTheater={selectTheater} />
Kim, Subin's avatar
Kim, Subin committed
59
60
                        </div>
                    </div>
Jiwon Yoon's avatar
Jiwon Yoon committed
61
62
                </div>
            </div>
63
64
65
66
67
        </div>
    )
}

export default TheaterPage