Place.js 1.59 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) {
Kim, Chaerin's avatar
Kim, Chaerin committed
6
7
  const [reviews, setReviews] = useState()
  const [db, setDb] = useState(false)
8
  const getReview = () => {
Kim, Chaerin's avatar
Kim, Chaerin committed
9
    axios({ url: `/api/review?keyword=${props.place.name}`, method: 'post', data: { db: db } })
10
      .then(res => {
Kim, Chaerin's avatar
Kim, Chaerin committed
11
        console.log("place res.data", res.data)
Kim, Chaerin's avatar
.    
Kim, Chaerin committed
12
13
14
        setReviews(res.data.review)
        setDb(res.data.db)
        console.log(db)
15
16
17
18
19
20
21
22
23
24
      })
      .catch(err => {
        console.log(err)
      })
  }

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

Kim, Chaerin's avatar
Kim, Chaerin committed
25
  return (
26
27
28
29
30
31
32
    <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' }}>
baesangjune's avatar
baesangjune committed
33
          {props.place.name}
34
35
36
37
        </Modal.Title>
      </Modal.Header>
      <Modal.Body className="show-grid">
        <Container style={{ fontSize: '40px' }}>
baesangjune's avatar
baesangjune committed
38
          {Array.isArray(reviews) ? reviews.map((review) => {
39
40
41
42
            return (
              <Row className="mt-4">
                <a href={review.link}>{review.title}</a>
                <div>{review.summary}</div>
Kim, Chaerin's avatar
Kim, Chaerin committed
43
                <div>{review.content}</div>
44
45
              </Row>
            )
Kim, Chaerin's avatar
Kim, Chaerin committed
46
47
          })
            : "리뷰가 없습니다."}
baesangjune's avatar
review    
baesangjune committed
48
        </Container>
49
50
51
52
53
54

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

58
export default Place;