Commit 393c3e38 authored by Lee SeoYeon's avatar Lee SeoYeon
Browse files

.

parent 6dc328f1
This diff is collapsed.
...@@ -3949,143 +3949,6 @@ ...@@ -3949,143 +3949,6 @@
"resolved": "https://registry.npmjs.org/check-types/-/check-types-11.1.2.tgz", "resolved": "https://registry.npmjs.org/check-types/-/check-types-11.1.2.tgz",
"integrity": "sha512-tzWzvgePgLORb9/3a0YenggReLKAIb2owL03H2Xdoe5pKcUyWRSEQ8xfCar8t2SIAuEDwtmx2da1YB52YuHQMQ==" "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": { "chokidar": {
"version": "3.4.3", "version": "3.4.3",
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.4.3.tgz", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.4.3.tgz",
...@@ -10914,21 +10777,6 @@ ...@@ -10914,21 +10777,6 @@
"resolved": "https://registry.npmjs.org/parse5/-/parse5-5.1.1.tgz", "resolved": "https://registry.npmjs.org/parse5/-/parse5-5.1.1.tgz",
"integrity": "sha512-ugq4DFI0Ptb+WWjAdOK16+u/nHfiIrcE+sh8kZMaM0WllQKLI9rOUq6c2b7cwPkXdzfQESqvoqK6ug7U/Yyzug==" "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": { "parseurl": {
"version": "1.3.3", "version": "1.3.3",
"resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz",
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
"@testing-library/user-event": "^12.6.0", "@testing-library/user-event": "^12.6.0",
"axios": "^0.21.1", "axios": "^0.21.1",
"bootstrap": "^4.5.3", "bootstrap": "^4.5.3",
"cheerio": "^1.0.0-rc.5",
"react": "^17.0.1", "react": "^17.0.1",
"react-bootstrap": "^1.4.0", "react-bootstrap": "^1.4.0",
"react-dom": "^17.0.1", "react-dom": "^17.0.1",
......
import React, { useState } from 'react'; import React, { useState } from 'react';
import { Redirect } from 'react-router-dom'; 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 { 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() { function App() {
const [state, setState] = useState(false); const [state, setState] = useState(false);
......
...@@ -7,6 +7,7 @@ import Paginations from '../Components/Paginations'; ...@@ -7,6 +7,7 @@ import Paginations from '../Components/Paginations';
import axios from 'axios'; import axios from 'axios';
import queryString from 'query-string' import queryString from 'query-string'
import * as Icon from 'react-bootstrap-icons'; import * as Icon from 'react-bootstrap-icons';
import { isAuthenticated } from '../utils/auth';
function Search(props) { function Search(props) {
const endPage = 10; const endPage = 10;
...@@ -14,10 +15,11 @@ function Search(props) { ...@@ -14,10 +15,11 @@ function Search(props) {
const [index, setIndex] = useState(1); const [index, setIndex] = useState(1);
const [showSet, setShowSet] = useState([false, false, false, false]); const [showSet, setShowSet] = useState([false, false, false, false]);
const [search, setSearch] = useState(queryString.parse(props.location.search).keyword); const [search, setSearch] = useState(queryString.parse(props.location.search).keyword);
const [pagePlace, setPagePlace] = useState(); // const [pagePlace, setPagePlace] = useState();
const [association, setAssociation] = useState([]) const [association, setAssociation] = useState([])
const [pagePlace, setPagePlace] = useState([]) const [pagePlace, setPagePlace] = useState([])
const [bookmark, setBookmark] = useState([false, false, false, false]) const [bookmark, setBookmark] = useState([false, false, false, false])
const user = isAuthenticated()
// console.log("search###############", search) // console.log("search###############", search)
// const getPlace = () => { // const getPlace = () => {
...@@ -59,6 +61,10 @@ function Search(props) { ...@@ -59,6 +61,10 @@ function Search(props) {
getAssociation() getAssociation()
}, []); }, []);
useEffect(() => {
console.log("222222222222222222", bookmark)
}, [bookmark])
useEffect(() => { useEffect(() => {
setPagePlace(paginate(association, index, association.length)) setPagePlace(paginate(association, index, association.length))
}, [association]); }, [association]);
...@@ -72,11 +78,11 @@ function Search(props) { ...@@ -72,11 +78,11 @@ function Search(props) {
// state: { id: search }, // state: { id: search },
// }} />; // }} />;
props.history.push('/search?keyword=' + search) props.history.push('/search?keyword=' + search)
// setState(false) setState(false)
// console.log("search야", search) // console.log("search야", search)
} window.addEventListener("scroll", infiniteScroll); } window.addEventListener("scroll", infiniteScroll);
return () => { window.removeEventListener("scroll", infiniteScroll); } return () => { window.removeEventListener("scroll", infiniteScroll); }
}, []); }, [state]);
const infiniteScroll = () => { const infiniteScroll = () => {
const { documentElement, body } = document; const { documentElement, body } = document;
...@@ -147,19 +153,22 @@ function Search(props) { ...@@ -147,19 +153,22 @@ function Search(props) {
return page return page
} }
async function handlebookmark(index, place) { async function handlebookmark(index) {
if (!bookmark[index]) { if (!bookmark[index]) {
// const response = await axios.put('/api/bookmark',) console.log(pagePlace[index])
alert('북마크가 저장되었습니다.') const response = await axios.put(`/api/users/bookmark?ID=${user}&place=${pagePlace[index]._id}`)
alert(response.data, '북마크가 저장되었습니다.')
const showArr = bookmark const showArr = bookmark
showArr[index] = true showArr[index] = true
setBookmark(showArr) setBookmark(showArr)
console.log("bookmark=", bookmark)
} else { } else {
// axios.delete('') const response = await axios.delete(`/api/users/bookmark?ID=${user}&place=${pagePlace[index]._id}`)
alert('저장된 북마크가 삭제되었습니다.') alert(response.data, '저장된 북마크가 삭제되었습니다.')
const showArr = bookmark const showArr = bookmark
showArr[index] = false showArr[index] = false
setBookmark(showArr) setBookmark(showArr)
console.log("bookmark=", bookmark)
} }
} }
...@@ -191,12 +200,18 @@ function Search(props) { ...@@ -191,12 +200,18 @@ function Search(props) {
return ( return (
<Col key={index} md={6} > <Col key={index} md={6} >
<Card align="center" border="info" style={{ margin: "3%" }}> <Card align="center" border="info" style={{ margin: "3%" }}>
<Button
style={{ marginLeft: "50vh" }} <Card.Title className="d-flex justify-content-center" style={{ margin: "3%", fontSize: '200%', fontWeight: 'bold' }} >{place.name}
onClick={() => handlebookmark(index, place)}> {user ?
{console.log(bookmark)} <Icon.BookmarkStarFill size={35} /> <Icon.BookmarkStar size={35} /> <Button
</Button>
<Card.Title style={{ margin: "3%", fontSize: '200%', fontWeight: 'bold' }} >{place.name}</Card.Title> variant={bookmark[index] ? "primary" : "light"}
style={{}}
onClick={() => handlebookmark(index, place)}>
<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.Img variant="top" style={{ padding: "5%", width: "100%", height: "340px" }} src={place.img} />
<Card.Body > <Card.Body >
<Card.Text style={{ overflow: 'auto', fontSize: '25px', width: '100%', height: "80px" }} > <Card.Text style={{ overflow: 'auto', fontSize: '25px', width: '100%', height: "80px" }} >
...@@ -216,7 +231,7 @@ function Search(props) { ...@@ -216,7 +231,7 @@ function Search(props) {
<Row className="mt-2 d-flex justify-content-center"> <Row className="mt-2 d-flex justify-content-center">
<Paginations index={index} endPage={endPage} handlePage={handlePage}></Paginations> <Paginations index={index} endPage={endPage} handlePage={handlePage}></Paginations>
</Row> </Row>
</Container> </Container >
); );
} }
......
...@@ -2,13 +2,12 @@ import React from 'react'; ...@@ -2,13 +2,12 @@ import React from 'react';
import ReactDOM from 'react-dom'; import ReactDOM from 'react-dom';
import './index.css'; import './index.css';
import 'bootstrap/dist/css/bootstrap.min.css'; import 'bootstrap/dist/css/bootstrap.min.css';
import App from './App' import App from './Pages/App'
import Search from './Pages/Search'; import Search from './Pages/Search';
import reportWebVitals from './reportWebVitals'; import reportWebVitals from './reportWebVitals';
import Signup from './Components/Signup' import Signup from './Components/Signup'
import Login from './Components/Login' import Login from './Components/Login'
import PrivateRoute from "./Components/PrivateRoute"; import PrivateRoute from "./Components/PrivateRoute";
import axios from 'axios'
import Bookmark from "./Bookmark" import Bookmark from "./Bookmark"
import { import {
BrowserRouter as Router, BrowserRouter as Router,
......
...@@ -64,8 +64,22 @@ const getBookmark = async (req, res) => { ...@@ -64,8 +64,22 @@ const getBookmark = async (req, res) => {
res.send(updatedUser) res.send(updatedUser)
} }
// function handlebookmark() { const setBookmark = async (req, res) => {
// const bookmarkUser = await User.findOne({}) // const place = await Place.findOne(address)
// } // const bookmarkUser = await User.findOne({ place }.populate(bookmark))
// if (bookmarkUser) {
export default { signup, userById, getBookmark } // bookmarkUser.save()
\ No newline at end of file // }
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
...@@ -7,7 +7,9 @@ router.route('/api/users/signup') ...@@ -7,7 +7,9 @@ router.route('/api/users/signup')
.post(userCtrl.signup) .post(userCtrl.signup)
router.route('/api/users/bookmark') router.route('/api/users/bookmark')
.put(userCtrl.getBookmark) .get(userCtrl.getBookmark)
.put(userCtrl.setBookmark)
.delete(userCtrl.deleteBookmark)
router.param('userId', userCtrl.userById) router.param('userId', userCtrl.userById)
......
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