diff --git a/src/apis/hooks/useSaveFinalResult.ts b/src/apis/hooks/useSaveFinalResult.ts index 98a05d38..b128e227 100644 --- a/src/apis/hooks/useSaveFinalResult.ts +++ b/src/apis/hooks/useSaveFinalResult.ts @@ -16,7 +16,7 @@ const useSaveFinalResult = (finalResult: T) => { return useMutation({ mutationFn: saveFinalResult, - onMutate: async () => { + onMutate: () => { const reviewId = finalResult.reviewId const userId = finalResult.userId diff --git a/src/apis/hooks/useSendReview.ts b/src/apis/hooks/useSendReview.ts index 72936643..5e55397d 100644 --- a/src/apis/hooks/useSendReview.ts +++ b/src/apis/hooks/useSendReview.ts @@ -1,4 +1,4 @@ -import { useMutation } from '@tanstack/react-query' +import { useMutation, useQueryClient } from '@tanstack/react-query' import apiClient from '@/apis/apiClient' interface Response { @@ -8,13 +8,25 @@ interface Response { } //NOTE - 대상자별 조합된 리뷰 결과를 저장 -const useSendReview = () => { - const sendReview = async ({ reviewId }: { reviewId: string }) => { +const useSendReview = ({ reviewId }: { reviewId: string }) => { + const queryClient = useQueryClient() + + const prevSendResultData = queryClient.getQueryData<{ + success: boolean + data: number[] + }>([`/final-results/${reviewId}/status`]) + + const sendReview = async () => { return await apiClient.post(`/final-results/${reviewId}`) } return useMutation({ mutationFn: sendReview, + onSuccess: () => { + queryClient.setQueryData([`/final-results/${reviewId}/status`], { + ...prevSendResultData, + }) + }, }) } export default useSendReview diff --git a/src/pages/CreatedReviewManagePage/components/AnswerGroup/index.tsx b/src/pages/CreatedReviewManagePage/components/AnswerGroup/index.tsx index db3cdffe..5493b3a9 100644 --- a/src/pages/CreatedReviewManagePage/components/AnswerGroup/index.tsx +++ b/src/pages/CreatedReviewManagePage/components/AnswerGroup/index.tsx @@ -106,7 +106,7 @@ const renderResponseByQuestion = (
diff --git a/src/pages/CreatedReviewManagePage/components/ReceiverTabReviewDatail/index.tsx b/src/pages/CreatedReviewManagePage/components/ReceiverTabReviewDatail/index.tsx index a25d0112..321c106a 100644 --- a/src/pages/CreatedReviewManagePage/components/ReceiverTabReviewDatail/index.tsx +++ b/src/pages/CreatedReviewManagePage/components/ReceiverTabReviewDatail/index.tsx @@ -26,7 +26,7 @@ const ReceiverReviewDetail = ({ //NOTE - 하나라도 응답 실패했을 떄 처리 const { addToast } = useToast() - const hasAnswered = useRef(false) + const hasAnswered = useRef([]) const { data: getReviewQuestion } = useGetReviewForCreator({ id: Number(reviewId), }) @@ -88,12 +88,15 @@ const ReceiverReviewDetail = ({ const { mutate: updateFinalReviewAnswer } = useUpdateFinalReviewAnswer() useEffect(() => { + if (getReviewQuestion.status === 'END') { + return + } if ( !ResponserList?.includes(Number(receiverId)) && - hasAnswered.current.valueOf() === false + !hasAnswered.current.includes(Number(receiverId)) ) { saveFinalResult() - hasAnswered.current = true + hasAnswered.current = [...hasAnswered.current, Number(receiverId)] } }, [receiverId]) @@ -126,9 +129,12 @@ const ReceiverReviewDetail = ({ return ( <> -
+
-
diff --git a/src/pages/CreatedReviewManagePage/components/ResponserTabReviewDetail/index.tsx b/src/pages/CreatedReviewManagePage/components/ResponserTabReviewDetail/index.tsx index 5faee63f..ff99c370 100644 --- a/src/pages/CreatedReviewManagePage/components/ResponserTabReviewDetail/index.tsx +++ b/src/pages/CreatedReviewManagePage/components/ResponserTabReviewDetail/index.tsx @@ -42,11 +42,11 @@ const ReceiverReviewDetail = ({ return ( <> -
+
diff --git a/src/pages/CreatedReviewManagePage/index.tsx b/src/pages/CreatedReviewManagePage/index.tsx index 63bc0b82..f3bed307 100644 --- a/src/pages/CreatedReviewManagePage/index.tsx +++ b/src/pages/CreatedReviewManagePage/index.tsx @@ -30,9 +30,10 @@ const CreatedReviewManagePage = () => { ) //NOTE - 리뷰의 질문을 가져온다! - const { data: getReviewQuestion } = useGetReviewForCreator({ - id: Number(reviewId), - }) + const { data: getReviewQuestion, refetch: getUpdatdReviewQuestion } = + useGetReviewForCreator({ + id: Number(reviewId), + }) const { data: checkAllReceiverReceived } = useCheckAllReceiverReceived({ id: reviewId, @@ -40,7 +41,7 @@ const CreatedReviewManagePage = () => { const { mutate: closeReview } = useCloseSurvey({ id: reviewId }) - const { mutate: sendReview } = useSendReview() + const { mutate: sendReview } = useSendReview({ reviewId }) const handleClickSurveyClose = () => { closeReview(undefined, { onSuccess: () => { @@ -70,23 +71,21 @@ const CreatedReviewManagePage = () => { return } - sendReview( - { reviewId }, - { - onSuccess: ({ data }) => { - if (data.errorCode && data.message) { - addToast({ message: data.message, type: 'error' }) + sendReview(undefined, { + onSuccess: ({ data }) => { + if (data.errorCode && data.message) { + addToast({ message: data.message, type: 'error' }) - return - } + return + } - addToast({ - message: '리뷰가 성공적으로 전송되었어요!', - type: 'success', - }) - }, + addToast({ + message: '리뷰가 성공적으로 전송되었어요!', + type: 'success', + }) + getUpdatdReviewQuestion() }, - ) + }) } const REVIEW_MANAGE_TAB_CONTENT = { @@ -111,7 +110,13 @@ const CreatedReviewManagePage = () => { > receiver.receiverId, + ) + : checkAllReceiverReceived?.data + } /> ), @@ -132,7 +137,7 @@ const CreatedReviewManagePage = () => { {getReviewQuestion?.description}
{REVIEW_MANAGE_TAB_CONTENT[activeTab]}
- {getReviewQuestion?.status === 'PROCEEDING' ? ( + {getReviewQuestion?.status === 'PROCEEDING' && ( - ) : ( + )} + + {getReviewQuestion.status === 'DEADLINE' && ( )} + + {getReviewQuestion.status === 'END' && ( + + )}
) diff --git a/src/pages/LoginPage/components/LoginGroup.tsx b/src/pages/LoginPage/components/LoginGroup.tsx index 76740091..d3224490 100644 --- a/src/pages/LoginPage/components/LoginGroup.tsx +++ b/src/pages/LoginPage/components/LoginGroup.tsx @@ -8,7 +8,11 @@ interface LoginGroupProps { } const LoginGroup = ({ handleLogin }: LoginGroupProps) => { const navigate = useNavigate() - const { register, handleSubmit } = useForm() + const { register, handleSubmit } = useForm({ + mode: 'onChange', + }) + + const { onChange: onChangePassword } = register('password') return (
{
- +
diff --git a/src/pages/LoginPage/index.tsx b/src/pages/LoginPage/index.tsx index 8562c2e8..2461f31c 100644 --- a/src/pages/LoginPage/index.tsx +++ b/src/pages/LoginPage/index.tsx @@ -1,3 +1,4 @@ +import { AxiosError } from 'axios' import { useNavigate } from 'react-router-dom' import { Header } from '@/components' import { useLogin, useUser } from '@/apis/hooks' @@ -25,7 +26,9 @@ const LoginPage = () => { navigate('/') }, onError(data) { - addToast({ message: data.message, type: 'error' }) + if (data instanceof AxiosError) { + addToast({ message: data.response?.data.message, type: 'error' }) + } }, }, )