Bookmark.js 2.11 KB
Newer Older
Lee SeoYeon's avatar
.    
Lee SeoYeon committed
1
2
3
import React, { useState, useEffect } from 'react'
import { Alert, Col, Card, Container, Form, Row, Button, Nav, Navbar, ListGroup, Image, Table } from "react-bootstrap"
import axios from "axios"
Lee SeoYeon's avatar
.    
Lee SeoYeon committed
4
import catchErrors from './utils/catchErrors.js'
Lee SeoYeon's avatar
.    
Lee SeoYeon committed
5
6
import { Redirect } from 'react-router-dom'

Lee SeoYeon's avatar
.    
Lee SeoYeon committed
7
8
9
10
11
const INIT_PAGE = {
    title: '',
    url: '',
}

Lee SeoYeon's avatar
.    
Lee SeoYeon committed
12
function Bookmark() {
Lee SeoYeon's avatar
.    
Lee SeoYeon committed
13
14
    const [page, setPage] = useState(INIT_PAGE)
    const [success, setSuccess] = useState(false)
Lee SeoYeon's avatar
.    
Lee SeoYeon committed
15
16
17
18
19
20
21
    const [error, setError] = useState('')


    function handleChange(event) {
        const {title, value} = event.target
        setPage({...page, [title]: value})
    }
Lee SeoYeon's avatar
.    
Lee SeoYeon committed
22
23
24
25
26

    async function handleSubmit(event) {
        event.preventDefault()
        try {
            setError('')
Lee SeoYeon's avatar
.    
Lee SeoYeon committed
27
            const response = await axios.post('/api/users/bookmark ', page)
Lee SeoYeon's avatar
.    
Lee SeoYeon committed
28
            console.log(response.data)
Lee SeoYeon's avatar
.    
Lee SeoYeon committed
29
            console.log(page)
Lee SeoYeon's avatar
.    
Lee SeoYeon committed
30
31
32
33
34
35
36
37
            // setUser(INIT_USER)
            setSuccess(true)
        } catch (error) {
            console.log(error)
            catchErrors(error, setError)
        }
    }

Lee SeoYeon's avatar
.    
Lee SeoYeon committed
38
39
40
41
42
43
44
45
46
    const add_Page = [{
        title:'즐겨찾기1',
        url:'http://localhost:3000',
    }, {
        title:'즐겨찾기2',
        url:'https://www.naver.com/',
    }, {
        title:'즐겨찾기3',
        url:'https://www.youtube.com/watch?v=wo46N-LQK7o'
Lee SeoYeon's avatar
.    
Lee SeoYeon committed
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
    }]

    return (
        <Container>
            <Navbar bg="primary" variant="dark">
                <Navbar.Brand href="/">북마크</Navbar.Brand>
                <Nav className="mr-auto">
                    <Nav.Link href="/">Home</Nav.Link>
                </Nav>
                {/* <Form inline>
                <FormControl type="text" placeholder="Search" className="mr-sm-2" />
                <Button variant="outline-light">Search</Button>
            </Form> */}
            </Navbar>
                <Form>
                    <ListGroup>
Lee SeoYeon's avatar
.    
Lee SeoYeon committed
63
                        <ListGroup.Item action href="">북마크1</ListGroup.Item>
Lee SeoYeon's avatar
.    
Lee SeoYeon committed
64
65
66
67
68
69
70
71
                        <ListGroup.Item>북마크2</ListGroup.Item>
                    </ListGroup>
                </Form>
        </Container>
    )
}

export default Bookmark