Commit f21119fa authored by Daeki Yoon's avatar Daeki Yoon
Browse files

signup 시작

parent abd187d8
...@@ -5,6 +5,7 @@ import Home from "./core/Home"; ...@@ -5,6 +5,7 @@ import Home from "./core/Home";
import Menu from "./core/Menu"; import Menu from "./core/Menu";
import NewQuiz from './quiz/NewQuiz' import NewQuiz from './quiz/NewQuiz'
import Quiz from './quiz/Quiz' import Quiz from './quiz/Quiz'
import Signup from "./user/Signup"
function MainRouter() { function MainRouter() {
return ( return (
...@@ -18,6 +19,9 @@ function MainRouter() { ...@@ -18,6 +19,9 @@ function MainRouter() {
<Route path="/signin"> <Route path="/signin">
<Signin /> <Signin />
</Route> </Route>
<Route path="/signup">
<Signup />
</Route>
<Route path='/quiz/new'> <Route path='/quiz/new'>
<NewQuiz /> <NewQuiz />
</Route> </Route>
......
import React from "react"; import React from "react"
import Navbar from "react-bootstrap/Navbar"; import Navbar from "react-bootstrap/Navbar"
import Nav from "react-bootstrap/Nav"; import Nav from "react-bootstrap/Nav"
import NavDropdown from "react-bootstrap/NavDropdown"; import NavDropdown from "react-bootstrap/NavDropdown"
import Button from "react-bootstrap/Button"; import Button from "react-bootstrap/Button"
import auth from "../auth/auth-helpers"; import auth from "../auth/auth-helpers"
import { Link, useHistory } from "react-router-dom"; import { Link, useHistory } from "react-router-dom"
import { useAuth } from "../auth/auth-context"; import { useAuth } from "../auth/auth-context"
function Menu() { function Menu() {
const {authUser, setAuthUser} = useAuth() const { authUser, setAuthUser } = useAuth()
const history = useHistory(); const history = useHistory()
return ( return (
<Navbar sticky="top" bg="dark" variant="dark" expand="sm"> <Navbar sticky="top" bg="dark" variant="dark" expand="sm">
...@@ -37,21 +37,26 @@ function Menu() { ...@@ -37,21 +37,26 @@ function Menu() {
<Button <Button
onClick={() => onClick={() =>
auth.clearJwt(() => { auth.clearJwt(() => {
history.push("/"); history.push("/")
setAuthUser(false); setAuthUser(false)
}) })
} }
> >
Sign out Sign out
</Button> </Button>
) : ( ) : (
<>
<Link to="/signin"> <Link to="/signin">
<Button>Sign in</Button> <Button>Sign in</Button>
</Link> </Link>
<Link to="/signup">
<Button>Sign up</Button>
</Link>
</>
)} )}
</Navbar.Collapse> </Navbar.Collapse>
</Navbar> </Navbar>
); )
} }
export default Menu; export default Menu
import React, { useState } from 'react'
import Button from 'react-bootstrap/Button'
import Form from 'react-bootstrap/Form'
function Signup() {
const [values, setValues] = useState({
name: '',
password: '',
email: '',
open: false,
error: '',
})
return (
<div>
<Form>
<Form.Group>
<Form.Label>Name</Form.Label>
<Form.Control type='text' placeholder='Name' />
</Form.Group>
<Form.Group>
<Form.Label>Password</Form.Label>
<Form.Control type='password' placeholder='Password' />
</Form.Group>
<Form.Group>
<Form.Label>Email</Form.Label>
<Form.Control type='email' placeholder='Email' />
</Form.Group>
<Button>확인</Button>
</Form>
</div>
)
}
export default Signup
const create = async (user) => {
try {
const response = await fetch('/api/users/', {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify(user)
})
return await response.json()
} catch (error) {
console.log(error)
}
}
export {
create,
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment