Commit b54f3c44 authored by Yoon, Daeki's avatar Yoon, Daeki 😅
Browse files

signup form 변경

parent 4ad237e6
import React, { useState } from "react"; import React, { useState } from "react";
import Button from "react-bootstrap/Button"; import Button from "react-bootstrap/Button";
import Container from "react-bootstrap/Container";
import Row from "react-bootstrap/Row";
import Col from "react-bootstrap/Col";
import Form from "react-bootstrap/Form"; import Form from "react-bootstrap/Form";
import Modal from 'react-bootstrap/Modal' import Modal from "react-bootstrap/Modal";
import {Link} from 'react-router-dom' import { Link } from "react-router-dom";
import { create } from "./api-user"; import { create } from "./api-user";
function Signup() { function Signup() {
...@@ -10,13 +13,18 @@ function Signup() { ...@@ -10,13 +13,18 @@ function Signup() {
name: "", name: "",
password: "", password: "",
email: "", email: "",
instructor: false,
open: false, open: false,
error: "", error: "",
}); });
const handleChange = (name) => (event) => { const handleChange = (name) => (event) => {
const { value } = event.target; const { value, checked } = event.target;
if (name === "instructor") {
setValues({ ...values, instructor: checked });
} else {
setValues({ ...values, [name]: value }); setValues({ ...values, [name]: value });
}
}; };
const handleSubmit = (event) => { const handleSubmit = (event) => {
...@@ -25,6 +33,7 @@ function Signup() { ...@@ -25,6 +33,7 @@ function Signup() {
name: values.name || undefined, name: values.name || undefined,
email: values.email || undefined, email: values.email || undefined,
password: values.password || undefined, password: values.password || undefined,
instructor: values.instructor || undefined,
}; };
create(user).then((data) => { create(user).then((data) => {
if (data.error) { if (data.error) {
...@@ -37,14 +46,16 @@ function Signup() { ...@@ -37,14 +46,16 @@ function Signup() {
}; };
return ( return (
<div> <Container fluid>
<Row className="justify-content-center">
<Col className="col-sm-6 col-md-7">
<Form> <Form>
<Form.Group> <Form.Group>
<Form.Label>Name</Form.Label> <Form.Label>Name</Form.Label>
<Form.Control <Form.Control
type="text" type="text"
placeholder="Name" placeholder="Name"
onChange={handleChange('name')} onChange={handleChange("name")}
/> />
</Form.Group> </Form.Group>
<Form.Group> <Form.Group>
...@@ -52,7 +63,7 @@ function Signup() { ...@@ -52,7 +63,7 @@ function Signup() {
<Form.Control <Form.Control
type="password" type="password"
placeholder="Password" placeholder="Password"
onChange={handleChange('password')} onChange={handleChange("password")}
/> />
</Form.Group> </Form.Group>
<Form.Group> <Form.Group>
...@@ -60,25 +71,33 @@ function Signup() { ...@@ -60,25 +71,33 @@ function Signup() {
<Form.Control <Form.Control
type="email" type="email"
placeholder="Email" placeholder="Email"
onChange={handleChange('email')} onChange={handleChange("email")}
/> />
</Form.Group> </Form.Group>
<Button onClick={handleSubmit}>확인</Button> <Form.Check
type="checkbox"
// checked={values.instructor}
label="Instructor"
onChange={handleChange("instructor")}
/>
<Button className="my-3" onClick={handleSubmit}>
확인
</Button>
</Form> </Form>
<Modal show={values.open}> <Modal show={values.open}>
<Modal.Header> <Modal.Header>
<Modal.Title>New Account</Modal.Title> <Modal.Title>New Account</Modal.Title>
</Modal.Header> </Modal.Header>
<Modal.Body> <Modal.Body>New Account successfully created.</Modal.Body>
New Account successfully created.
</Modal.Body>
<Modal.Footer> <Modal.Footer>
<Link to='/signin'> <Link to="/signin">
<Button>Sign in</Button> <Button>Sign in</Button>
</Link> </Link>
</Modal.Footer> </Modal.Footer>
</Modal> </Modal>
</div> </Col>
</Row>
</Container>
); );
} }
......
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