정의왕

Register ver1.0

import React, { useState } from "react";
import React, {useCallback, useState} from "react";
import "../style/RegisterPage.scss";
import { Icon, Input } from "semantic-ui-react"
import { Button, Icon, Input } from "semantic-ui-react"
function RegisterPage() {
const [Email, setEmail] = useState("");
const [Password, setPassword] = useState("");
const [PasswordCheck,setPasswordCheck] = useState("");
const [Personality, setPersonality] = useState("");
const [PasswordError,setPasswordError] = useState(false);
const onIdHandler = (event) => {
setEmail(event.currentTarget.value);
......@@ -12,11 +15,22 @@ function RegisterPage() {
const onPasswordHandler = (event) => {
setPassword(event.currentTarget.value);
};
const onSubmitHandler = (event) => {
const onPersonalityHandler = (event) => {
setPersonality(event.currentTarget.value);
};
const onPasswordChkHandler = useCallback((event) => {
//비밀번호를 입력할때마다 password 를 검증하는 함수
setPasswordError(event.currentTarget.value !== Password);
setPasswordCheck(event.currentTarget.value);
},[PasswordCheck]);
const onSubmitHandler = useCallback((event) => {
event.preventDefault();
if(Password !== PasswordCheck){
return setPasswordError(true);
}
console.log("Email",Email);
console.log("Password", Password);
};
},[Password,PasswordCheck]);
return (
<div id="body">
<div className="register-form">
......@@ -30,7 +44,7 @@ function RegisterPage() {
type="text"
value={Email}
autoComplete="off"
onChange={onIdHandler}/>
required onChange={onIdHandler}/>
</div>
<div className="input-area">
<Input
......@@ -41,9 +55,34 @@ function RegisterPage() {
value={Password}
autoComplete="off"
onChange={onPasswordHandler}/>
{PasswordError && <div style={{color : 'red'}}>!</div>}
</div>
<div className="input-area">
<Input
icon={<Icon name='check'/>}
iconPosition='left'
placeholder="Check your Password"
type="password"
value={PasswordCheck}
autoComplete="off"
onChange={onPasswordChkHandler}/>
</div>
<div className="input-area">
<Input
icon={<Icon name='heart'/>}
iconPosition='left'
placeholder="Your MBTI"
type="text"
value={Personality}
autoComplete="off"
onChange={onPersonalityHandler}/>
</div>
<div className="btn-area">
<button className="register-btn" >Register</button>
<div className="btn-area" >
<Button className='register-btn'
content='Sign up'
icon='signup'
size='small'
iconPosition='left'/>
</div>
</form>
</div>
......

54.8 KB | W: | H:

58.2 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin
......@@ -8,7 +8,7 @@
justify-content: center;
align-items: center;
height: 100vh;
background-image: url("../images/login_background.png");
background-image: linear-gradient( rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.3) ), url("../images/register_background.png");
background-repeat: no-repeat;
background-position: center;
.register-form {
......@@ -62,8 +62,8 @@
margin-top: 30px;
.register-btn {
width: 150px;
height: 50px;
width: 170px;
height: 55px;
background-color: transparent;
font-size: 20px;
color: white;
......