Search.js 4.49 KB
Newer Older
Kim, Chaerin's avatar
Kim, Chaerin committed
1
2
3
import React, { useState } from 'react';
import { Link, Redirect } from 'react-router-dom';
import ohuh from './ohuh-sm.PNG';
Kim, Chaerin's avatar
Kim, Chaerin committed
4
5
6
import Place from './Components/Place';
import halla from './halla.jpg';
import { Container, Row, Card, Image, InputGroup, FormControl, Button, Form } from 'react-bootstrap';
Kim, Chaerin's avatar
Kim, Chaerin committed
7
8

function Search(props) {
Kim, Chaerin's avatar
Kim, Chaerin committed
9
10
11
12
13
14
15
16
17
18
19
    const [state, setState] = useState(false);
    const [search, setSearch] = useState(props.location.state.id);
    const [modalShow, setModalShow] = useState(false);

    if (state !== false) {
        return <Redirect to={{
          pathname: `/search/${search}`,
          state: { id: search },
        }} />;
      }

Kim, Chaerin's avatar
Kim, Chaerin committed
20
21
22
    const handleChange = (e) => {
        setSearch(e.target.value);
    }
Kim, Chaerin's avatar
Kim, Chaerin committed
23

Kim, Chaerin's avatar
Kim, Chaerin committed
24
    const handleSubmit = (e) => {
Kim, Chaerin's avatar
Kim, Chaerin committed
25
        setState(true);
Kim, Chaerin's avatar
Kim, Chaerin committed
26
27
    }
    return (
Kim, Chaerin's avatar
Kim, Chaerin committed
28
        <Container className="mt-3">
Kim, Chaerin's avatar
Kim, Chaerin committed
29
30
            <Row className="" >
                <InputGroup size="lg">
Kim, Chaerin's avatar
Kim, Chaerin committed
31
                    <Link to="/"><Image src={ohuh} /></Link>
Kim, Chaerin's avatar
Kim, Chaerin committed
32
33
                    <FormControl
                        placeholder="검색어를 입력하세요."
Kim, Chaerin's avatar
Kim, Chaerin committed
34
                        value={search}
Kim, Chaerin's avatar
Kim, Chaerin committed
35
36
37
38
39
40
41
42
43
                        aria-label="Large"
                        aria-describedby="inputGroup-sizing-sm"
                        onChange={handleChange}
                    />
                    <InputGroup.Append>
                        <Button variant="outline-secondary" onClick={handleSubmit}><Link to="/search">검색</Link></Button>
                    </InputGroup.Append>
                </InputGroup>
            </Row>
Kim, Chaerin's avatar
Kim, Chaerin committed
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
            <Form>
                <Row className="d-flex justify-content-between">
                    <Card style={{ width: '35rem' }}>
                        <Card.Img variant="top" src={halla} />
                        <Card.Body>
                            <Card.Title>한라산(hallasan)</Card.Title>
                            <Card.Text>
                                제주 서귀포시 토평동 산15-1 </Card.Text>
                                <Button variant="primary" onClick={() => setModalShow(true)}>한라산 자세히 살펴보기</Button>
                                <Place search={search} show={modalShow} onHide={() => setModalShow(false)} />
                        </Card.Body>
                    </Card>

                    <Card style={{ width: '35rem' }}>
                        <Card.Img variant="top" src={halla} />
                        <Card.Body>
                            <Card.Title>성산일출봉(sungsan)</Card.Title>
                            <Card.Text>
                                제주 서귀포시 성산읍 성산리 1 </Card.Text>
                                <Button variant="primary" onClick={() => setModalShow(true)}>성산일출봉 자세히 살펴보기</Button>
                                <Place search={search} show={modalShow} onHide={() => setModalShow(false)} />
                        </Card.Body>
                    </Card>
                </Row>
                <Row className="d-flex justify-content-between">
                    <Card style={{ width: '35rem' }}>
                        <Card.Img variant="top" src={halla} />
                        <Card.Body>
                            <Card.Title>해녀의 (haenyeo)</Card.Title>
                            <Card.Text>
                                제주 서귀포시 성산읍 한도로 141-13지번오조리 3 오조해녀의집 </Card.Text>
                                <Button variant="primary" onClick={() => setModalShow(true)}>해녀의  자세히 살펴보기</Button>
                                <Place search={search} show={modalShow} onHide={() => setModalShow(false)} />
                        </Card.Body>
                    </Card>

                    <Card style={{ width: '35rem' }}>
                        <Card.Img variant="top" src={halla} />
                        <Card.Body>
                            <Card.Title>오설록  뮤지엄(osulloc)</Card.Title>
                            <Card.Text>
                                제주 서귀포시 안덕면 신화역사로 15 오설록지번서광리 1235-1 오설록 </Card.Text>
                                <Button variant="primary" onClick={() => setModalShow(true)}>오설록  뮤지엄 자세히 살펴보기</Button>
                                <Place search={search} show={modalShow} onHide={() => setModalShow(false)} />
                        </Card.Body>
                    </Card>
                </Row>
            </Form>
Kim, Chaerin's avatar
Kim, Chaerin committed
92
93
94
95
96
        </Container>
    );
}

export default Search;