Place.js 1.82 KB
Newer Older
1
2
import axios from 'axios';
import React, { useEffect, useState } from 'react';
baesangjune's avatar
baesangjune committed
3
import { Modal, Container, Row, Button, } from 'react-bootstrap';
Kim, Chaerin's avatar
Kim, Chaerin committed
4
5

function Place(props) {
6
<<<<<<< HEAD
baesangjune's avatar
baesangjune committed
7
  const [reviews, setReviews] = useState([{ title: "", link: "", summery: "", content: "" }])
8
  const getReview = () => {
9
10
    axios.get(`/api/review/${props.search.name}`)//review를 서버에 연결해서
      .then(res => {s
11
=======
Kim, Chaerin's avatar
Kim, Chaerin committed
12
13
  const [reviews, setReviews] = useState()
  const [db, setDb] = useState(false)
14
  const getReview = () => {
Kim, Chaerin's avatar
Kim, Chaerin committed
15
    axios({ url: `/api/review?keyword=${props.place.name}`, method: 'post', data: { db: db } })
16
      .then(res => {
17
>>>>>>> origin/cherry
Kim, Chaerin's avatar
Kim, Chaerin committed
18
        console.log("place res.data", res.data)
19
20
21
22
23
24
25
26
27
28
29
        setReviews(res.data)
      })
      .catch(err => {
        console.log(err)
      })
  }

  useEffect(() => {
    getReview();
  }, [])

Kim, Chaerin's avatar
Kim, Chaerin committed
30
  return (
31
32
33
34
35
36
37
    <Modal {...props}
      size="xl"
      keyboard="true"
      variant="backdrop.in"
      aria-labelledby="example-modal-sizes-title-lg">
      <Modal.Header closeButton>
        <Modal.Title id="contained-modal-title-vcenter" style={{ fontSize: '40px' }}>
Kim, Chaerin's avatar
Kim, Chaerin committed
38
          {props.index + 1}. {props.place.name}
39
40
41
42
        </Modal.Title>
      </Modal.Header>
      <Modal.Body className="show-grid">
        <Container style={{ fontSize: '40px' }}>
Kim, Chaerin's avatar
Kim, Chaerin committed
43
          {Array.isArray(reviews) ? reviews.map((review, index) => {
44
45
46
47
            return (
              <Row className="mt-4">
                <a href={review.link}>{review.title}</a>
                <div>{review.summary}</div>
Kim, Chaerin's avatar
Kim, Chaerin committed
48
                <div>{review.content}</div>
49
50
              </Row>
            )
Kim, Chaerin's avatar
Kim, Chaerin committed
51
52
          })
            : "리뷰가 없습니다."}
baesangjune's avatar
review    
baesangjune committed
53
        </Container>
54
55
56
57
58
59

      </Modal.Body>
      <Modal.Footer>
        <Button block onClick={props.onHide}>Close</Button>
      </Modal.Footer>
    </Modal>
Kim, Chaerin's avatar
Kim, Chaerin committed
60
61
62
  );
}

63
export default Place;