diff --git a/package.json b/package.json index 4ac8c82d..1a130929 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "react": "^18.3.1", "react-datepicker": "^7.2.0", "react-dom": "^18.3.1", + "react-hook-form": "^7.52.1", "react-router-dom": "^6.24.0", "react-spinners": "^0.14.1", "swiper": "^11.1.4" diff --git a/src/apis/domains/host/usePostHostApply.ts b/src/apis/domains/host/usePostHostApply.ts index 42428e53..a98e5c44 100644 --- a/src/apis/domains/host/usePostHostApply.ts +++ b/src/apis/domains/host/usePostHostApply.ts @@ -4,7 +4,7 @@ import { useEasyNavigate } from '@hooks'; import { components } from '@schema'; import { useQueryClient, useMutation } from '@tanstack/react-query'; import { ErrorResponse, ErrorType, MutateResponseType } from '@types'; -import { Dispatch, RefObject, SetStateAction } from 'react'; +import { Dispatch, SetStateAction } from 'react'; type HostApplyRequest = components['schemas']['SubmitterCreateRequest']; @@ -21,10 +21,10 @@ const postHostApply = async (hostApplyState: HostApplyRequest): Promise void, + // resetHostApplyState: () => void, onNext: () => void, setIsNicknameDuplicate: Dispatch>, - nicknameRef: RefObject + // nicknameRef: RefObject ) => { const queryClient = useQueryClient(); const { goGuestMyPage } = useEasyNavigate(); @@ -33,13 +33,13 @@ export const usePostHostApply = ( mutationFn: (hostApplyState: HostApplyRequest) => postHostApply(hostApplyState), onSuccess: () => { queryClient.invalidateQueries({ queryKey: [QUERY_KEY.HOST_APPLY] }); - resetHostApplyState(); + // resetHostApplyState(); onNext(); }, onError: (error: ErrorType) => { if (error.status === 40008) { setIsNicknameDuplicate(true); - nicknameRef.current?.focus(); + // nicknameRef.current?.focus(); } else { alert(error.message); goGuestMyPage(); diff --git a/src/components/common/CategorySelectBox/CategorySelectBox.tsx b/src/components/common/CategorySelectBox/CategorySelectBox.tsx index 9ab2f80d..81a604a2 100644 --- a/src/components/common/CategorySelectBox/CategorySelectBox.tsx +++ b/src/components/common/CategorySelectBox/CategorySelectBox.tsx @@ -71,7 +71,7 @@ interface Category { } interface CategorySelectBoxProps { - selectedCategories: Category; + selectedCategories: Category | undefined; onUpdateCategories: (newCategories: Category) => void; } diff --git a/src/components/common/TextArea/TextArea.tsx b/src/components/common/TextArea/TextArea.tsx index f3614b62..01f01b67 100644 --- a/src/components/common/TextArea/TextArea.tsx +++ b/src/components/common/TextArea/TextArea.tsx @@ -1,4 +1,4 @@ -import { TextareaHTMLAttributes, useState } from 'react'; +import { forwardRef, TextareaHTMLAttributes, useState } from 'react'; import { textAreaStyle, @@ -17,54 +17,49 @@ export interface TextAreaProps extends TextareaHTMLAttributes { - const [maxLengthError, setMaxLengthError] = useState(false); - const [isFocused, setIsFocused] = useState(false); - // 글자 수 세서 바로 화면에 반영하는 onChange 함수 (default) - const handleTextAreaChange = (e: React.ChangeEvent) => { - if (e.target.value.length <= maxLength) { - onChange(e); - setMaxLengthError(false); - } else { - setMaxLengthError(true); - } - }; +const TextArea = forwardRef( + ({ value, onChange, isValid, size = 'small', placeholder, errorMessage, maxLength }, ref) => { + const [maxLengthError, setMaxLengthError] = useState(false); + const [isFocused, setIsFocused] = useState(false); + // 글자 수 세서 바로 화면에 반영하는 onChange 함수 (default) + const handleTextAreaChange = (e: React.ChangeEvent) => { + if (e.target.value.length <= maxLength) { + onChange(e); + setMaxLengthError(false); + } else { + setMaxLengthError(true); + } + }; - // TODO: constants 파일에 분리하기 - // 글자 수 에러 메시지 - const textLengthErrorMessage = `* 글자 수 ${maxLength}자 이하로 입력해주세요.`; + // TODO: constants 파일에 분리하기 + // 글자 수 에러 메시지 + const textLengthErrorMessage = `* 글자 수 ${maxLength}자 이하로 입력해주세요.`; - const isError = maxLengthError || !isValid; + const isError = maxLengthError || !isValid; - return ( -
-
-