Skip to content

Commit

Permalink
feat: 수정 시 처음에 모든 수신자들을 답변 완료처리로 변경 (#110)
Browse files Browse the repository at this point in the history
  • Loading branch information
hayamaster authored Dec 4, 2023
1 parent dc8f0c4 commit b6ae55d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const ReviewReply = ({ reviewData, handleSubmit }: ReviewReplyProps) => {
})

const { individualReplyCompletes, allReplyComplete, checkReplyComplete } =
useReplyComplete({ receivers, selectedReceiverIndex })
useReplyComplete({ receivers, selectedReceiverIndex, editPage: true })

const questionArray = questions.map((question, index) => (
<Questions
Expand Down
12 changes: 9 additions & 3 deletions src/pages/ReviewReplyPage/hooks/useReplyComplete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,18 @@ import { ReviewReplyEditType } from '../types'
interface UseReplyCompleteProps {
receivers: Receiver[]
selectedReceiverIndex: number
editPage?: boolean
}

const useReplyComplete = ({
receivers,
selectedReceiverIndex,
editPage = false,
}: UseReplyCompleteProps) => {
const [individualReplyCompletes, setIndividualReplyCompletes] = useState<
boolean[]
>(Array(receivers.length).fill(false))
const [allReplyComplete, setAllReplyComplete] = useState<boolean>(false)
>(Array(receivers.length).fill(editPage))
const [allReplyComplete, setAllReplyComplete] = useState<boolean>(editPage)
const { getValues } = useFormContext<ReviewReplyEditType>()

const checkReplyComplete = useCallback(() => {
Expand All @@ -34,7 +36,11 @@ const useReplyComplete = ({
setAllReplyComplete(individualReplyCompletes.every((value) => value))
}, [individualReplyCompletes])

return { individualReplyCompletes, allReplyComplete, checkReplyComplete }
return {
individualReplyCompletes,
allReplyComplete,
checkReplyComplete,
}
}

export default useReplyComplete

0 comments on commit b6ae55d

Please sign in to comment.