Skip to content

Commit

Permalink
fix: idx -> id
Browse files Browse the repository at this point in the history
  • Loading branch information
Doeunnkimm committed Aug 24, 2024
1 parent 7f9f874 commit ec007ea
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export interface MyMeetingAnswerListResponse {
}

interface Content {
meetingQuestionId: number;
idx: number;
title: string;
content: Array<string>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ export const AnsweredQuestionsContainer = forwardRef<Ref>((_, 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에 추가
Expand All @@ -64,7 +64,7 @@ export const AnsweredQuestionsContainer = forwardRef<Ref>((_, ref) => {
<div css={checkboxAndTriggerCss}>
<If condition={isModifyPage}>
<Checkbox
id={`${answer.idx}`}
id={`${answer.meetingQuestionId}`}
ref={(el) => {
checkboxRefs.current[index] = el;
}}
Expand Down

0 comments on commit ec007ea

Please sign in to comment.