From 46ba74e060d07eb5e1fb03c7b9e3799a91127412 Mon Sep 17 00:00:00 2001 From: jisu Seo Date: Sat, 6 Jan 2024 15:02:25 +0900 Subject: [PATCH] =?UTF-8?q?Feat:=20=EA=B8=B0=EB=B3=B8=20=EB=A1=9C=EA=B7=B8?= =?UTF-8?q?=EC=9D=B8=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/@types/auth.types.ts | 4 +- src/components/user/ErrorMessage.tsx | 9 ++ src/components/user/index.ts | 3 +- .../user/useInputBox/UserInputBox.tsx | 41 +++++---- src/pages/login/login.page.tsx | 85 ++++++++++++++----- 5 files changed, 96 insertions(+), 46 deletions(-) create mode 100644 src/components/user/ErrorMessage.tsx diff --git a/src/@types/auth.types.ts b/src/@types/auth.types.ts index 589b7210..c95769ab 100644 --- a/src/@types/auth.types.ts +++ b/src/@types/auth.types.ts @@ -1,4 +1,4 @@ -interface AuthRequest { +export interface AuthRequest { email: string; password: string; name: string; @@ -9,7 +9,7 @@ interface AuthRequest { survey: string; } -interface LoginRequest { +export interface LoginFormVlaue { email: string; password: string; } diff --git a/src/components/user/ErrorMessage.tsx b/src/components/user/ErrorMessage.tsx new file mode 100644 index 00000000..89f8e587 --- /dev/null +++ b/src/components/user/ErrorMessage.tsx @@ -0,0 +1,9 @@ +interface Props { + children: string; +} + +const ErrorMessage = ({ children }: Props) => { + return

{children}

; +}; + +export default ErrorMessage; diff --git a/src/components/user/index.ts b/src/components/user/index.ts index 4d720963..844de37c 100644 --- a/src/components/user/index.ts +++ b/src/components/user/index.ts @@ -1,5 +1,6 @@ import UserInputBox from './useInputBox/UserInputBox'; import UserEmailInputBox from './useInputBox/UserEmailInputBox'; import UserPwInputBox from './useInputBox/UserPwInputBox'; +import ErrorMessage from './ErrorMessage'; -export { UserInputBox, UserEmailInputBox, UserPwInputBox }; \ No newline at end of file +export { UserInputBox, UserEmailInputBox, UserPwInputBox, ErrorMessage }; diff --git a/src/components/user/useInputBox/UserInputBox.tsx b/src/components/user/useInputBox/UserInputBox.tsx index edea2f2c..a969e1b8 100644 --- a/src/components/user/useInputBox/UserInputBox.tsx +++ b/src/components/user/useInputBox/UserInputBox.tsx @@ -1,52 +1,49 @@ -import { useState } from 'react'; import { CloseIcon } from '@components/common/icons/Icons'; +import { UseFormRegisterReturn, UseFormSetValue } from 'react-hook-form'; +import { LoginFormVlaue } from '@/@types/auth.types'; interface Props { label: string; - type?: string; - name: string; + id: 'email' | 'password'; + type?: 'text' | 'email' | 'password'; placeholder: string; - // children: React.ReactNode; - validifyCheckList?: string[]; - // onInputBlur: VoidFunction; + register: UseFormRegisterReturn; + inputValue: string; + setValue: UseFormSetValue; marginB?: string; + // validifyCheckList?: string[]; + // onInputBlur: VoidFunction; + // children: React.ReactNode; } const UserInputBox = ({ label, - type = 'password', - name, + id, + type = 'text', placeholder, - // validifyCheckList, + register, + inputValue, + setValue, marginB = 'mb-6', }: Props) => { - const [inputValue, setInputValue] = useState(''); - - const onInputChange = (e: React.ChangeEvent) => { - setInputValue(e.target.value); - }; - return (
-