From fc0f697cbc4f59ccae0f6abcf58c9160b3dc0dcd Mon Sep 17 00:00:00 2001 From: JUHA KIM <88622675+hayamaster@users.noreply.github.com> Date: Tue, 28 Nov 2023 17:56:40 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EB=8B=B5=EB=B3=80=20=ED=8E=98=EC=9D=B4?= =?UTF-8?q?=EC=A7=80=20=EC=9C=A1=EA=B0=81=ED=98=95=20=EC=8A=A4=ED=83=AF=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20(#84)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/Questions/index.tsx | 6 +++++- .../ReplyCategory/ReplyHexa/index.tsx | 9 ++++---- .../hooks/useHandleQuestion.ts | 21 +------------------ 3 files changed, 10 insertions(+), 26 deletions(-) diff --git a/src/pages/ReviewReplyPage/components/Questions/index.tsx b/src/pages/ReviewReplyPage/components/Questions/index.tsx index c063abd4..aacc08db 100644 --- a/src/pages/ReviewReplyPage/components/Questions/index.tsx +++ b/src/pages/ReviewReplyPage/components/Questions/index.tsx @@ -35,7 +35,11 @@ const Questions = ({ question, index, receiverIndex }: QuestionsProps) => { value: string | number | number[] }) => { if (!question.isRequired) { - setValue(replyCompletePath, true) + if (type === 'HEXASTAT' && value !== 0 && value !== 6) { + setValue(replyCompletePath, false) + } else { + setValue(replyCompletePath, true) + } return } diff --git a/src/pages/ReviewReplyPage/components/ReplyCategory/ReplyHexa/index.tsx b/src/pages/ReviewReplyPage/components/ReplyCategory/ReplyHexa/index.tsx index ca6574f3..ad1638d8 100644 --- a/src/pages/ReviewReplyPage/components/ReplyCategory/ReplyHexa/index.tsx +++ b/src/pages/ReviewReplyPage/components/ReplyCategory/ReplyHexa/index.tsx @@ -30,17 +30,16 @@ const ReplyHexa = ({ useEffect(() => { let count = 0 - while (count < 6) { + for (let i = 0; i < 6; i++) { if ( getValues( `replyTargets.${receiverIndex}.replies.${ - questionIndex + count + questionIndex + i }.answerHexa`, - ) === 0 + ) !== 0 ) { - break + count++ } - count++ } handleCheckReply({ value: count }) diff --git a/src/pages/ReviewReplyPage/hooks/useHandleQuestion.ts b/src/pages/ReviewReplyPage/hooks/useHandleQuestion.ts index c5e42386..fe13d925 100644 --- a/src/pages/ReviewReplyPage/hooks/useHandleQuestion.ts +++ b/src/pages/ReviewReplyPage/hooks/useHandleQuestion.ts @@ -1,37 +1,18 @@ import { useState, MouseEvent } from 'react' -import { useFormContext } from 'react-hook-form' -import { useLocation } from 'react-router-dom' import { Question } from '@/types' -import { ReviewReplyStartType } from '../types' interface UseHandleQuestionProps { questions: Question[] selectedReceiverIndex: number } -const useHandleQuestion = ({ - questions, - selectedReceiverIndex, -}: UseHandleQuestionProps) => { - const { state } = useLocation() +const useHandleQuestion = ({ questions }: UseHandleQuestionProps) => { const [selectedQuestionIndex, setSelectedQuestionIndex] = useState(0) - const { setValue } = useFormContext() const handleClickQuestion = (e: MouseEvent) => { const selectedTarget = questions.findIndex( (question) => question.id === e.currentTarget.value, ) - - if ( - state.status === 'PROCEEDING' && - !questions[selectedTarget].isRequired - ) { - setValue( - `replyComplete.${selectedReceiverIndex}.complete.${selectedTarget}`, - true, - ) - } - setSelectedQuestionIndex(selectedTarget) }