App.js 1.57 KB
Newer Older
Kim, Chaerin's avatar
Kim, Chaerin committed
1
2
import React, { useEffect, useState } from 'react';
import { Link, Redirect } from 'react-router-dom';
Lee SeoYeon's avatar
.    
Lee SeoYeon committed
3
4
5
import ohuh from './ohuh.PNG'
import { Container, Row, Form, Image, InputGroup, Button, Col, FormControl, Navbar, Nav } from 'react-bootstrap';
import { handleLogout, isAuthenticated } from './utils/auth.js'
Lee SeoYeon's avatar
.    
Lee SeoYeon committed
6

Kim, Chaerin's avatar
Kim, Chaerin committed
7
function App() {
Kim, Chaerin's avatar
Kim, Chaerin committed
8
  const [state, setState] = useState(false);
Kim, Chaerin's avatar
Kim, Chaerin committed
9
  const [search, setSearch] = useState("");
Lee SeoYeon's avatar
0111    
Lee SeoYeon committed
10
  const user = isAuthenticated()
Lee SeoYeon's avatar
.    
Lee SeoYeon committed
11
  
Kim, Chaerin's avatar
Kim, Chaerin committed
12
13
14
15
16
17
  if (state !== false) {
    return <Redirect to={{
      pathname: `/search/${search}`,
      state: { id: search },
    }} />;
  }
Kim, Chaerin's avatar
Kim, Chaerin committed
18
19
20
21
22

  const handleChange = (e) => {
    setSearch(e.target.value);
  }

Kim, Chaerin's avatar
Kim, Chaerin committed
23
  const handleSubmit = () => {
Kim, Chaerin's avatar
Kim, Chaerin committed
24
25
26
27
    setState(true);
  }

  return (
Kim, Chaerin's avatar
서연    
Kim, Chaerin committed
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
    <Container className="vh-100 d-flex justify-content-md-center align-items-center">
      <Col md={6} lassName=" d-flex justify-content-center">
        <Row style={{marginBottom:20}}>
          <Image src={ohuh} />
        </Row>
        <Row style={{marginBottom:500}}>
          <Form className="vw-100" onSubmit={handleSubmit}>
            <InputGroup>
              <Form.Control
                size="lg"
                placeholder="검색어를 입력하세요."
                aria-label="Large"
                aria-describedby="inputGroup-sizing-sm"
                onChange={handleChange}
              />
              <InputGroup.Append>
                <Button type='submit' variant="outline-secondary">검색</Button>
              </InputGroup.Append>
            </InputGroup>
          </Form>
        </Row>
      </Col>
Kim, Chaerin's avatar
Kim, Chaerin committed
50
51
52
53
    </Container>
  );
}

Kim, Chaerin's avatar
?    
Kim, Chaerin committed
54
export default App;