Skip to content
Snippets Groups Projects
Search.js 1.14 KiB
Newer Older
LEE's avatar
LEE committed
import { Map, MapMarker } from "react-kakao-maps-sdk";
import React, { useState, useEffect, useContext } from 'react';
import {Routes, Route, Link, useNavigate, Navigate  } from 'react-router-dom';
Hyun Woo Jeong's avatar
Hyun Woo Jeong committed
import SearchMap from '../components/SearchMapByKeyword.js'
import { UserContext } from '../Context.js';
LEE's avatar
LEE committed
const {kakao} = window;

LEE's avatar
LEE committed
function Search(props) {

    const userContext = useContext(UserContext);
	const navigate = useNavigate();
	function MoveTo(link){
		navigate(link)
	}	
Hyun Woo Jeong's avatar
Hyun Woo Jeong committed

    const [location, setLocation] = useState({
        keyword: "",
        center: { lat: null, lng: null }
    });

    useEffect(() => {
        const session = userContext.CheckSession()
        .then((response) => {
            if (!response.data) {
                alert("세션이 만료되었습니다. 다시 로그인 바랍니다.")
                MoveTo('/login')
             }
		})
		.catch((response)=>{
			console.log("error!:LogOut")
			console.log(response)
		})
      });

LEE's avatar
LEE committed
    return (
		<div className="search">
			<h1>검색페이지입니다.</h1>
Hyun Woo Jeong's avatar
Hyun Woo Jeong committed
            <SearchMap loc={location} setLoc={setLocation}></SearchMap>  
LEE's avatar
LEE committed
		</div>
    );
}

LEE's avatar
LEE committed
export default Search;