-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add return for dynamic folder useEffect * Remove function at constants * Fix import error * Refactor: 홈 마크업 및 스타일 개선 * Refactor: 회원가입 폼 커스텀 훅 구현 * Remove: 인증관련 컴포넌트 이동을 위해 삭제 * Feat: api url 변경으로 코드 수정 * Remove: 폴더 이동 * Feat: zustand 코드 정리 및 비밀번호 가시성 상태 추가 * Feat: 폼 컴포넌트 분리 후 적용(추후 레이아웃 구현) * Feat: 로그인 로직에 탠스택 쿼리 적용 * Feat: 회원가입 로직 탠스택 쿼리 적용 후 인증 로직 훅으로 분리 * Refactor: 로그인 부분 개선
- Loading branch information
Showing
24 changed files
with
404 additions
and
381 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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
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
File renamed without changes.
File renamed without changes.
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,78 @@ | ||
import { useForm } from "react-hook-form"; | ||
import useSignin from "@/hooks/auth/useSignin"; | ||
import { useStoreState } from "@/hooks/state"; | ||
import classNames from "classnames"; | ||
import { FormValues } from "@/types/form"; | ||
import { EMAIL_PATTERN, PW_PATTERN } from "@/constants"; | ||
import { FaEye, FaEyeSlash } from "react-icons/fa"; | ||
import styles from "../Form.module.css"; | ||
|
||
function SigninForm() { | ||
const { | ||
register, | ||
handleSubmit, | ||
formState: { errors }, | ||
} = useForm<FormValues>({ mode: "onBlur" }); | ||
const { currentType, toggleType } = useStoreState(); | ||
const { handleSignin } = useSignin(); | ||
|
||
return ( | ||
<form | ||
className={styles.formContainer} | ||
onSubmit={handleSubmit(handleSignin)} | ||
> | ||
<div className={styles.inputContainer}> | ||
<label className={styles.inputLabel} htmlFor="email"> | ||
이메일 | ||
</label> | ||
<input | ||
id="email" | ||
type="text" | ||
placeholder="이메일을 입력해 주세요" | ||
className={classNames(styles.inputWrapper, { | ||
[styles.errorBorder]: errors.email, | ||
})} | ||
{...register("email", { | ||
required: "이메일을 입력해 주세요", | ||
pattern: { | ||
value: EMAIL_PATTERN, | ||
message: "올바른 형식의 이메일을 입력해 주세요", | ||
}, | ||
})} | ||
/> | ||
{errors.email && ( | ||
<p className={styles.errorMessage}>{errors.email.message}</p> | ||
)} | ||
</div> | ||
<div className={styles.inputContainer}> | ||
<label className={styles.inputLabel} htmlFor="password"> | ||
비밀번호 | ||
</label> | ||
<input | ||
id="password" | ||
type={currentType} | ||
placeholder="영문, 숫자를 조합해 8자 이상 입력해 주세요" | ||
className={classNames(styles.inputWrapper, { | ||
[styles.errorBorder]: errors.password, | ||
})} | ||
{...register("password", { | ||
required: "비밀번호를 입력해 주세요", | ||
pattern: { | ||
value: PW_PATTERN, | ||
message: "영문, 숫자를 조합해 8자 이상 입력해 주세요", | ||
}, | ||
})} | ||
/> | ||
{errors.password && ( | ||
<p className={styles.errorMessage}>{errors.password.message}</p> | ||
)} | ||
<button className={styles.eyeIcon} type="button" onClick={toggleType}> | ||
{currentType === "password" ? <FaEye /> : <FaEyeSlash />} | ||
</button> | ||
</div> | ||
<button className={styles.submitButton}>로그인</button> | ||
</form> | ||
); | ||
} | ||
|
||
export default SigninForm; |
Oops, something went wrong.