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
393c3e38
Commit
393c3e38
authored
Jan 27, 2021
by
Lee SeoYeon
Browse files
.
parent
6dc328f1
Changes
8
Expand all
Show whitespace changes
Inline
Side-by-side
client/.eslintcache
View file @
393c3e38
This diff is collapsed.
Click to expand it.
client/package-lock.json
View file @
393c3e38
...
...
@@ -3949,143 +3949,6 @@
"resolved": "https://registry.npmjs.org/check-types/-/check-types-11.1.2.tgz",
"integrity": "sha512-tzWzvgePgLORb9/3a0YenggReLKAIb2owL03H2Xdoe5pKcUyWRSEQ8xfCar8t2SIAuEDwtmx2da1YB52YuHQMQ=="
},
"cheerio": {
"version": "1.0.0-rc.5",
"resolved": "https://registry.npmjs.org/cheerio/-/cheerio-1.0.0-rc.5.tgz",
"integrity": "sha512-yoqps/VCaZgN4pfXtenwHROTp8NG6/Hlt4Jpz2FEP0ZJQ+ZUkVDd0hAPDNKhj3nakpfPt/CNs57yEtxD1bXQiw==",
"requires": {
"cheerio-select-tmp": "^0.1.0",
"dom-serializer": "~1.2.0",
"domhandler": "^4.0.0",
"entities": "~2.1.0",
"htmlparser2": "^6.0.0",
"parse5": "^6.0.0",
"parse5-htmlparser2-tree-adapter": "^6.0.0"
},
"dependencies": {
"dom-serializer": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-1.2.0.tgz",
"integrity": "sha512-n6kZFH/KlCrqs/1GHMOd5i2fd/beQHuehKdWvNNffbGHTr/almdhuVvTVFb3V7fglz+nC50fFusu3lY33h12pA==",
"requires": {
"domelementtype": "^2.0.1",
"domhandler": "^4.0.0",
"entities": "^2.0.0"
}
},
"domelementtype": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.1.0.tgz",
"integrity": "sha512-LsTgx/L5VpD+Q8lmsXSHW2WpA+eBlZ9HPf3erD1IoPF00/3JKHZ3BknUVA2QGDNu69ZNmyFmCWBSO45XjYKC5w=="
},
"domhandler": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/domhandler/-/domhandler-4.0.0.tgz",
"integrity": "sha512-KPTbnGQ1JeEMQyO1iYXoagsI6so/C96HZiFyByU3T6iAzpXn8EGEvct6unm1ZGoed8ByO2oirxgwxBmqKF9haA==",
"requires": {
"domelementtype": "^2.1.0"
}
},
"domutils": {
"version": "2.4.4",
"resolved": "https://registry.npmjs.org/domutils/-/domutils-2.4.4.tgz",
"integrity": "sha512-jBC0vOsECI4OMdD0GC9mGn7NXPLb+Qt6KW1YDQzeQYRUFKmNG8lh7mO5HiELfr+lLQE7loDVI4QcAxV80HS+RA==",
"requires": {
"dom-serializer": "^1.0.1",
"domelementtype": "^2.0.1",
"domhandler": "^4.0.0"
}
},
"htmlparser2": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-6.0.0.tgz",
"integrity": "sha512-numTQtDZMoh78zJpaNdJ9MXb2cv5G3jwUoe3dMQODubZvLoGvTE/Ofp6sHvH8OGKcN/8A47pGLi/k58xHP/Tfw==",
"requires": {
"domelementtype": "^2.0.1",
"domhandler": "^4.0.0",
"domutils": "^2.4.4",
"entities": "^2.0.0"
}
},
"parse5": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/parse5/-/parse5-6.0.1.tgz",
"integrity": "sha512-Ofn/CTFzRGTTxwpNEs9PP93gXShHcTq255nzRYSKe8AkVpZY7e1fpmTfOyoIvjP5HG7Z2ZM7VS9PPhQGW2pOpw=="
}
}
},
"cheerio-select-tmp": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/cheerio-select-tmp/-/cheerio-select-tmp-0.1.1.tgz",
"integrity": "sha512-YYs5JvbpU19VYJyj+F7oYrIE2BOll1/hRU7rEy/5+v9BzkSo3bK81iAeeQEMI92vRIxz677m72UmJUiVwwgjfQ==",
"requires": {
"css-select": "^3.1.2",
"css-what": "^4.0.0",
"domelementtype": "^2.1.0",
"domhandler": "^4.0.0",
"domutils": "^2.4.4"
},
"dependencies": {
"css-select": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/css-select/-/css-select-3.1.2.tgz",
"integrity": "sha512-qmss1EihSuBNWNNhHjxzxSfJoFBM/lERB/Q4EnsJQQC62R2evJDW481091oAdOr9uh46/0n4nrg0It5cAnj1RA==",
"requires": {
"boolbase": "^1.0.0",
"css-what": "^4.0.0",
"domhandler": "^4.0.0",
"domutils": "^2.4.3",
"nth-check": "^2.0.0"
}
},
"css-what": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/css-what/-/css-what-4.0.0.tgz",
"integrity": "sha512-teijzG7kwYfNVsUh2H/YN62xW3KK9YhXEgSlbxMlcyjPNvdKJqFx5lrwlJgoFP1ZHlB89iGDlo/JyshKeRhv5A=="
},
"dom-serializer": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-1.2.0.tgz",
"integrity": "sha512-n6kZFH/KlCrqs/1GHMOd5i2fd/beQHuehKdWvNNffbGHTr/almdhuVvTVFb3V7fglz+nC50fFusu3lY33h12pA==",
"requires": {
"domelementtype": "^2.0.1",
"domhandler": "^4.0.0",
"entities": "^2.0.0"
}
},
"domelementtype": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.1.0.tgz",
"integrity": "sha512-LsTgx/L5VpD+Q8lmsXSHW2WpA+eBlZ9HPf3erD1IoPF00/3JKHZ3BknUVA2QGDNu69ZNmyFmCWBSO45XjYKC5w=="
},
"domhandler": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/domhandler/-/domhandler-4.0.0.tgz",
"integrity": "sha512-KPTbnGQ1JeEMQyO1iYXoagsI6so/C96HZiFyByU3T6iAzpXn8EGEvct6unm1ZGoed8ByO2oirxgwxBmqKF9haA==",
"requires": {
"domelementtype": "^2.1.0"
}
},
"domutils": {
"version": "2.4.4",
"resolved": "https://registry.npmjs.org/domutils/-/domutils-2.4.4.tgz",
"integrity": "sha512-jBC0vOsECI4OMdD0GC9mGn7NXPLb+Qt6KW1YDQzeQYRUFKmNG8lh7mO5HiELfr+lLQE7loDVI4QcAxV80HS+RA==",
"requires": {
"dom-serializer": "^1.0.1",
"domelementtype": "^2.0.1",
"domhandler": "^4.0.0"
}
},
"nth-check": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/nth-check/-/nth-check-2.0.0.tgz",
"integrity": "sha512-i4sc/Kj8htBrAiH1viZ0TgU8Y5XqCaV/FziYK6TBczxmeKm3AEFWqqF3195yKudrarqy7Zu80Ra5dobFjn9X/Q==",
"requires": {
"boolbase": "^1.0.0"
}
}
}
},
"chokidar": {
"version": "3.4.3",
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.4.3.tgz",
...
...
@@ -10914,21 +10777,6 @@
"resolved": "https://registry.npmjs.org/parse5/-/parse5-5.1.1.tgz",
"integrity": "sha512-ugq4DFI0Ptb+WWjAdOK16+u/nHfiIrcE+sh8kZMaM0WllQKLI9rOUq6c2b7cwPkXdzfQESqvoqK6ug7U/Yyzug=="
},
"parse5-htmlparser2-tree-adapter": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/parse5-htmlparser2-tree-adapter/-/parse5-htmlparser2-tree-adapter-6.0.1.tgz",
"integrity": "sha512-qPuWvbLgvDGilKc5BoicRovlT4MtYT6JfJyBOMDsKoiT+GiuP5qyrPCnR9HcPECIJJmZh5jRndyNThnhhb/vlA==",
"requires": {
"parse5": "^6.0.1"
},
"dependencies": {
"parse5": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/parse5/-/parse5-6.0.1.tgz",
"integrity": "sha512-Ofn/CTFzRGTTxwpNEs9PP93gXShHcTq255nzRYSKe8AkVpZY7e1fpmTfOyoIvjP5HG7Z2ZM7VS9PPhQGW2pOpw=="
}
}
},
"parseurl": {
"version": "1.3.3",
"resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz",
...
...
client/package.json
View file @
393c3e38
...
...
@@ -8,7 +8,6 @@
"@testing-library/user-event"
:
"^12.6.0"
,
"axios"
:
"^0.21.1"
,
"bootstrap"
:
"^4.5.3"
,
"cheerio"
:
"^1.0.0-rc.5"
,
"react"
:
"^17.0.1"
,
"react-bootstrap"
:
"^1.4.0"
,
"react-dom"
:
"^17.0.1"
,
...
...
client/src/App.js
→
client/src/
Pages/
App.js
View file @
393c3e38
import
React
,
{
useState
}
from
'
react
'
;
import
{
Redirect
}
from
'
react-router-dom
'
;
import
ohuh
from
'
./ohuh.PNG
'
import
ohuh
from
'
.
.
/ohuh.PNG
'
import
{
Container
,
Row
,
Form
,
Image
,
InputGroup
,
Button
,
Col
,
Nav
}
from
'
react-bootstrap
'
;
import
{
handleLogout
,
isAuthenticated
}
from
'
./utils/auth.js
'
import
{
handleLogout
,
isAuthenticated
}
from
'
.
.
/utils/auth.js
'
function
App
()
{
const
[
state
,
setState
]
=
useState
(
false
);
...
...
client/src/Pages/Search.js
View file @
393c3e38
...
...
@@ -7,6 +7,7 @@ import Paginations from '../Components/Paginations';
import
axios
from
'
axios
'
;
import
queryString
from
'
query-string
'
import
*
as
Icon
from
'
react-bootstrap-icons
'
;
import
{
isAuthenticated
}
from
'
../utils/auth
'
;
function
Search
(
props
)
{
const
endPage
=
10
;
...
...
@@ -14,10 +15,11 @@ function Search(props) {
const
[
index
,
setIndex
]
=
useState
(
1
);
const
[
showSet
,
setShowSet
]
=
useState
([
false
,
false
,
false
,
false
]);
const
[
search
,
setSearch
]
=
useState
(
queryString
.
parse
(
props
.
location
.
search
).
keyword
);
const
[
pagePlace
,
setPagePlace
]
=
useState
();
//
const [pagePlace, setPagePlace] = useState();
const
[
association
,
setAssociation
]
=
useState
([])
const
[
pagePlace
,
setPagePlace
]
=
useState
([])
const
[
bookmark
,
setBookmark
]
=
useState
([
false
,
false
,
false
,
false
])
const
user
=
isAuthenticated
()
// console.log("search###############", search)
// const getPlace = () => {
...
...
@@ -59,6 +61,10 @@ function Search(props) {
getAssociation
()
},
[]);
useEffect
(()
=>
{
console
.
log
(
"
222222222222222222
"
,
bookmark
)
},
[
bookmark
])
useEffect
(()
=>
{
setPagePlace
(
paginate
(
association
,
index
,
association
.
length
))
},
[
association
]);
...
...
@@ -72,11 +78,11 @@ function Search(props) {
// state: { id: search },
// }} />;
props
.
history
.
push
(
'
/search?keyword=
'
+
search
)
//
setState(false)
setState
(
false
)
// console.log("search야", search)
}
window
.
addEventListener
(
"
scroll
"
,
infiniteScroll
);
return
()
=>
{
window
.
removeEventListener
(
"
scroll
"
,
infiniteScroll
);
}
},
[]);
},
[
state
]);
const
infiniteScroll
=
()
=>
{
const
{
documentElement
,
body
}
=
document
;
...
...
@@ -147,19 +153,22 @@ function Search(props) {
return
page
}
async
function
handlebookmark
(
index
,
place
)
{
async
function
handlebookmark
(
index
)
{
if
(
!
bookmark
[
index
])
{
// const response = await axios.put('/api/bookmark',)
alert
(
'
북마크가 저장되었습니다.
'
)
console
.
log
(
pagePlace
[
index
])
const
response
=
await
axios
.
put
(
`/api/users/bookmark?ID=
${
user
}
&place=
${
pagePlace
[
index
].
_id
}
`
)
alert
(
response
.
data
,
'
북마크가 저장되었습니다.
'
)
const
showArr
=
bookmark
showArr
[
index
]
=
true
setBookmark
(
showArr
)
console
.
log
(
"
bookmark=
"
,
bookmark
)
}
else
{
// axios.delete(''
)
alert
(
'
저장된 북마크가 삭제되었습니다.
'
)
const
response
=
await
axios
.
delete
(
`/api/users/bookmark?ID=
${
user
}
&place=
${
pagePlace
[
index
].
_id
}
`
)
alert
(
response
.
data
,
'
저장된 북마크가 삭제되었습니다.
'
)
const
showArr
=
bookmark
showArr
[
index
]
=
false
setBookmark
(
showArr
)
console
.
log
(
"
bookmark=
"
,
bookmark
)
}
}
...
...
@@ -191,12 +200,18 @@ function Search(props) {
return
(
<
Col
key
=
{
index
}
md
=
{
6
}
>
<
Card
align
=
"
center
"
border
=
"
info
"
style
=
{{
margin
:
"
3%
"
}}
>
<
Card
.
Title
className
=
"
d-flex justify-content-center
"
style
=
{{
margin
:
"
3%
"
,
fontSize
:
'
200%
'
,
fontWeight
:
'
bold
'
}}
>
{
place
.
name
}
{
user
?
<
Button
style
=
{{
marginLeft
:
"
50vh
"
}}
variant
=
{
bookmark
[
index
]
?
"
primary
"
:
"
light
"
}
style
=
{{}}
onClick
=
{()
=>
handlebookmark
(
index
,
place
)}
>
{
console
.
log
(
bookmark
)}
<
Icon
.
BookmarkStarFill
size
=
{
35
}
/> <Icon.BookmarkStar size=
{35}
/
>
<
/Button
>
<
Card
.
Title
style
=
{{
margin
:
"
3%
"
,
fontSize
:
'
200%
'
,
fontWeight
:
'
bold
'
}}
>
{
place
.
name
}
<
/Card.Title
>
<
Icon
.
BookmarkStarFill
size
=
{
35
}
/
>
{
console
.
log
(
"
bookmark
"
,
bookmark
)}
{
console
.
log
(
"
bookmark[index]
"
,
bookmark
[
index
])}
<
/Button> : null
}
<
/Card.Title
>
<
Card
.
Img
variant
=
"
top
"
style
=
{{
padding
:
"
5%
"
,
width
:
"
100%
"
,
height
:
"
340px
"
}}
src
=
{
place
.
img
}
/
>
<
Card
.
Body
>
<
Card
.
Text
style
=
{{
overflow
:
'
auto
'
,
fontSize
:
'
25px
'
,
width
:
'
100%
'
,
height
:
"
80px
"
}}
>
...
...
@@ -216,7 +231,7 @@ function Search(props) {
<
Row
className
=
"
mt-2 d-flex justify-content-center
"
>
<
Paginations
index
=
{
index
}
endPage
=
{
endPage
}
handlePage
=
{
handlePage
}
><
/Paginations
>
<
/Row
>
<
/Container
>
<
/Container
>
);
}
...
...
client/src/index.js
View file @
393c3e38
...
...
@@ -2,13 +2,12 @@ import React from 'react';
import
ReactDOM
from
'
react-dom
'
;
import
'
./index.css
'
;
import
'
bootstrap/dist/css/bootstrap.min.css
'
;
import
App
from
'
./App
'
import
App
from
'
./
Pages/
App
'
import
Search
from
'
./Pages/Search
'
;
import
reportWebVitals
from
'
./reportWebVitals
'
;
import
Signup
from
'
./Components/Signup
'
import
Login
from
'
./Components/Login
'
import
PrivateRoute
from
"
./Components/PrivateRoute
"
;
import
axios
from
'
axios
'
import
Bookmark
from
"
./Bookmark
"
import
{
BrowserRouter
as
Router
,
...
...
server/controllers/user.controller.js
View file @
393c3e38
...
...
@@ -64,8 +64,22 @@ const getBookmark = async (req, res) => {
res
.
send
(
updatedUser
)
}
// function handlebookmark() {
// const bookmarkUser = await User.findOne({})
// }
const
setBookmark
=
async
(
req
,
res
)
=>
{
// const place = await Place.findOne(address)
// const bookmarkUser = await User.findOne({ place }.populate(bookmark))
// if (bookmarkUser) {
export
default
{
signup
,
userById
,
getBookmark
}
\ No newline at end of file
// bookmarkUser.save()
// }
console
.
log
(
req
.
query
.
ID
,
req
.
query
.
place
,
"
여기에요 여기!!!!
"
)
await
User
.
updateOne
({
_id
:
req
.
query
.
ID
},
{
$push
:
{
bookmark
:
req
.
query
.
place
}
})
res
.
send
(
"
추가완료
"
)
}
const
deleteBookmark
=
async
(
req
,
res
)
=>
{
console
.
log
(
req
.
query
.
ID
,
req
.
query
.
place
)
await
User
.
updateOne
({
_id
:
req
.
query
.
ID
},
{
$pull
:
{
bookmark
:
req
.
query
.
place
}
})
res
.
send
(
"
삭제완료
"
)
}
export
default
{
signup
,
userById
,
getBookmark
,
setBookmark
,
deleteBookmark
}
\ No newline at end of file
server/routes/user.routes.js
View file @
393c3e38
...
...
@@ -7,7 +7,9 @@ router.route('/api/users/signup')
.
post
(
userCtrl
.
signup
)
router
.
route
(
'
/api/users/bookmark
'
)
.
put
(
userCtrl
.
getBookmark
)
.
get
(
userCtrl
.
getBookmark
)
.
put
(
userCtrl
.
setBookmark
)
.
delete
(
userCtrl
.
deleteBookmark
)
router
.
param
(
'
userId
'
,
userCtrl
.
userById
)
...
...
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