Fix: 멤버 추가 되게 api 재연결

This commit is contained in:
정현조 2024-10-04 14:26:39 +09:00
parent a2a54639b2
commit 82ed776c9d
3 changed files with 12 additions and 11 deletions

View File

@ -80,13 +80,14 @@ export async function addProjectMember(projectId: number, memberId: number, newM
export async function updateProjectMemberPrivilege(
projectId: number,
memberId: number,
privilegeData: ProjectMemberRequest
privilegeType: ProjectMemberResponse['privilegeType'] // 수정 가능한 권한 타입으로 변경
) {
return api
.put<ProjectMemberResponse>(`/projects/${projectId}/members`, privilegeData, {
params: { memberId },
})
.then(({ data }) => data);
const privilegeData = {
memberId,
privilegeType,
};
return api.put<ProjectMemberResponse>(`/projects/${projectId}/members`, privilegeData).then(({ data }) => data);
}
// 프로젝트 멤버 삭제

View File

@ -75,7 +75,7 @@ export default function ProjectMemberManage() {
updatePrivilege.mutate({
projectId: Number(projectId),
memberId,
privilegeData: { memberId, privilegeType: role },
privilegeType: role, // 수정: privilegeData 대신 privilegeType만 전달
});
} else {
addProjectMember.mutate({

View File

@ -1,6 +1,6 @@
import { useMutation, useQueryClient } from '@tanstack/react-query';
import { updateProjectMemberPrivilege } from '@/api/projectApi';
import { ProjectMemberRequest } from '@/types';
import { ProjectMemberResponse } from '@/types';
export default function useUpdateProjectMemberPrivilegeQuery() {
const queryClient = useQueryClient();
@ -9,12 +9,12 @@ export default function useUpdateProjectMemberPrivilegeQuery() {
mutationFn: ({
projectId,
memberId,
privilegeData,
privilegeType,
}: {
projectId: number;
memberId: number;
privilegeData: ProjectMemberRequest;
}) => updateProjectMemberPrivilege(projectId, memberId, privilegeData),
privilegeType: ProjectMemberResponse['privilegeType'];
}) => updateProjectMemberPrivilege(projectId, memberId, privilegeType),
onSuccess: (_, variables) => {
queryClient.invalidateQueries({ queryKey: ['projectMembers', variables.projectId] });
},