import { useState, useEffect } from 'react' import axios from "axios" import catchErrors from "../utils/catchErrors" // import InfoModal from "./InfoModal" // const { kakao } = window; const TheaterInfo = () => { // if (kakao) { // console.log("kakao") // const mapContainer = document.getElementById('map'), // 지도를 표시할 div // mapOption = { // center: new kakao.maps.LatLng(33.450701, 126.570667), // 지도의 중심좌표 // level: 3 // 지도의 확대 레벨 // }; // // 지도를 생성합니다 // const map = new kakao.maps.Map(mapContainer, mapOption); // // 주소-좌표 변환 객체를 생성합니다 // const geocoder = new kakao.maps.services.Geocoder(); // // 주소로 좌표를 검색합니다 // geocoder.addressSearch('제주특별자치도 제주시 첨단로 242', function (result, status) { // // 정상적으로 검색이 완료됐으면 // if (status === kakao.maps.services.Status.OK) { // const coords = new kakao.maps.LatLng(result[0].y, result[0].x); // // 결과값으로 받은 위치를 마커로 표시합니다 // const marker = new kakao.maps.Marker({ // map: map, // position: coords // }); // // 인포윈도우로 장소에 대한 설명을 표시합니다 // const infowindow = new kakao.maps.InfoWindow({ // content: '
우리회사
' // }); // infowindow.open(map, marker); // // 지도의 중심을 결과값으로 받은 위치로 이동시킵니다 // map.setCenter(coords); // } // }); // } const [theaterInfo, setTheaterInfo] = useState() const [currentInfo, setCurrentInfo] = useState({ name: "init", title: "init", information: "init" }) const [error, setError] = useState() const [tabContent, setTabContent] = useState([]) useEffect(() => { getTheaterInfo() }, []) useEffect(() => { if (currentInfo.title === "parking") { setTabContent(
{currentInfo.information}
) } else if (currentInfo.title === "address") { setTabContent(
{currentInfo.information}
) } else { setTabContent(
{currentInfo.information}
) } }, [currentInfo]) async function getTheaterInfo() { try { const response = await axios.get('/api/info/cinema') const response2 = await axios.get('/api/theater') setTheaterInfo({...response.data, theaterNum:response2.data.length}) setCurrentInfo({ name:"대중교통 안내", title:"transportation", information: response.data.transportation }) } catch (error) { catchErrors(error, setError) } } function handleClick(e) { setCurrentInfo({ name: e.target.name, title: e.target.id, information: e.target.value }) } return ( <> {theaterInfo ?
{/* {console.log(currentInfo)} */} {console.log(theaterInfo)}

{theaterInfo.cinemaName}

총 상영관 수: {theaterInfo.theaterNum}개
{theaterInfo.address}
{tabContent}
:
극장정보를 불러올 수 없습니다.
} ) } export default TheaterInfo