Commit d8de9050 authored by Kim, Chaerin's avatar Kim, Chaerin
Browse files

Merge remote-tracking branch 'origin/BAE' into cherry

parents 0e9de33f c7df9b76
[{"C:\\Users\\sag06\\Desktop\\project\\search-page\\client\\src\\Pages\\App.js":"1","C:\\Users\\sag06\\Desktop\\project\\search-page\\client\\src\\Pages\\Bookmark.js":"2","C:\\Users\\sag06\\Desktop\\project\\search-page\\client\\src\\Pages\\Place.js":"3"},{"size":2131,"mtime":1612145479350,"results":"4","hashOfConfig":"5"},{"size":5206,"mtime":1612142580630,"results":"6","hashOfConfig":"5"},{"size":6320,"mtime":1612141050493,"results":"7","hashOfConfig":"5"},{"filePath":"8","messages":"9","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"1n20xnc",{"filePath":"10","messages":"11","errorCount":0,"warningCount":12,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"12","messages":"13","errorCount":1,"warningCount":4,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},"C:\\Users\\sag06\\Desktop\\project\\search-page\\client\\src\\Pages\\App.js",[],"C:\\Users\\sag06\\Desktop\\project\\search-page\\client\\src\\Pages\\Bookmark.js",["14","15","16","17","18","19","20","21","22","23","24","25"],"C:\\Users\\sag06\\Desktop\\project\\search-page\\client\\src\\Pages\\Place.js",["26","27","28","29","30"],{"ruleId":"31","severity":1,"message":"32","line":2,"column":45,"nodeType":"33","messageId":"34","endLine":2,"endColumn":48},{"ruleId":"31","severity":1,"message":"35","line":2,"column":50,"nodeType":"33","messageId":"34","endLine":2,"endColumn":56},{"ruleId":"31","severity":1,"message":"36","line":17,"column":12,"nodeType":"33","messageId":"34","endLine":17,"endColumn":16},{"ruleId":"31","severity":1,"message":"37","line":17,"column":18,"nodeType":"33","messageId":"34","endLine":17,"endColumn":25},{"ruleId":"31","severity":1,"message":"38","line":18,"column":12,"nodeType":"33","messageId":"34","endLine":18,"endColumn":17},{"ruleId":"31","severity":1,"message":"39","line":18,"column":19,"nodeType":"33","messageId":"34","endLine":18,"endColumn":27},{"ruleId":"31","severity":1,"message":"40","line":19,"column":12,"nodeType":"33","messageId":"34","endLine":19,"endColumn":17},{"ruleId":"31","severity":1,"message":"41","line":20,"column":12,"nodeType":"33","messageId":"34","endLine":20,"endColumn":17},{"ruleId":"31","severity":1,"message":"42","line":20,"column":19,"nodeType":"33","messageId":"34","endLine":20,"endColumn":27},{"ruleId":"31","severity":1,"message":"43","line":23,"column":12,"nodeType":"33","messageId":"34","endLine":23,"endColumn":19},{"ruleId":"31","severity":1,"message":"44","line":23,"column":21,"nodeType":"33","messageId":"34","endLine":23,"endColumn":31},{"ruleId":"45","severity":1,"message":"46","line":65,"column":8,"nodeType":"47","endLine":65,"endColumn":10,"suggestions":"48"},{"ruleId":"31","severity":1,"message":"49","line":1,"column":10,"nodeType":"50","messageId":"34","endLine":1,"endColumn":15},{"ruleId":"31","severity":1,"message":"51","line":4,"column":21,"nodeType":"33","messageId":"34","endLine":4,"endColumn":24},{"ruleId":"45","severity":1,"message":"52","line":55,"column":6,"nodeType":"47","endLine":55,"endColumn":8,"suggestions":"53"},{"ruleId":"54","severity":2,"message":"55","line":86,"column":10,"nodeType":"56","endLine":86,"endColumn":21},{"ruleId":"57","severity":1,"message":"58","line":134,"column":11,"nodeType":"59","endLine":134,"endColumn":23},"no-unused-vars","'Nav' is defined but never used.","Identifier","unusedVar","'Navbar' is defined but never used.","'page' is assigned a value but never used.","'setPage' is assigned a value but never used.","'index' is assigned a value but never used.","'setIndex' is assigned a value but never used.","'error' is assigned a value but never used.","'state' is assigned a value but never used.","'setState' is assigned a value but never used.","'showSet' is assigned a value but never used.","'setShowSet' is assigned a value but never used.","react-hooks/exhaustive-deps","React Hook useEffect has a missing dependency: 'getBookmark'. Either include it or remove the dependency array.","ArrayExpression",["60"],"'kakao' is defined but never used.","Program","'Row' is defined but never used.","React Hook useEffect has missing dependencies: 'getReview' and 'infiniteScroll'. Either include them or remove the dependency array.",["61"],"react/jsx-no-undef","'MapContents' is not defined.","JSXIdentifier","jsx-a11y/anchor-is-valid","The href attribute requires a valid value to be accessible. Provide a valid, navigable address as the href value. If you cannot provide a valid href, but still need the element to resemble a link, use a button and change it with appropriate styles. Learn more: https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/anchor-is-valid.md","JSXOpeningElement",{"desc":"62","fix":"63"},{"desc":"64","fix":"65"},"Update the dependencies array to be: [getBookmark]",{"range":"66","text":"67"},"Update the dependencies array to be: [getReview, infiniteScroll]",{"range":"68","text":"69"},[2255,2257],"[getBookmark]",[1815,1817],"[getReview, infiniteScroll]"] [{"C:\\Users\\sag06\\Desktop\\project\\search-page\\client\\src\\Pages\\Bookmark.js":"1","C:\\Users\\sag06\\Desktop\\project\\search-page\\client\\src\\Pages\\App.js":"2","C:\\Users\\sag06\\Desktop\\project\\search-page\\client\\src\\Pages\\Search.js":"3","C:\\Users\\sag06\\Desktop\\project\\search-page\\client\\src\\Pages\\Place.js":"4"},{"size":5288,"mtime":1612154335893,"results":"5","hashOfConfig":"6"},{"size":6632,"mtime":1612152098441,"results":"7","hashOfConfig":"6"},{"size":8073,"mtime":1612153255044,"results":"8","hashOfConfig":"6"},{"size":6328,"mtime":1612149747278,"results":"9","hashOfConfig":"6"},{"filePath":"10","messages":"11","errorCount":0,"warningCount":12,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},"1n20xnc",{"filePath":"12","messages":"13","errorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"14","messages":"15","errorCount":0,"warningCount":5,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"16","messages":"17","errorCount":0,"warningCount":4,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},"C:\\Users\\sag06\\Desktop\\project\\search-page\\client\\src\\Pages\\Bookmark.js",["18","19","20","21","22","23","24","25","26","27","28","29"],"C:\\Users\\sag06\\Desktop\\project\\search-page\\client\\src\\Pages\\App.js",["30"],"C:\\Users\\sag06\\Desktop\\project\\search-page\\client\\src\\Pages\\Search.js",["31","32","33","34","35"],"C:\\Users\\sag06\\Desktop\\project\\search-page\\client\\src\\Pages\\Place.js",["36","37","38","39"],{"ruleId":"40","severity":1,"message":"41","line":2,"column":45,"nodeType":"42","messageId":"43","endLine":2,"endColumn":48},{"ruleId":"40","severity":1,"message":"44","line":2,"column":50,"nodeType":"42","messageId":"43","endLine":2,"endColumn":56},{"ruleId":"40","severity":1,"message":"45","line":17,"column":12,"nodeType":"42","messageId":"43","endLine":17,"endColumn":16},{"ruleId":"40","severity":1,"message":"46","line":17,"column":18,"nodeType":"42","messageId":"43","endLine":17,"endColumn":25},{"ruleId":"40","severity":1,"message":"47","line":18,"column":12,"nodeType":"42","messageId":"43","endLine":18,"endColumn":17},{"ruleId":"40","severity":1,"message":"48","line":18,"column":19,"nodeType":"42","messageId":"43","endLine":18,"endColumn":27},{"ruleId":"40","severity":1,"message":"49","line":19,"column":12,"nodeType":"42","messageId":"43","endLine":19,"endColumn":17},{"ruleId":"40","severity":1,"message":"50","line":20,"column":12,"nodeType":"42","messageId":"43","endLine":20,"endColumn":17},{"ruleId":"40","severity":1,"message":"51","line":20,"column":19,"nodeType":"42","messageId":"43","endLine":20,"endColumn":27},{"ruleId":"40","severity":1,"message":"52","line":23,"column":12,"nodeType":"42","messageId":"43","endLine":23,"endColumn":19},{"ruleId":"40","severity":1,"message":"53","line":23,"column":21,"nodeType":"42","messageId":"43","endLine":23,"endColumn":31},{"ruleId":"54","severity":1,"message":"55","line":65,"column":8,"nodeType":"56","endLine":65,"endColumn":10,"suggestions":"57"},{"ruleId":"40","severity":1,"message":"58","line":4,"column":64,"nodeType":"42","messageId":"43","endLine":4,"endColumn":68},{"ruleId":"40","severity":1,"message":"41","line":4,"column":83,"nodeType":"42","messageId":"43","endLine":4,"endColumn":86},{"ruleId":"40","severity":1,"message":"49","line":22,"column":12,"nodeType":"42","messageId":"43","endLine":22,"endColumn":17},{"ruleId":"54","severity":1,"message":"59","line":63,"column":8,"nodeType":"56","endLine":63,"endColumn":15,"suggestions":"60"},{"ruleId":"40","severity":1,"message":"61","line":133,"column":9,"nodeType":"42","messageId":"43","endLine":133,"endColumn":13},{"ruleId":"62","severity":1,"message":"63","line":138,"column":35,"nodeType":"64","endLine":138,"endColumn":76},{"ruleId":"40","severity":1,"message":"65","line":1,"column":10,"nodeType":"66","messageId":"43","endLine":1,"endColumn":15},{"ruleId":"40","severity":1,"message":"67","line":4,"column":21,"nodeType":"42","messageId":"43","endLine":4,"endColumn":24},{"ruleId":"54","severity":1,"message":"68","line":55,"column":6,"nodeType":"56","endLine":55,"endColumn":8,"suggestions":"69"},{"ruleId":"70","severity":1,"message":"71","line":134,"column":11,"nodeType":"72","endLine":134,"endColumn":23},"no-unused-vars","'Nav' is defined but never used.","Identifier","unusedVar","'Navbar' is defined but never used.","'page' is assigned a value but never used.","'setPage' is assigned a value but never used.","'index' is assigned a value but never used.","'setIndex' is assigned a value but never used.","'error' is assigned a value but never used.","'state' is assigned a value but never used.","'setState' is assigned a value but never used.","'showSet' is assigned a value but never used.","'setShowSet' is assigned a value but never used.","react-hooks/exhaustive-deps","React Hook useEffect has a missing dependency: 'getBookmark'. Either include it or remove the dependency array.","ArrayExpression",["73"],"'Card' is defined but never used.","React Hook useEffect has missing dependencies: 'getAssociation', 'getBookmark', 'props.history', and 'search'. Either include them or remove the dependency array.",["74"],"'time' is assigned a value but never used.","react/jsx-no-duplicate-props","No duplicate props allowed","JSXAttribute","'kakao' is defined but never used.","Program","'Row' is defined but never used.","React Hook useEffect has missing dependencies: 'getReview' and 'infiniteScroll'. Either include them or remove the dependency array.",["75"],"jsx-a11y/anchor-is-valid","The href attribute requires a valid value to be accessible. Provide a valid, navigable address as the href value. If you cannot provide a valid href, but still need the element to resemble a link, use a button and change it with appropriate styles. Learn more: https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/anchor-is-valid.md","JSXOpeningElement",{"desc":"76","fix":"77"},{"desc":"78","fix":"79"},{"desc":"80","fix":"81"},"Update the dependencies array to be: [getBookmark]",{"range":"82","text":"83"},"Update the dependencies array to be: [getAssociation, getBookmark, props.history, search, state]",{"range":"84","text":"85"},"Update the dependencies array to be: [getReview, infiniteScroll]",{"range":"86","text":"87"},[2281,2283],"[getBookmark]",[2424,2431],"[getAssociation, getBookmark, props.history, search, state]",[1815,1817],"[getReview, infiniteScroll]"]
\ No newline at end of file \ No newline at end of file
import React, { useState } from 'react'; import React, { useState, useEffect } from 'react';
import { Redirect } from 'react-router-dom'; import { Link, 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, Card, Nav } from 'react-bootstrap';
import axios from 'axios';
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);
const [search, setSearch] = useState(""); const [search, setSearch] = useState("");
const [recommend, setRecommend] = useState([{ name: " ", address: " ", img: " " }]);
const [latest, setLatest] = useState([{ name: " ", address: " ", img: " " }]);
useEffect(() => {
getRecommend()
getLatest()
}, []);
const user = isAuthenticated() const user = isAuthenticated()
if (state !== false) { if (state !== false) {
...@@ -21,25 +30,51 @@ function App() { ...@@ -21,25 +30,51 @@ function App() {
setState(true); setState(true);
} //submit 버튼을 누르면 state 값을 true로 바뀐다 } //submit 버튼을 누르면 state 값을 true로 바뀐다
const getRecommend = () => {
axios.get(`/api/app/recommend`)
.then(res => {
setRecommend(res.data)
})
.catch(err => {
console.log("APP RECOMMEND ERROR", err)
})
}
const getLatest = () => {
axios.get(`/api/app/lastest`)
.then(res => {
setLatest(res.data)
})
.catch(err => {
console.log("APP LATEST ERROR", err)
})
}
return ( return (
<Container className="vh-100 d-flex justify-content-md-center align-items-center"> <Container className="vh-100 ">
<Col md={6} style={{ marginTop: 140 }}> <Col xs={12} >
<Nav className="justify-content-end" bg="#fff" variant="light" > <Nav className="justify-content-end" bg="#fff" variant="light" style={{}} >
{user ? <Nav.Link onClick={() => handleLogout()}>로그아웃</Nav.Link> {user ? <>
<Nav.Link onClick={() => handleLogout()}>로그아웃</Nav.Link>
<Nav.Link href='/bookmark'>북마크</Nav.Link>
</>
: ( : (
<> <>
<Nav.Link href="/signup">회원가입</Nav.Link> <Nav.Link href="/signup">회원가입</Nav.Link>
<Nav.Link href="/login">로그인</Nav.Link> <Nav.Link href="/login">로그인</Nav.Link>
</> </>
)} )}
<Nav.Link href='/bookmark'>북마크</Nav.Link>
</Nav> </Nav>
<Row style={{ marginBottom: 20 }}> <Row className="justify-content-center" md={2}>
<Image src={ohuh} /> <Col className="d-flex justify-content-center">
<Image src={ohuh} style={{ margin: "3%", marginTop: "3%" }} fluid />
</Col>
</Row> </Row>
<Row style={{ marginBottom: 500 }}> <Row style={{ marginBottom: "5%" }}>
<Form className="vw-100" onSubmit={handleSubmit}> <Form className="vw-100" onSubmit={handleSubmit}>
<InputGroup style={{ width: 560 }}> <InputGroup >
<Form.Control <Form.Control
size="lg" size="lg"
placeholder="검색어를 입력하세요." placeholder="검색어를 입력하세요."
...@@ -53,8 +88,77 @@ function App() { ...@@ -53,8 +88,77 @@ function App() {
</InputGroup> </InputGroup>
</Form> </Form>
</Row> </Row>
<div class="row mb-2">
<div class="col-md-6">
<div class="row g-0 border rounded overflow-hidden flex-md-row mb-4 shadow-sm h-md-250 position-relative">
<div class="col p-4 d-flex flex-column position-static">
<strong class="d-inline-block mb-2 text-info">인기관광지</strong>
<h3 class="mb-0">{recommend.name}</h3>
<Image variant="top" style={{ padding: "5%", width: "100%", height: "340px" }} src={recommend.img} />
<p class="card-text mb-auto">{recommend.address}</p>
<Link to={`/place?id=${1}&place=${recommend.name}`} >
<Button variant="info"> {recommend.name} 자세히 살펴보기</Button>
</Link>
</div>
<div class="col-auto d-none d-lg-block">
</div>
</div>
</div>
<div class="col-md-6">
<div class="row g-0 border rounded overflow-hidden flex-md-row mb-4 shadow-sm h-md-250 position-relative">
<div class="col p-4 d-flex flex-column position-static">
<strong class="d-inline-block mb-2 text-success">최근검색 관광지</strong>
<h3 class="mb-0">{latest.name}</h3>
<Image variant="top" style={{ padding: "5%", width: "100%", height: "340px" }} src={latest.img} />
<p class="mb-auto">{latest.address}</p>
<Link to={`/place?id=${1}&place=${latest.name}`} >
<Button variant="info"> {latest.name} 자세히 살펴보기</Button>
</Link>
</div>
<div class="col-auto d-none d-lg-block">
</div>
</div>
</div>
</div>
{/* <Row xs={6}>
<Col md={6} xs={12}>
<h1 className=" d-flex justify-content-center" style={{ marginBottom: "7%" }}>인기관광지</h1>
<Card align="center" border="info" style={{ margin: "3%" }}>
<Card.Header style={{ margin: "0",fontSize: '200%', fontWeight: 'bold' }} >{recommend.name}</Card.Header>
<Card.Img variant="top" style={{ padding: "5%", width: "100%", height: "340px" }} src={recommend.img} />
<Card.Body >
<Card.Text style={{ overflow: 'auto', fontSize: '25px', width: '100%', height: "80px" }} >
{recommend.address} </Card.Text>
<Link to={`/place?id=${1}&place=${recommend.name}`} >
<Button variant="primary"> {recommend.name} 자세히 살펴보기</Button>
</Link>
</Card.Body>
</Card>
</Col>
<Col md={6} xs={12}>
<h1 className=" d-flex justify-content-center" style={{ marginBottom: "7%" }}>최근 검색관광지</h1>
<Card align="center" border="info" style={{ margin: "3%" }} >
<Card.Header style={{ margin: "0", fontSize: '200%', fontWeight: 'bold'}} bg="danger">{latest.name}</Card.Header>
<Card.Img variant="top" style={{ padding: "5%", width: "100%", height: "340px" }} src={latest.img} />
<Card.Body >
<Card.Text style={{ overflow: 'auto', fontSize: '25px', width: '100%', height: "80px" }} >
{latest.address} </Card.Text>
<Link to={`/place?id=${1}&place=${latest.name}`} >
<Button variant="primary"> {latest.name} 자세히 살펴보기</Button>
</Link>
</Card.Body>
</Card>
</Col>
</Row> */}
</Col> </Col>
</Container> </Container>
); );
} }
......
...@@ -18,7 +18,7 @@ function Bookmark() { ...@@ -18,7 +18,7 @@ function Bookmark() {
const [index, setIndex] = useState(1); const [index, setIndex] = useState(1);
const [error, setError] = useState('') const [error, setError] = useState('')
const [state, setState] = useState(false); const [state, setState] = useState(false);
const [bookmark, setBookmark] = useState([false, false, false, false]) const [bookmark, setBookmark] = useState([true, true, true, true])
const [pagePlace, setPagePlace] = useState([]) const [pagePlace, setPagePlace] = useState([])
const [showSet, setShowSet] = useState([false, false, false, false]); const [showSet, setShowSet] = useState([false, false, false, false]);
...@@ -49,7 +49,7 @@ function Bookmark() { ...@@ -49,7 +49,7 @@ function Bookmark() {
} }
} else { } else {
try { try {
const response = await axios.delete(`/api/users/bookmark?ID=${user}`) const response = await axios.delete(`/api/users/bookmark?ID=${user}&place=${pagePlace[index]._id}`)
alert(response.data, '저장된 북마크가 삭제되었습니다.') alert(response.data, '저장된 북마크가 삭제되었습니다.')
const showArr = bookmark const showArr = bookmark
showArr[index] = false showArr[index] = false
...@@ -80,20 +80,21 @@ function Bookmark() { ...@@ -80,20 +80,21 @@ function Bookmark() {
<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%" }}>
<Card.Title className="d-flex justify-content-center" style={{ margin: "3%", fontSize: '200%', fontWeight: 'bold' }} >{place.name} <Card.Header className="d-flex justify-content-center" style={{ margin: "0", fontSize: '200%', fontWeight: 'bold' }} >{place.name}
{user ? {user ?
<Button <Button
variant={bookmark[index] ? "primary" : "light"} className="float-right"
variant={bookmark[index] ? "info" : "light"}
onClick={() => handleBookmark(index, place)}> onClick={() => handleBookmark(index, place)}>
<Icon.BookmarkStarFill size={35} /> <Icon.BookmarkStarFill size={35} />
{console.log("bookmark", bookmark)} {console.log("bookmark", bookmark)}
{console.log("bookmark[index]", bookmark[index])}</Button> : null} {console.log("bookmark[index]", bookmark[index])}</Button> : null}
</Card.Title> </Card.Header>
<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" }} >
{place.address} </Card.Text> {place.address} </Card.Text>
<Link to={`/place?id=${index}&place=${place.name}`} > <Link to={`/place?&place=${place.name}`} >
<Button variant="info"> {place.name} 자세히 살펴보기</Button> <Button variant="info"> {place.name} 자세히 살펴보기</Button>
</Link> </Link>
</Card.Body> </Card.Body>
......
...@@ -83,7 +83,7 @@ function Place(props) { ...@@ -83,7 +83,7 @@ function Place(props) {
<div class="my-3 p-3 bg-white rounded shadow-sm"> <div class="my-3 p-3 bg-white rounded shadow-sm">
<h6 class="border-bottom pb-2 mb-0">관광지 정보</h6> <h6 class="border-bottom pb-2 mb-0">관광지 정보</h6>
<MapContents id="Mymap"></MapContents> {/* <MapContents id="Mymap"></MapContents> */}
{/* <div class="d-flex text-muted pt-3"> {/* <div class="d-flex text-muted pt-3">
<p class="pb-3 mb-0 small lh-sm border-bottom"> <p class="pb-3 mb-0 small lh-sm border-bottom">
......
...@@ -13,9 +13,8 @@ function Search(props) { ...@@ -13,9 +13,8 @@ function Search(props) {
const [state, setState] = useState(false); const [state, setState] = useState(false);
const [index, setIndex] = useState(1); const [index, setIndex] = useState(1);
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 [bookmark, setBookmark] = useState([false, false, false, false]) const [bookmark, setBookmark] = useState([])
const user = isAuthenticated() const user = isAuthenticated()
const [association, setAssociation] = useState([{ name: " ", address: " ", img: " " }]) const [association, setAssociation] = useState([{ name: " ", address: " ", img: " " }])
const [pagePlace, setPagePlace] = useState([{ name: " ", address: " ", img: " " }, { name: " ", address: " ", img: " " }]) const [pagePlace, setPagePlace] = useState([{ name: " ", address: " ", img: " " }, { name: " ", address: " ", img: " " }])
...@@ -25,9 +24,9 @@ function Search(props) { ...@@ -25,9 +24,9 @@ function Search(props) {
async function getBookmark() { async function getBookmark() {
try { try {
const response = await axios.get(`/api/users/bookmark?ID=${user}`) const response = await axios.get(`/api/users/bookmark?ID=${user}`)
// setBookmark(response.data.bookmark) setBookmark(response.data.bookmark)
} catch (error) { } catch (error) {
catchErrors(error, setError) catchErrors(error, setError(error))
} }
} }
...@@ -42,12 +41,6 @@ function Search(props) { ...@@ -42,12 +41,6 @@ function Search(props) {
}) })
} }
useEffect(() => {
getAssociation()
}, []);
useEffect(() => { useEffect(() => {
if (association.length < 3) { if (association.length < 3) {
setPagePlace(paginate(association, index, association.length)) setPagePlace(paginate(association, index, association.length))
...@@ -61,15 +54,10 @@ function Search(props) { ...@@ -61,15 +54,10 @@ function Search(props) {
useEffect(() => { useEffect(() => {
getAssociation() getAssociation()
getBookmark()
if (state) { if (state) {
// window.location.reload()
// return <Redirect to={{
// pathname: `/search?keyword=${search}`,
// state: { id: search },
// }} />;
props.history.push('/search?keyword=' + search) props.history.push('/search?keyword=' + search)
setState(false) setState(false)
// console.log("search야", search)
} window.addEventListener("scroll", infiniteScroll); } window.addEventListener("scroll", infiniteScroll);
return () => { window.removeEventListener("scroll", infiniteScroll); } return () => { window.removeEventListener("scroll", infiniteScroll); }
}, [state]); }, [state]);
...@@ -113,10 +101,9 @@ function Search(props) { ...@@ -113,10 +101,9 @@ function Search(props) {
console.log("뿌릴 data22222222222222222", page) console.log("뿌릴 data22222222222222222", page)
return page return page
} }
//usestate 쓰거나 한번에 useeffect에 넣기
async function handlebookmark(index) { async function handlebookmark(index, place) {
if (!bookmark[index]) { if (!bookmark.includes(place.name)) {
console.log(pagePlace[index]) console.log(pagePlace[index])
try { try {
const response = await axios.put(`/api/users/bookmark?ID=${user}&place=${pagePlace[index]._id}`) const response = await axios.put(`/api/users/bookmark?ID=${user}&place=${pagePlace[index]._id}`)
...@@ -147,7 +134,7 @@ function Search(props) { ...@@ -147,7 +134,7 @@ function Search(props) {
return ( return (
<Container > <Container >
<Link to="/" className="d-flex justify-content-center"><Image src={ohuh} /></Link> <Link to="/" className="d-flex justify-content-center" ><Image src={ohuh} /></Link>
<Row className="mb-2" className="d-flex justify-content-center"> <Row className="mb-2" className="d-flex justify-content-center">
<Form style={{ width: "90vw" }} onSubmit={handleSubmit}> <Form style={{ width: "90vw" }} onSubmit={handleSubmit}>
<InputGroup size="lg"> <InputGroup size="lg">
...@@ -164,24 +151,24 @@ function Search(props) { ...@@ -164,24 +151,24 @@ function Search(props) {
</InputGroup> </InputGroup>
</Form> </Form>
</Row> </Row>
{/* {time.toLocaleString()} */}
<Row className="d-flex flex-wrap"> <Row className="d-flex flex-wrap">
{console.log("#####################33", pagePlace)} {console.log("#####################33", pagePlace)}
{pagePlace.map((place, index) => { {pagePlace.map((place, index) => {
return ( return (
<Col key={index} md={6} > <Col key={index} md={6} >
<Card align="center" border="info" style={{ margin: "3%" }}> <Card align="right" border="info" style={{ margin: "2%" }}>
<Row className="d-flex justify-content-between">
<Card.Title className="d-flex justify-content-center" style={{ margin: "3%", fontSize: '200%', fontWeight: 'bold' }} >{place.name} <Card.Header style={{ margin: "0", marginLeft: "3%", marginRight: "3%", fontSize: '200%', fontWeight: 'bold', width: "100vw" }} >{place.name}
{user ? {console.log(bookmark.findIndex(i => i.name === place.name))}
<Button {user ?
variant={bookmark[index] ? "info" : "light"} <Button
onClick={() => handlebookmark(index, place)}> variant={bookmark.findIndex(i => i.name === place.name) !== -1 ? "info" : "light"}
<Icon.BookmarkStarFill size={35} /> onClick={() => handlebookmark(index, place)}>
{console.log("bookmark", bookmark)} <Icon.BookmarkStarFill size={35} />
{console.log("bookmark[index]", bookmark[index])}</Button> : null} </Button> : null}
</Card.Title> </Card.Header>
</Row>
<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" }} >
......
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