-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* formstate err * #19 feat: 로그인 유효성검증 * feat:login-style-prototype * feat:login-style-prototype * test(#19) * feat:19-login-style2(#19) * feat:19-login-style3(#19) * feat/19-login-style(3)
- Loading branch information
Showing
19 changed files
with
1,044 additions
and
102 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,73 @@ | ||
.nav{width: 100%;height: 60px;background: #eff2f4; position: fixed; top: 0;left: 0;z-index: 9000;} | ||
.container{max-width: 1440px; height: 100%; display: flex; justify-content: space-between; align-items: center; padding: 0 20px; box-sizing: border-box; margin: 0 auto;} | ||
.nav { | ||
width: 100%; | ||
height: 60px; | ||
background: #eff2f4; | ||
position: fixed; | ||
top: 0; | ||
left: 0; | ||
z-index: 9000; | ||
} | ||
.container { | ||
max-width: 1440px; | ||
height: 100%; | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: center; | ||
padding: 0 20px; | ||
box-sizing: border-box; | ||
margin: 0 auto; | ||
} | ||
|
||
/* 로고 */ | ||
.logo{width: 49px;height: 54px; cursor: pointer;} | ||
.logo img{width: 100%;height: 100%;object-fit: cover;} | ||
.logo { | ||
width: 49px; | ||
height: 54px; | ||
cursor: pointer; | ||
} | ||
.logo img { | ||
width: 100%; | ||
height: 100%; | ||
object-fit: cover; | ||
} | ||
|
||
@media (max-width: 767px) { | ||
.container { | ||
padding: 0 10px; | ||
} | ||
.nav { | ||
width: 100%; | ||
height: 60px; | ||
background: #eff2f4; | ||
position: fixed; | ||
top: 0; | ||
left: 0; | ||
z-index: 9000; | ||
} | ||
.container { | ||
max-width: 1440px; | ||
height: 100%; | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: center; | ||
padding: 0 20px; | ||
box-sizing: border-box; | ||
margin: 0 auto; | ||
} | ||
} | ||
/* 로고 */ | ||
.logo { | ||
width: 49px; | ||
height: 54px; | ||
cursor: pointer; | ||
} | ||
.logo img { | ||
width: 100%; | ||
height: 100%; | ||
object-fit: cover; | ||
} | ||
|
||
@media (max-width : 767px){ | ||
.container{padding: 0 10px; } | ||
@media (max-width: 767px) { | ||
.container { | ||
padding: 0 10px; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
import React from 'react'; | ||
import { Link } from 'react-router-dom'; | ||
import { useForm } from 'react-hook-form'; | ||
import { BASE_URL, USER_URL } from '../../../constants/api'; | ||
import axios from 'axios'; | ||
import { useEffect } from 'react'; | ||
import styles from './style.module.css'; | ||
|
||
const Form = () => { | ||
const { register, handleSubmit, getValues, formState } = useForm(); | ||
// input 에 들어있는 email value | ||
const email = getValues('email'); | ||
// input 에 들어있는 password value | ||
const password = getValues('password'); | ||
// 회원가입시 전송될 데이터 | ||
const sendLoginData = async () => { | ||
//login api data | ||
const user = { | ||
email, | ||
password, | ||
}; | ||
try { | ||
const response = await axios.post(`${BASE_URL} ${USER_URL.LOGIN}`, { user }); | ||
console.log(response); | ||
} catch (err) { | ||
console.log(err); | ||
} | ||
}; | ||
// form 안에 input, error 등이 변할경우 useEffect 실행. | ||
useEffect(() => {}, [formState]); | ||
|
||
return ( | ||
<> | ||
<form className={styles.form} onSubmit={handleSubmit(sendLoginData)}> | ||
<span className={styles.span}> | ||
이메일<span className={styles.spanICon}>*</span> | ||
<span className={styles.error}>{formState.errors.email?.message}</span> | ||
</span> | ||
{/* email 유효성검사 메시지 */} | ||
|
||
{/* password 유효성검사 메시지 */} | ||
|
||
<input | ||
className={styles.input} | ||
{...register('email', { | ||
required: '이메일은 필수 입력입니다.', | ||
// email 최소길이 | ||
minLength: { | ||
value: 5, | ||
message: '5글자이상 입력해주세요.', | ||
}, | ||
// email 정규식 | ||
pattern: { | ||
value: /^[a-zA-Z0-9]+@[a-z0-9]+\.[a-z]{2,3}/, | ||
message: '이메일 형식은 @와 .이들어가야합니다.', | ||
}, | ||
// email 최대길이 | ||
maxLength: { | ||
value: 22, | ||
message: '22글자 이하로 입력해주세요.', | ||
}, | ||
})} | ||
type="text" | ||
placeholder="이메일을 입력해주세요" | ||
></input> | ||
<span className={styles.span2}> | ||
비밀번호<span className={styles.spanICon}>*</span> | ||
<span className={styles.error}>{formState.errors.password?.message}</span> | ||
</span> | ||
<input | ||
className={styles.input} | ||
{...register('password', { | ||
required: '비밀번호는 필수입니다.', | ||
minLength: { | ||
// password 최소길이 | ||
value: 8, | ||
message: '비밀번호는 8글자이상입력부탁드립니다', | ||
}, | ||
// password 최대길이 | ||
maxLength: { | ||
value: 14, | ||
message: '비밀번호는 14글자 이하로부탁드립니다', | ||
}, | ||
// password 정규식 | ||
pattern: { | ||
value: /[`~!@#$%^&*|₩₩₩'₩";:₩/?]/gi, | ||
message: '비밀번호는 특수문자 ~!@#$%^&* 포함해주셔야합니다.', | ||
}, | ||
})} | ||
type="password" | ||
placeholder="비밀번호를 입력해주세요" | ||
></input> | ||
<div className={styles.passwordBox}> | ||
<Link to="#"> | ||
<span>비밀번호 찾기</span> | ||
</Link> | ||
</div> | ||
<button className={styles.btn}>로그인</button> | ||
<button className={styles.btn}>회원가입</button> | ||
</form> | ||
</> | ||
); | ||
}; | ||
|
||
export default Form; |
Oops, something went wrong.