Skip to content

Commit

Permalink
feat: 답변 페이지 육각형 스탯 수정 (#84)
Browse files Browse the repository at this point in the history
  • Loading branch information
hayamaster authored Nov 28, 2023
1 parent 10c293b commit fc0f697
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 26 deletions.
6 changes: 5 additions & 1 deletion src/pages/ReviewReplyPage/components/Questions/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
Expand Down
21 changes: 1 addition & 20 deletions src/pages/ReviewReplyPage/hooks/useHandleQuestion.ts
Original file line number Diff line number Diff line change
@@ -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<number>(0)
const { setValue } = useFormContext<ReviewReplyStartType>()

const handleClickQuestion = (e: MouseEvent<HTMLLIElement>) => {
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)
}

Expand Down

0 comments on commit fc0f697

Please sign in to comment.