Place.js 1.5 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) {
baesangjune's avatar
baesangjune committed
6
  const [reviews, setReviews] = useState([{ title: "", link: "", summery: "", content: "" }])
7
  const getReview = () => {
8
9
    axios.get(`/api/review/${props.search.name}`)//review를 서버에 연결해서
      .then(res => {s
Kim, Chaerin's avatar
Kim, Chaerin committed
10
        console.log("place res.data", res.data)
11
12
13
14
15
16
17
18
19
20
21
        setReviews(res.data)
      })
      .catch(err => {
        console.log(err)
      })
  }

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

Kim, Chaerin's avatar
Kim, Chaerin committed
22
  return (
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
    <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' }}>
          {props.index + 1}. {props.search.name}
        </Modal.Title>
      </Modal.Header>
      <Modal.Body className="show-grid">
        <Container style={{ fontSize: '40px' }}>
          {reviews.map((review, index) => {
            return (
              <Row className="mt-4">
                <a href={review.link}>{review.title}</a>
                <div>{review.summary}</div>
Kim, Chaerin's avatar
Kim, Chaerin committed
40
                <div>{review.content}</div>
41
42
43
              </Row>
            )
          })}
baesangjune's avatar
review    
baesangjune committed
44
        </Container>
45
46
47
48
49
50

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

54
export default Place;