Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
students
search-page
Commits
f81deda0
Commit
f81deda0
authored
Jan 25, 2021
by
Lee SeoYeon
Browse files
..
parent
7af468a7
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
client/.eslintcache
View file @
f81deda0
This diff is collapsed.
Click to expand it.
client/src/Bookmark.js
View file @
f81deda0
...
...
@@ -3,12 +3,11 @@ 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
:
[
'
한라산
'
],
const
INIT_PAGE
=
{
bookmark
:
[
'
성산일출봉
'
,
'
제주도
'
,
'
한라산
'
,
'
주상절리
'
,
'
오설록 티 뮤지엄
'
],
}
const
user
=
isAuthenticated
()
...
...
@@ -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
>
...
...
client/src/Search.js
View file @
f81deda0
...
...
@@ -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
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment