-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1027 from ayoung-iya/part3-윤아영-week15
[윤아영] week15
- Loading branch information
Showing
29 changed files
with
469 additions
and
64 deletions.
There are no files selected for viewing
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
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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { useFormContext } from 'react-hook-form'; | ||
import styles from '@/styles/sign.module.css'; | ||
import { useState } from 'react'; | ||
|
||
const InputGroup = ({ info }: any) => { | ||
const { | ||
register, | ||
trigger, | ||
formState: { errors }, | ||
} = useFormContext(); | ||
const [showText, setShowText] = useState(() => (info.id !== 'email' ? false : true)); | ||
const type = info.id === 'email' ? info.type : showText ? 'text' : info.type; | ||
const eyeClassName = `${styles.iconEye} ${showText ? styles.on : ''}`; | ||
const inputClassName = `${styles.input} ${errors[info.id]?.message ? styles.error : ''}`; | ||
|
||
return ( | ||
<> | ||
<label className={styles.label} htmlFor={info.id}> | ||
{info.label} | ||
</label> | ||
<div className={styles.inputGroup}> | ||
<input | ||
type={type} | ||
id={info.id} | ||
{...register(info.id, { ...info.validation, onBlur: async () => await trigger(info.id) })} | ||
placeholder={info.placeholder} | ||
className={inputClassName} | ||
/> | ||
{info.type === 'password' && ( | ||
<button type="button" className={eyeClassName} onClick={() => setShowText(!showText)} /> | ||
)} | ||
</div> | ||
{errors?.[info.id] && <p className={styles.messageError}>{errors[info.id]?.message as string}</p>} | ||
</> | ||
); | ||
}; | ||
|
||
export default InputGroup; |
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 |
---|---|---|
@@ -0,0 +1,69 @@ | ||
export const ERROR_MESSAGE = { | ||
email: { | ||
pattern: '올바른 이메일 주소가 아닙니다.', | ||
required: '이메일을 입력해 주세요.', | ||
checkRight: '이메일을 확인해 주세요.', | ||
}, | ||
password: { | ||
pattern: '비밀번호는 영문, 숫자 조합 8자 이상 입력해 주세요.', | ||
required: '비밀번호를 입력해 주세요', | ||
checkSame: '비밀번호가 일치하지 않아요', | ||
checkRight: '비밀번호를 확인해 주세요.', | ||
}, | ||
}; | ||
|
||
export const INPUT_INFO = { | ||
email: { | ||
id: 'email', | ||
type: 'email', | ||
label: '이메일', | ||
placeholder: '이메일를 입력해 주세요.', | ||
validation: { | ||
pattern: { | ||
value: /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/, | ||
message: ERROR_MESSAGE.email.pattern, | ||
}, | ||
required: ERROR_MESSAGE.email.required, | ||
}, | ||
}, | ||
password: { | ||
signIn: { | ||
id: 'password', | ||
type: 'password', | ||
label: '비밀번호', | ||
placeholder: '비밀번호를 입력해 주세요.', | ||
validation: { | ||
required: ERROR_MESSAGE.password.required, | ||
}, | ||
}, | ||
signUp: { | ||
id: 'password', | ||
type: 'password', | ||
label: '비밀번호 ', | ||
placeholder: '비밀번호를 입력해 주세요.', | ||
validation: { | ||
pattern: { | ||
value: /^(?=.*[a-zA-Z])(?=.*[0-9]).{8,}$/, | ||
message: ERROR_MESSAGE.password.pattern, | ||
}, | ||
required: ERROR_MESSAGE.password.required, | ||
}, | ||
}, | ||
}, | ||
passwordCheck: { | ||
id: 'passwordCheck', | ||
type: 'password', | ||
label: '비밀번호 확인', | ||
placeholder: '비밀번호와 일치하는 값을 입력해주세요.', | ||
validation: { | ||
validate: (value: any, formValues: any) => { | ||
if (value.length === 0 && formValues.password.length === 0) return ERROR_MESSAGE.password.required; | ||
return value !== formValues.password && ERROR_MESSAGE.password.checkSame; | ||
}, | ||
pattern: { | ||
value: /^(?=.*[a-zA-Z])(?=.*[0-9]).{8,}$/, | ||
message: ERROR_MESSAGE.password.pattern, | ||
}, | ||
}, | ||
}, | ||
}; |
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
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
Oops, something went wrong.