diff --git a/packages/web-domains/src/about-me/common/apis/mutates/useUpdateQuestionsActive.ts b/packages/web-domains/src/about-me/common/apis/mutates/useUpdateQuestionsActive.ts index 4b2ab392..428cc432 100644 --- a/packages/web-domains/src/about-me/common/apis/mutates/useUpdateQuestionsActive.ts +++ b/packages/web-domains/src/about-me/common/apis/mutates/useUpdateQuestionsActive.ts @@ -16,16 +16,21 @@ interface MutationProps { export const useUpdateQuestionsActive = ({ options }: MutationProps = {}) => { const queryClient = useQueryClient(); + const mutationFn = ({ meetingId, activeMeetingQuestionIds }: Request) => { + const params = + activeMeetingQuestionIds.length > 0 + ? `?${activeMeetingQuestionIds.map((id) => `activeMeetingQuestionIds=${id}`).join('&')}` + : ''; + + return Http.PATCH(`/v1/meetings/${meetingId}/questions/active${params}`); + }; + return useMutation({ - mutationFn: ({ meetingId, activeMeetingQuestionIds }: Request) => { - // NOTE: PATCH지만, params로 넘겨줘야 해서 전처리 - const params = activeMeetingQuestionIds.map((id) => `activeMeetingQuestionIds=${id}`).join('&'); - return Http.PATCH(`/v1/meetings/${meetingId}/questions/active?${params}`); - }, + mutationFn, onSuccess: (data, variable, context) => { queryClient.invalidateQueries({ queryKey: [ANSWERS_ME_QUERY_KEY, variable.meetingId] }); - options?.onSuccess?.(data, variable, context); }, + ...options, }); }; diff --git a/packages/web-domains/src/about-me/common/apis/schema/MyMeetingAnswerListReponse.ts b/packages/web-domains/src/about-me/common/apis/schema/MyMeetingAnswerListReponse.ts index a4c3039a..e81abc23 100644 --- a/packages/web-domains/src/about-me/common/apis/schema/MyMeetingAnswerListReponse.ts +++ b/packages/web-domains/src/about-me/common/apis/schema/MyMeetingAnswerListReponse.ts @@ -3,6 +3,7 @@ export interface MyMeetingAnswerListResponse { } interface Content { + meetingQuestionId: number; idx: number; title: string; content: Array; diff --git a/packages/web-domains/src/about-me/features/containers/AnsweredQuestionsContainer.tsx b/packages/web-domains/src/about-me/features/containers/AnsweredQuestionsContainer.tsx index 67aa6a9e..4f02405e 100644 --- a/packages/web-domains/src/about-me/features/containers/AnsweredQuestionsContainer.tsx +++ b/packages/web-domains/src/about-me/features/containers/AnsweredQuestionsContainer.tsx @@ -39,11 +39,11 @@ export const AnsweredQuestionsContainer = forwardRef((_, ref) => { } const handleModify = () => { - const checkedIdx = checkboxRefs.current + const checkedIds = checkboxRefs.current .filter((checkbox) => checkbox?.checked) .map((checkbox) => Number(checkbox?.id)); - mutate({ meetingId, activeMeetingQuestionIds: checkedIdx }); + mutate({ meetingId, activeMeetingQuestionIds: checkedIds }); }; // NOTE: ScreenContainer에서 호출하기 위해 ref에 추가 @@ -64,7 +64,7 @@ export const AnsweredQuestionsContainer = forwardRef((_, ref) => {
{ checkboxRefs.current[index] = el; }}