Commit f81deda0 authored by Lee SeoYeon's avatar Lee SeoYeon
Browse files

..

parent 7af468a7
This diff is collapsed.
......@@ -3,11 +3,10 @@ import { Alert, Col, Card, Container, Form, Row, Button, Nav, Navbar, ListGroup,
import axios from "axios"
import catchErrors from './utils/catchErrors.js'
import { isAuthenticated } from './utils/auth'
import { Redirect } from 'react-router-dom'
const INIT_PAGE = {
bookmark: ['제주도'],
bookmark: ['한라산'],
bookmark: ['성산일출봉', '제주도', '한라산', '주상절리', '오설록 티 뮤지엄'],
}
......@@ -16,22 +15,39 @@ const user = isAuthenticated()
function Bookmark() {
const [page, setPage] = useState(INIT_PAGE)
const [error, setError] = useState('')
const [success, setSuccess] = useState(false)
const [state, setState] = useState(false);
const user = isAuthenticated()
async function getBookmark(user) {
const userId = localStorage.getItem('loginStatus')
async function getBookmark( ) {
try {
setError('')
const response = await axios.post(`/api/users/bookmark/${user}`)
setPage(response.data)
console.log(page)
console.log(userId)
await axios.post(`/api/users/bookmark`, {bookmark: page, userId: userId})
} catch (error) {
catchErrors(error, setError)
}
}
useEffect(() => {
Bookmark(user)
}, [user])
// async function handleSubmit(e){
// setState(true); //버튼이 눌려서 handlesubmit이될때 setState값이 true로 바뀐다
// try { //respons 서버에 post로 요청하여 데이터를 받아온다
// const response = await axios.post('/api/users/bookmark', page)
// setSuccess(true)
// } catch (error) {
// console.log(error)
// catchErrors(error, setError)
// }
// }
// useEffect(() => {
// getBookmark(user)
// }, [user])
......@@ -42,11 +58,15 @@ function Bookmark() {
<Nav className="mr-auto">
<Nav.Link href="/">Home</Nav.Link>
</Nav>
<Button type='submit' onClick={getBookmark}>저장</Button>
</Navbar>
<Form>
<ListGroup>
<ListGroup.Item value={page.bookmark}></ListGroup.Item>
<ListGroup.Item></ListGroup.Item>
<ListGroup.Item>{page.bookmark[0]}</ListGroup.Item>
<ListGroup.Item>{page.bookmark[1]}</ListGroup.Item>
<ListGroup.Item>{page.bookmark[2]}</ListGroup.Item>
<ListGroup.Item>{page.bookmark[3]}</ListGroup.Item>
<ListGroup.Item>{page.bookmark[4]}</ListGroup.Item>
</ListGroup>
</Form>
</Container>
......
......@@ -80,13 +80,6 @@ function Search(props) {
async function handleSubmit(e){
setState(true); //버튼이 눌려서 handlesubmit이될때 setState값이 true로 바뀐다
try { //respons 서버에 post로 요청하여 데이터를 받아온다
const response = await axios.post('/api/users/bookmark', page)
setSuccess(true)
} catch (error) {
console.log(error)
catchErrors(error, setError)
}
}
function paginate(items, pageNumber, itemNumber) {
......
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