Showing
5 changed files
with
49 additions
and
10 deletions
| 1 | -import React, { useState } from "react"; | 1 | +import React, {useCallback, useState} from "react"; |
| 2 | import "../style/RegisterPage.scss"; | 2 | import "../style/RegisterPage.scss"; |
| 3 | -import { Icon, Input } from "semantic-ui-react" | 3 | +import { Button, Icon, Input } from "semantic-ui-react" |
| 4 | 4 | ||
| 5 | function RegisterPage() { | 5 | function RegisterPage() { |
| 6 | const [Email, setEmail] = useState(""); | 6 | const [Email, setEmail] = useState(""); |
| 7 | const [Password, setPassword] = useState(""); | 7 | const [Password, setPassword] = useState(""); |
| 8 | + const [PasswordCheck,setPasswordCheck] = useState(""); | ||
| 9 | + const [Personality, setPersonality] = useState(""); | ||
| 10 | + const [PasswordError,setPasswordError] = useState(false); | ||
| 8 | 11 | ||
| 9 | const onIdHandler = (event) => { | 12 | const onIdHandler = (event) => { |
| 10 | setEmail(event.currentTarget.value); | 13 | setEmail(event.currentTarget.value); |
| ... | @@ -12,11 +15,22 @@ function RegisterPage() { | ... | @@ -12,11 +15,22 @@ function RegisterPage() { |
| 12 | const onPasswordHandler = (event) => { | 15 | const onPasswordHandler = (event) => { |
| 13 | setPassword(event.currentTarget.value); | 16 | setPassword(event.currentTarget.value); |
| 14 | }; | 17 | }; |
| 15 | - const onSubmitHandler = (event) => { | 18 | + const onPersonalityHandler = (event) => { |
| 19 | + setPersonality(event.currentTarget.value); | ||
| 20 | + }; | ||
| 21 | + const onPasswordChkHandler = useCallback((event) => { | ||
| 22 | + //비밀번호를 입력할때마다 password 를 검증하는 함수 | ||
| 23 | + setPasswordError(event.currentTarget.value !== Password); | ||
| 24 | + setPasswordCheck(event.currentTarget.value); | ||
| 25 | + },[PasswordCheck]); | ||
| 26 | + const onSubmitHandler = useCallback((event) => { | ||
| 16 | event.preventDefault(); | 27 | event.preventDefault(); |
| 28 | + if(Password !== PasswordCheck){ | ||
| 29 | + return setPasswordError(true); | ||
| 30 | + } | ||
| 17 | console.log("Email",Email); | 31 | console.log("Email",Email); |
| 18 | console.log("Password", Password); | 32 | console.log("Password", Password); |
| 19 | - }; | 33 | + },[Password,PasswordCheck]); |
| 20 | return ( | 34 | return ( |
| 21 | <div id="body"> | 35 | <div id="body"> |
| 22 | <div className="register-form"> | 36 | <div className="register-form"> |
| ... | @@ -30,7 +44,7 @@ function RegisterPage() { | ... | @@ -30,7 +44,7 @@ function RegisterPage() { |
| 30 | type="text" | 44 | type="text" |
| 31 | value={Email} | 45 | value={Email} |
| 32 | autoComplete="off" | 46 | autoComplete="off" |
| 33 | - onChange={onIdHandler}/> | 47 | + required onChange={onIdHandler}/> |
| 34 | </div> | 48 | </div> |
| 35 | <div className="input-area"> | 49 | <div className="input-area"> |
| 36 | <Input | 50 | <Input |
| ... | @@ -41,9 +55,34 @@ function RegisterPage() { | ... | @@ -41,9 +55,34 @@ function RegisterPage() { |
| 41 | value={Password} | 55 | value={Password} |
| 42 | autoComplete="off" | 56 | autoComplete="off" |
| 43 | onChange={onPasswordHandler}/> | 57 | onChange={onPasswordHandler}/> |
| 58 | + {PasswordError && <div style={{color : 'red'}}>!</div>} | ||
| 59 | + </div> | ||
| 60 | + <div className="input-area"> | ||
| 61 | + <Input | ||
| 62 | + icon={<Icon name='check'/>} | ||
| 63 | + iconPosition='left' | ||
| 64 | + placeholder="Check your Password" | ||
| 65 | + type="password" | ||
| 66 | + value={PasswordCheck} | ||
| 67 | + autoComplete="off" | ||
| 68 | + onChange={onPasswordChkHandler}/> | ||
| 69 | + </div> | ||
| 70 | + <div className="input-area"> | ||
| 71 | + <Input | ||
| 72 | + icon={<Icon name='heart'/>} | ||
| 73 | + iconPosition='left' | ||
| 74 | + placeholder="Your MBTI" | ||
| 75 | + type="text" | ||
| 76 | + value={Personality} | ||
| 77 | + autoComplete="off" | ||
| 78 | + onChange={onPersonalityHandler}/> | ||
| 44 | </div> | 79 | </div> |
| 45 | - <div className="btn-area"> | 80 | + <div className="btn-area" > |
| 46 | - <button className="register-btn" >Register</button> | 81 | + <Button className='register-btn' |
| 82 | + content='Sign up' | ||
| 83 | + icon='signup' | ||
| 84 | + size='small' | ||
| 85 | + iconPosition='left'/> | ||
| 47 | </div> | 86 | </div> |
| 48 | </form> | 87 | </form> |
| 49 | </div> | 88 | </div> | ... | ... |
54.8 KB
| ... | @@ -8,7 +8,7 @@ | ... | @@ -8,7 +8,7 @@ |
| 8 | justify-content: center; | 8 | justify-content: center; |
| 9 | align-items: center; | 9 | align-items: center; |
| 10 | height: 100vh; | 10 | height: 100vh; |
| 11 | - background-image: url("../images/login_background.png"); | 11 | + background-image: linear-gradient( rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.3) ), url("../images/register_background.png"); |
| 12 | background-repeat: no-repeat; | 12 | background-repeat: no-repeat; |
| 13 | background-position: center; | 13 | background-position: center; |
| 14 | .register-form { | 14 | .register-form { |
| ... | @@ -62,8 +62,8 @@ | ... | @@ -62,8 +62,8 @@ |
| 62 | margin-top: 30px; | 62 | margin-top: 30px; |
| 63 | 63 | ||
| 64 | .register-btn { | 64 | .register-btn { |
| 65 | - width: 150px; | 65 | + width: 170px; |
| 66 | - height: 50px; | 66 | + height: 55px; |
| 67 | background-color: transparent; | 67 | background-color: transparent; |
| 68 | font-size: 20px; | 68 | font-size: 20px; |
| 69 | color: white; | 69 | color: white; | ... | ... |
-
Please register or login to post a comment