From 6ca10e813ce1445b167ae141b8f8182cecbc7d07 Mon Sep 17 00:00:00 2001 From: ImxYJL Date: Wed, 4 Sep 2024 14:54:35 +0900 Subject: [PATCH 1/5] =?UTF-8?q?refactor:=20TEXT=5FANSWER=5FLENGTH=20?= =?UTF-8?q?=EC=83=81=EC=88=98=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/pages/ReviewWritingPage/constants/index.ts | 1 + frontend/src/pages/ReviewWritingPage/constants/textarea.ts | 5 +++++ 2 files changed, 6 insertions(+) create mode 100644 frontend/src/pages/ReviewWritingPage/constants/textarea.ts diff --git a/frontend/src/pages/ReviewWritingPage/constants/index.ts b/frontend/src/pages/ReviewWritingPage/constants/index.ts index 133aa7420..18f5aa63b 100644 --- a/frontend/src/pages/ReviewWritingPage/constants/index.ts +++ b/frontend/src/pages/ReviewWritingPage/constants/index.ts @@ -1 +1,2 @@ export * from './modal'; +export * from './textarea'; diff --git a/frontend/src/pages/ReviewWritingPage/constants/textarea.ts b/frontend/src/pages/ReviewWritingPage/constants/textarea.ts new file mode 100644 index 000000000..e678d67de --- /dev/null +++ b/frontend/src/pages/ReviewWritingPage/constants/textarea.ts @@ -0,0 +1,5 @@ +export const TEXT_ANSWER_LENGTH = { + min: 20, + max: 1000, + extra: 10, +}; From d242806e92166fa5a1462e4aeff807746e6bd9df Mon Sep 17 00:00:00 2001 From: ImxYJL Date: Wed, 4 Sep 2024 14:55:46 +0900 Subject: [PATCH 2/5] =?UTF-8?q?refactor:=20=EC=84=9C=EC=88=A0=ED=98=95=20?= =?UTF-8?q?=ED=95=84=EC=88=98=20=EC=A7=81=EB=AC=B8=EC=97=90=20=EC=B5=9C?= =?UTF-8?q?=EC=86=8C/=EC=B5=9C=EB=8C=80=20=EA=B8=80=EC=9E=90=20=EC=88=98?= =?UTF-8?q?=20=ED=91=9C=EC=8B=9C=20=EB=B0=8F=20textarea=EC=9D=98=20placeho?= =?UTF-8?q?lder=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ReviewWritingPage/form/components/QnABox/index.tsx | 10 ++++++++-- .../form/components/TextAnswer/index.tsx | 3 +-- .../form/hooks/answers/useTextAnswer/index.ts | 7 +------ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/frontend/src/pages/ReviewWritingPage/form/components/QnABox/index.tsx b/frontend/src/pages/ReviewWritingPage/form/components/QnABox/index.tsx index 7c5fee946..98a814e95 100644 --- a/frontend/src/pages/ReviewWritingPage/form/components/QnABox/index.tsx +++ b/frontend/src/pages/ReviewWritingPage/form/components/QnABox/index.tsx @@ -1,3 +1,4 @@ +import { TEXT_ANSWER_LENGTH } from '@/pages/ReviewWritingPage/constants'; import { MultipleChoiceAnswer, TextAnswer } from '@/pages/ReviewWritingPage/form/components'; import { ReviewWritingCardQuestion } from '@/types'; @@ -15,12 +16,17 @@ const QnABox = ({ question }: QnABoxProps) => { * 객관식 문항의 최소,최대 개수에 대한 안내 문구 */ const multipleLGuideline = (() => { - const { optionGroup } = question; - if (!optionGroup) return; + const { optionGroup, questionType } = question; + + if (question.required && questionType === 'TEXT') { + return `(최소 ${TEXT_ANSWER_LENGTH.min}자 ~ 최대 ${TEXT_ANSWER_LENGTH.max}자)`; + } + if (!optionGroup) return; const { minCount, maxCount } = optionGroup; const isAllSelectAvailable = maxCount === optionGroup.options.length; + if (!maxCount || isAllSelectAvailable) return `(최소 ${minCount}개 이상)`; return `(${minCount}개 ~ ${maxCount}개)`; diff --git a/frontend/src/pages/ReviewWritingPage/form/components/TextAnswer/index.tsx b/frontend/src/pages/ReviewWritingPage/form/components/TextAnswer/index.tsx index 3b8fe9e9a..9f76b4f13 100644 --- a/frontend/src/pages/ReviewWritingPage/form/components/TextAnswer/index.tsx +++ b/frontend/src/pages/ReviewWritingPage/form/components/TextAnswer/index.tsx @@ -8,7 +8,7 @@ interface TextAnswerProps { } const TextAnswer = ({ question }: TextAnswerProps) => { - const { text, minLength, maxLength, errorMessage, handleTextAnswerBlur, handleTextAnswerChange } = useTextAnswer({ + const { text, maxLength, errorMessage, handleTextAnswerBlur, handleTextAnswerChange } = useTextAnswer({ question, }); @@ -22,7 +22,6 @@ const TextAnswer = ({ question }: TextAnswerProps) => { $isError={errorMessage !== ''} onChange={handleTextAnswerChange} onBlur={handleTextAnswerBlur} - placeholder={`최소 ${minLength}자 이상, 최대 ${maxLength}자까지 입력 가능해요`} /> {errorMessage} diff --git a/frontend/src/pages/ReviewWritingPage/form/hooks/answers/useTextAnswer/index.ts b/frontend/src/pages/ReviewWritingPage/form/hooks/answers/useTextAnswer/index.ts index 2dea901db..ee0f18ebe 100644 --- a/frontend/src/pages/ReviewWritingPage/form/hooks/answers/useTextAnswer/index.ts +++ b/frontend/src/pages/ReviewWritingPage/form/hooks/answers/useTextAnswer/index.ts @@ -1,15 +1,10 @@ import { useState } from 'react'; +import { TEXT_ANSWER_LENGTH } from '@/pages/ReviewWritingPage/constants'; import { ReviewWritingAnswer, ReviewWritingCardQuestion } from '@/types'; import useUpdateReviewerAnswer from '../useUpdateReviewerAnswer'; -export const TEXT_ANSWER_LENGTH = { - min: 20, - max: 1000, - extra: 10, -}; - export const TEXT_ANSWER_ERROR_MESSAGE = { min: `최소 ${TEXT_ANSWER_LENGTH.min}자 이상 작성해 주세요`, max: `최대 ${TEXT_ANSWER_LENGTH.max}자까지만 입력 가능해요`, From ea2997a20eeead562b48a6129982aa0f407c1191 Mon Sep 17 00:00:00 2001 From: ImxYJL Date: Wed, 4 Sep 2024 17:16:59 +0900 Subject: [PATCH 3/5] =?UTF-8?q?test:=20=EB=A6=AC=ED=8C=A9=ED=86=A0?= =?UTF-8?q?=EB=A7=81=EC=97=90=20=EB=94=B0=EB=A5=B8=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20import=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../form/hooks/answers/useTextAnswer/test.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/frontend/src/pages/ReviewWritingPage/form/hooks/answers/useTextAnswer/test.tsx b/frontend/src/pages/ReviewWritingPage/form/hooks/answers/useTextAnswer/test.tsx index df0525110..ba9a35b3f 100644 --- a/frontend/src/pages/ReviewWritingPage/form/hooks/answers/useTextAnswer/test.tsx +++ b/frontend/src/pages/ReviewWritingPage/form/hooks/answers/useTextAnswer/test.tsx @@ -2,6 +2,7 @@ import { act, renderHook, waitFor } from '@testing-library/react'; import { RecoilRoot, RecoilState, useRecoilValue } from 'recoil'; import { FEEDBACK_SECTION } from '@/mocks/mockData'; +import { TEXT_ANSWER_LENGTH } from '@/pages/ReviewWritingPage/constants'; import { answerMapAtom, answerValidationMapAtom, @@ -12,7 +13,7 @@ import { EssentialPropsWithChildren, ReviewWritingCardSection } from '@/types'; import useUpdateDefaultAnswers from '../useUpdateDefaultAnswers'; -import useTextAnswer, { TEXT_ANSWER_ERROR_MESSAGE, TEXT_ANSWER_LENGTH } from '.'; +import useTextAnswer, { TEXT_ANSWER_ERROR_MESSAGE } from '.'; const MOCK_SECTION_LIST = [FEEDBACK_SECTION]; const NOT_REQUIRED_MOCK_SECTION_LIST: ReviewWritingCardSection[] = [ From 792b3e2fd5740f42bc36dda0e3deab42783f0f70 Mon Sep 17 00:00:00 2001 From: ImxYJL Date: Wed, 4 Sep 2024 17:47:48 +0900 Subject: [PATCH 4/5] =?UTF-8?q?refactor:=20=EC=A3=BC=EA=B4=80=EC=8B=9D=20?= =?UTF-8?q?=EC=84=A0=ED=83=9D=20=EB=AC=B8=ED=95=AD=EC=97=90=20=EB=8C=80?= =?UTF-8?q?=ED=95=9C=20=EA=B0=80=EC=9D=B4=EB=93=9C=EB=9D=BC=EC=9D=B8=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ReviewWritingPage/form/components/QnABox/index.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/frontend/src/pages/ReviewWritingPage/form/components/QnABox/index.tsx b/frontend/src/pages/ReviewWritingPage/form/components/QnABox/index.tsx index 98a814e95..20b132037 100644 --- a/frontend/src/pages/ReviewWritingPage/form/components/QnABox/index.tsx +++ b/frontend/src/pages/ReviewWritingPage/form/components/QnABox/index.tsx @@ -18,8 +18,12 @@ const QnABox = ({ question }: QnABoxProps) => { const multipleLGuideline = (() => { const { optionGroup, questionType } = question; - if (question.required && questionType === 'TEXT') { - return `(최소 ${TEXT_ANSWER_LENGTH.min}자 ~ 최대 ${TEXT_ANSWER_LENGTH.max}자)`; + // NOTE: 객관식일 경우의 안내 문구 처리 + if (questionType === 'TEXT') { + const guideline = question.required + ? `(최소 ${TEXT_ANSWER_LENGTH.min}자 ~ 최대 ${TEXT_ANSWER_LENGTH.max}자)` + : `(최대 ${TEXT_ANSWER_LENGTH.max}자)`; + return guideline; } if (!optionGroup) return; From b658e5e7c6b8b4d430e0fc9695eaaadad05baf22 Mon Sep 17 00:00:00 2001 From: ImxYJL Date: Thu, 5 Sep 2024 10:04:02 +0900 Subject: [PATCH 5/5] =?UTF-8?q?refactor:=20=EC=A7=88=EB=AC=B8=EB=B3=84=20?= =?UTF-8?q?=EC=95=88=EB=82=B4=20=EB=AC=B8=EA=B5=AC=EB=A5=BC=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95=ED=95=98=EB=8A=94=20if=EB=AC=B8=20=EA=B0=9C=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ReviewWritingPage/form/components/QnABox/index.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/frontend/src/pages/ReviewWritingPage/form/components/QnABox/index.tsx b/frontend/src/pages/ReviewWritingPage/form/components/QnABox/index.tsx index 20b132037..d83f48a7e 100644 --- a/frontend/src/pages/ReviewWritingPage/form/components/QnABox/index.tsx +++ b/frontend/src/pages/ReviewWritingPage/form/components/QnABox/index.tsx @@ -16,17 +16,17 @@ const QnABox = ({ question }: QnABoxProps) => { * 객관식 문항의 최소,최대 개수에 대한 안내 문구 */ const multipleLGuideline = (() => { - const { optionGroup, questionType } = question; + const { optionGroup } = question; - // NOTE: 객관식일 경우의 안내 문구 처리 - if (questionType === 'TEXT') { + // NOTE: 주관식일 경우의 안내 문구 처리 + if (!optionGroup) { const guideline = question.required ? `(최소 ${TEXT_ANSWER_LENGTH.min}자 ~ 최대 ${TEXT_ANSWER_LENGTH.max}자)` : `(최대 ${TEXT_ANSWER_LENGTH.max}자)`; return guideline; } - if (!optionGroup) return; + // NOTE: 객관식일 경우의 안내 문구 처리 const { minCount, maxCount } = optionGroup; const isAllSelectAvailable = maxCount === optionGroup.options.length;