diff --git a/frontend/src/hooks/useAuthHooks.ts b/frontend/src/hooks/useAuthHooks.ts index 1d18390..99ec964 100644 --- a/frontend/src/hooks/useAuthHooks.ts +++ b/frontend/src/hooks/useAuthHooks.ts @@ -1,39 +1,39 @@ -import { useMutation, useQueryClient } from '@tanstack/react-query'; -import useAuthStore from '@/stores/useAuthStore'; -import { reissueToken } from '@/api/authApi'; -import { useEffect } from 'react'; +// import { useMutation, useQueryClient } from '@tanstack/react-query'; +// import useAuthStore from '@/stores/useAuthStore'; +// import { reissueToken } from '@/api/authApi'; +// import { useEffect } from 'react'; -import useProfileQuery from '@/queries/useProfileQuery'; +// import useProfileQuery from '@/queries/auth/useProfileQuery'; -export const useReissueToken = () => { - const queryClient = useQueryClient(); - const { setLoggedIn } = useAuthStore(); +// export const useReissueToken = () => { +// const queryClient = useQueryClient(); +// const { setLoggedIn } = useAuthStore(); - return useMutation({ - mutationFn: reissueToken, - onSuccess: (data) => { - setLoggedIn(true, data.accessToken); - queryClient.invalidateQueries({ queryKey: ['profile'] }); - }, - }); -}; +// return useMutation({ +// mutationFn: reissueToken, +// onSuccess: (data) => { +// setLoggedIn(true, data.accessToken); +// queryClient.invalidateQueries({ queryKey: ['profile'] }); +// }, +// }); +// }; -export const useProfile = () => { - const { setProfile } = useAuthStore(); - const query = useProfileQuery(); +// export const useProfile = () => { +// const { setProfile } = useAuthStore(); +// const query = useProfileQuery(); - // TODO: query.data가 변경될 때마다 setProfile을 호출하여 profile 업데이트, useEffect 제거 - useEffect(() => { - setProfile(query.data); - }, [query.data, setProfile]); +// // TODO: query.data가 변경될 때마다 setProfile을 호출하여 profile 업데이트, useEffect 제거 +// useEffect(() => { +// setProfile(query.data); +// }, [query.data, setProfile]); - return query; -}; +// return query; +// }; -export const useFetchProfile = () => { - const { setProfile } = useAuthStore(); - const query = useProfileQuery(); - if (query.data) { - setProfile(query.data); - } -}; +// export const useFetchProfile = () => { +// const { setProfile } = useAuthStore(); +// const query = useProfileQuery(); +// if (query.data) { +// setProfile(query.data); +// } +// }; diff --git a/frontend/src/hooks/useOAuthCallbackHooks.ts b/frontend/src/hooks/useOAuthCallbackHooks.ts index a7a6341..b25cca2 100644 --- a/frontend/src/hooks/useOAuthCallbackHooks.ts +++ b/frontend/src/hooks/useOAuthCallbackHooks.ts @@ -1,7 +1,7 @@ import useAuthStore from '@/stores/useAuthStore'; -import useProfileQuery from '@/queries/useProfileQuery'; +import useProfileQuery from '@/queries/auth/useProfileQuery'; -export function useHandleOAuthCallback() { +export default function useHandleOAuthCallback() { const queryParams = new URLSearchParams(window.location.search); const accessToken = queryParams.get('accessToken'); const setLoggedIn = useAuthStore((state) => state.setLoggedIn); diff --git a/frontend/src/hooks/useProjectHooks.ts b/frontend/src/hooks/useProjectHooks.ts index 29e3c58..e72819f 100644 --- a/frontend/src/hooks/useProjectHooks.ts +++ b/frontend/src/hooks/useProjectHooks.ts @@ -112,87 +112,87 @@ // }, // }); // }; -import { useMutation, useQueryClient } from '@tanstack/react-query'; -import { - createProject, - updateProject, - deleteProject, - addProjectMember, - updateProjectMemberPrivilege, - removeProjectMember, -} from '@/api/projectApi'; -import { ProjectResponse, ProjectRequest, ProjectMemberRequest, ProjectMemberResponse } from '@/types'; +// import { useMutation, useQueryClient } from '@tanstack/react-query'; +// import { +// createProject, +// updateProject, +// deleteProject, +// addProjectMember, +// updateProjectMemberPrivilege, +// removeProjectMember, +// } from '@/api/projectApi'; +// import { ProjectResponse, ProjectRequest, ProjectMemberRequest, ProjectMemberResponse } from '@/types'; -export const useCreateProject = () => { - const queryClient = useQueryClient(); +// export const useCreateProject = () => { +// const queryClient = useQueryClient(); - return useMutation({ - mutationFn: ({ workspaceId, memberId, data }) => createProject(workspaceId, memberId, data), - onSuccess: (_, variables) => { - queryClient.invalidateQueries({ queryKey: ['projects', variables.workspaceId] }); - }, - }); -}; +// return useMutation({ +// mutationFn: ({ workspaceId, memberId, data }) => createProject(workspaceId, memberId, data), +// onSuccess: (_, variables) => { +// queryClient.invalidateQueries({ queryKey: ['projects', variables.workspaceId] }); +// }, +// }); +// }; -export const useUpdateProject = () => { - const queryClient = useQueryClient(); +// export const useUpdateProject = () => { +// const queryClient = useQueryClient(); - return useMutation({ - mutationFn: ({ projectId, memberId, data }) => updateProject(projectId, memberId, data), - onSuccess: (data) => { - queryClient.invalidateQueries({ queryKey: ['project', data.id] }); - }, - }); -}; +// return useMutation({ +// mutationFn: ({ projectId, memberId, data }) => updateProject(projectId, memberId, data), +// onSuccess: (data) => { +// queryClient.invalidateQueries({ queryKey: ['project', data.id] }); +// }, +// }); +// }; -export const useDeleteProject = () => { - const queryClient = useQueryClient(); +// export const useDeleteProject = () => { +// const queryClient = useQueryClient(); - return useMutation({ - mutationFn: ({ projectId, memberId }) => deleteProject(projectId, memberId), - onSuccess: (_, variables) => { - queryClient.invalidateQueries({ queryKey: ['projects', variables.projectId] }); - }, - }); -}; +// return useMutation({ +// mutationFn: ({ projectId, memberId }) => deleteProject(projectId, memberId), +// onSuccess: (_, variables) => { +// queryClient.invalidateQueries({ queryKey: ['projects', variables.projectId] }); +// }, +// }); +// }; -export const useAddProjectMember = () => { - const queryClient = useQueryClient(); - return useMutation< - ProjectMemberResponse, - Error, - { projectId: number; memberId: number; newMember: ProjectMemberRequest } - >({ - mutationFn: ({ projectId, memberId, newMember }) => addProjectMember(projectId, memberId, newMember), - onSuccess: (_, { projectId }) => { - queryClient.invalidateQueries({ queryKey: ['projectMembers', projectId] }); - }, - }); -}; +// export const useAddProjectMember = () => { +// const queryClient = useQueryClient(); +// return useMutation< +// ProjectMemberResponse, +// Error, +// { projectId: number; memberId: number; newMember: ProjectMemberRequest } +// >({ +// mutationFn: ({ projectId, memberId, newMember }) => addProjectMember(projectId, memberId, newMember), +// onSuccess: (_, { projectId }) => { +// queryClient.invalidateQueries({ queryKey: ['projectMembers', projectId] }); +// }, +// }); +// }; -// 프로젝트 멤버 권한 수정 훅 -export const useUpdateProjectMemberPrivilege = () => { - const queryClient = useQueryClient(); - return useMutation< - ProjectMemberResponse, - Error, - { projectId: number; memberId: number; privilegeData: ProjectMemberRequest } - >({ - mutationFn: ({ projectId, memberId, privilegeData }) => - updateProjectMemberPrivilege(projectId, memberId, privilegeData), - onSuccess: (_, { projectId }) => { - queryClient.invalidateQueries({ queryKey: ['projectMembers', projectId] }); - }, - }); -}; +// // 프로젝트 멤버 권한 수정 훅 +// export const useUpdateProjectMemberPrivilege = () => { +// const queryClient = useQueryClient(); +// return useMutation< +// ProjectMemberResponse, +// Error, +// { projectId: number; memberId: number; privilegeData: ProjectMemberRequest } +// >({ +// mutationFn: ({ projectId, memberId, privilegeData }) => +// updateProjectMemberPrivilege(projectId, memberId, privilegeData), +// onSuccess: (_, { projectId }) => { +// queryClient.invalidateQueries({ queryKey: ['projectMembers', projectId] }); +// }, +// }); +// }; -// 프로젝트 멤버 삭제 훅 -export const useRemoveProjectMember = () => { - const queryClient = useQueryClient(); - return useMutation({ - mutationFn: ({ projectId, memberId, targetMemberId }) => removeProjectMember(projectId, memberId, targetMemberId), - onSuccess: (_, { projectId }) => { - queryClient.invalidateQueries({ queryKey: ['projectMembers', projectId] }); - }, - }); -}; +// // 프로젝트 멤버 삭제 훅 +// export const useRemoveProjectMember = () => { +// const queryClient = useQueryClient(); +// return useMutation({ +// mutationFn: ({ projectId, memberId, targetMemberId }) => removeProjectMember(projectId, memberId, targetMemberId), +// onSuccess: (_, { projectId }) => { +// queryClient.invalidateQueries({ queryKey: ['projectMembers', projectId] }); +// }, +// }); +// }; diff --git a/frontend/src/hooks/useReviewHooks.ts b/frontend/src/hooks/useReviewHooks.ts index 75f1512..90652a3 100644 --- a/frontend/src/hooks/useReviewHooks.ts +++ b/frontend/src/hooks/useReviewHooks.ts @@ -1,57 +1,57 @@ -import { useMutation, useQueryClient } from '@tanstack/react-query'; -import { createReview, updateReview, deleteReview, updateReviewStatus } from '@/api/reviewApi'; -import { ReviewRequest, ReviewResponse } from '@/types'; +// import { useMutation, useQueryClient } from '@tanstack/react-query'; +// import { createReview, updateReview, deleteReview, updateReviewStatus } from '@/api/reviewApi'; +// import { ReviewRequest, ReviewResponse } from '@/types'; -// 리뷰 생성 훅 -export const useCreateReview = () => { - const queryClient = useQueryClient(); - return useMutation({ - mutationFn: ({ projectId, memberId, reviewData }) => createReview(projectId, memberId, reviewData), - onSuccess: (_, { projectId, memberId }) => { - queryClient.invalidateQueries({ queryKey: ['reviewList', projectId, memberId] }); - }, - }); -}; +// // 리뷰 생성 훅 +// export const useCreateReview = () => { +// const queryClient = useQueryClient(); +// return useMutation({ +// mutationFn: ({ projectId, memberId, reviewData }) => createReview(projectId, memberId, reviewData), +// onSuccess: (_, { projectId, memberId }) => { +// queryClient.invalidateQueries({ queryKey: ['reviewList', projectId, memberId] }); +// }, +// }); +// }; -// 리뷰 수정 훅 -export const useUpdateReview = () => { - const queryClient = useQueryClient(); - return useMutation< - ReviewResponse, - Error, - { projectId: number; reviewId: number; memberId: number; reviewData: ReviewRequest } - >({ - mutationFn: ({ projectId, reviewId, memberId, reviewData }) => - updateReview(projectId, reviewId, memberId, reviewData), - onSuccess: (_, { projectId, reviewId }) => { - queryClient.invalidateQueries({ queryKey: ['reviewDetail', projectId, reviewId] }); - }, - }); -}; +// // 리뷰 수정 훅 +// export const useUpdateReview = () => { +// const queryClient = useQueryClient(); +// return useMutation< +// ReviewResponse, +// Error, +// { projectId: number; reviewId: number; memberId: number; reviewData: ReviewRequest } +// >({ +// mutationFn: ({ projectId, reviewId, memberId, reviewData }) => +// updateReview(projectId, reviewId, memberId, reviewData), +// onSuccess: (_, { projectId, reviewId }) => { +// queryClient.invalidateQueries({ queryKey: ['reviewDetail', projectId, reviewId] }); +// }, +// }); +// }; -// 리뷰 삭제 훅 -export const useDeleteReview = () => { - const queryClient = useQueryClient(); - return useMutation({ - mutationFn: ({ projectId, reviewId, memberId }) => deleteReview(projectId, reviewId, memberId), - onSuccess: (_, { projectId, reviewId }) => { - queryClient.invalidateQueries({ queryKey: ['reviewDetail', projectId, reviewId] }); - }, - }); -}; +// // 리뷰 삭제 훅 +// export const useDeleteReview = () => { +// const queryClient = useQueryClient(); +// return useMutation({ +// mutationFn: ({ projectId, reviewId, memberId }) => deleteReview(projectId, reviewId, memberId), +// onSuccess: (_, { projectId, reviewId }) => { +// queryClient.invalidateQueries({ queryKey: ['reviewDetail', projectId, reviewId] }); +// }, +// }); +// }; -// 리뷰 상태 변경 훅 -export const useUpdateReviewStatus = () => { - const queryClient = useQueryClient(); - return useMutation< - ReviewResponse, - Error, - { projectId: number; reviewId: number; memberId: number; reviewStatus: string } - >({ - mutationFn: ({ projectId, reviewId, memberId, reviewStatus }) => - updateReviewStatus(projectId, reviewId, memberId, reviewStatus), - onSuccess: (_, { projectId, reviewId }) => { - queryClient.invalidateQueries({ queryKey: ['reviewDetail', projectId, reviewId] }); - }, - }); -}; +// // 리뷰 상태 변경 훅 +// export const useUpdateReviewStatus = () => { +// const queryClient = useQueryClient(); +// return useMutation< +// ReviewResponse, +// Error, +// { projectId: number; reviewId: number; memberId: number; reviewStatus: string } +// >({ +// mutationFn: ({ projectId, reviewId, memberId, reviewStatus }) => +// updateReviewStatus(projectId, reviewId, memberId, reviewStatus), +// onSuccess: (_, { projectId, reviewId }) => { +// queryClient.invalidateQueries({ queryKey: ['reviewDetail', projectId, reviewId] }); +// }, +// }); +// }; diff --git a/frontend/src/hooks/useWorkspaceHooks.ts b/frontend/src/hooks/useWorkspaceHooks.ts index 992031c..aad486d 100644 --- a/frontend/src/hooks/useWorkspaceHooks.ts +++ b/frontend/src/hooks/useWorkspaceHooks.ts @@ -88,68 +88,68 @@ // }); // }; -import { useMutation, useQueryClient } from '@tanstack/react-query'; -import { - createWorkspace, - updateWorkspace, - deleteWorkspace, - addWorkspaceMember, - removeWorkspaceMember, -} from '@/api/workspaceApi'; -import { WorkspaceResponse, WorkspaceRequest } from '@/types'; +// import { useMutation, useQueryClient } from '@tanstack/react-query'; +// import { +// createWorkspace, +// updateWorkspace, +// deleteWorkspace, +// addWorkspaceMember, +// removeWorkspaceMember, +// } from '@/api/workspaceApi'; +// import { WorkspaceResponse, WorkspaceRequest } from '@/types'; -export const useCreateWorkspace = () => { - const queryClient = useQueryClient(); +// export const useCreateWorkspace = () => { +// const queryClient = useQueryClient(); - return useMutation({ - mutationFn: ({ memberId, data }) => createWorkspace(memberId, data), - onSuccess: () => { - queryClient.invalidateQueries({ queryKey: ['workspaceList'] }); - }, - }); -}; +// return useMutation({ +// mutationFn: ({ memberId, data }) => createWorkspace(memberId, data), +// onSuccess: () => { +// queryClient.invalidateQueries({ queryKey: ['workspaceList'] }); +// }, +// }); +// }; -export const useUpdateWorkspace = () => { - const queryClient = useQueryClient(); +// export const useUpdateWorkspace = () => { +// const queryClient = useQueryClient(); - return useMutation({ - mutationFn: ({ workspaceId, memberId, data }) => updateWorkspace(workspaceId, memberId, data), - onSuccess: (_, variables) => { - queryClient.invalidateQueries({ queryKey: ['workspace', variables.workspaceId] }); - }, - }); -}; +// return useMutation({ +// mutationFn: ({ workspaceId, memberId, data }) => updateWorkspace(workspaceId, memberId, data), +// onSuccess: (_, variables) => { +// queryClient.invalidateQueries({ queryKey: ['workspace', variables.workspaceId] }); +// }, +// }); +// }; -export const useDeleteWorkspace = () => { - const queryClient = useQueryClient(); +// export const useDeleteWorkspace = () => { +// const queryClient = useQueryClient(); - return useMutation({ - mutationFn: ({ workspaceId, memberId }) => deleteWorkspace(workspaceId, memberId), - onSuccess: (_, variables) => { - queryClient.invalidateQueries({ queryKey: ['workspace', variables.workspaceId] }); - }, - }); -}; +// return useMutation({ +// mutationFn: ({ workspaceId, memberId }) => deleteWorkspace(workspaceId, memberId), +// onSuccess: (_, variables) => { +// queryClient.invalidateQueries({ queryKey: ['workspace', variables.workspaceId] }); +// }, +// }); +// }; -export const useAddWorkspaceMember = () => { - const queryClient = useQueryClient(); +// export const useAddWorkspaceMember = () => { +// const queryClient = useQueryClient(); - return useMutation({ - mutationFn: ({ workspaceId, memberId, newMemberId }) => addWorkspaceMember(workspaceId, memberId, newMemberId), - onSuccess: (_, variables) => { - queryClient.invalidateQueries({ queryKey: ['workspace', variables.workspaceId] }); - }, - }); -}; +// return useMutation({ +// mutationFn: ({ workspaceId, memberId, newMemberId }) => addWorkspaceMember(workspaceId, memberId, newMemberId), +// onSuccess: (_, variables) => { +// queryClient.invalidateQueries({ queryKey: ['workspace', variables.workspaceId] }); +// }, +// }); +// }; -export const useRemoveWorkspaceMember = () => { - const queryClient = useQueryClient(); +// export const useRemoveWorkspaceMember = () => { +// const queryClient = useQueryClient(); - return useMutation({ - mutationFn: ({ workspaceId, memberId, targetMemberId }) => - removeWorkspaceMember(workspaceId, memberId, targetMemberId), - onSuccess: (_, variables) => { - queryClient.invalidateQueries({ queryKey: ['workspace', variables.workspaceId] }); - }, - }); -}; +// return useMutation({ +// mutationFn: ({ workspaceId, memberId, targetMemberId }) => +// removeWorkspaceMember(workspaceId, memberId, targetMemberId), +// onSuccess: (_, variables) => { +// queryClient.invalidateQueries({ queryKey: ['workspace', variables.workspaceId] }); +// }, +// }); +// }; diff --git a/frontend/src/queries/useProfileQuery.ts b/frontend/src/queries/auth/useProfileQuery.ts similarity index 100% rename from frontend/src/queries/useProfileQuery.ts rename to frontend/src/queries/auth/useProfileQuery.ts diff --git a/frontend/src/queries/auth/useReissueTokenQuery.ts b/frontend/src/queries/auth/useReissueTokenQuery.ts new file mode 100644 index 0000000..1cba196 --- /dev/null +++ b/frontend/src/queries/auth/useReissueTokenQuery.ts @@ -0,0 +1,16 @@ +import { useMutation, useQueryClient } from '@tanstack/react-query'; +import useAuthStore from '@/stores/useAuthStore'; +import { reissueToken } from '@/api/authApi'; + +export default function useReissueTokenQuery() { + const queryClient = useQueryClient(); + const { setLoggedIn } = useAuthStore(); + + return useMutation({ + mutationFn: reissueToken, + onSuccess: (data) => { + setLoggedIn(true, data.accessToken); + queryClient.invalidateQueries({ queryKey: ['profile'] }); + }, + }); +} diff --git a/frontend/src/queries/useFolderQuery.ts b/frontend/src/queries/folders/useFolderQuery.ts similarity index 69% rename from frontend/src/queries/useFolderQuery.ts rename to frontend/src/queries/folders/useFolderQuery.ts index 59dd2f9..5c38ad6 100644 --- a/frontend/src/queries/useFolderQuery.ts +++ b/frontend/src/queries/folders/useFolderQuery.ts @@ -1,9 +1,9 @@ -import { fetchFolder } from '@/api/folderApi'; +import { getFolder } from '@/api/folderApi'; import { useSuspenseQuery } from '@tanstack/react-query'; export default function useFolderQuery(projectId: number, folderId: number, memberId: number) { return useSuspenseQuery({ queryKey: ['folder', projectId, folderId, memberId], - queryFn: () => fetchFolder(projectId, folderId, memberId), + queryFn: () => getFolder(projectId, folderId, memberId), }); } diff --git a/frontend/src/queries/useFolderReviewListQuery.ts b/frontend/src/queries/folders/useFolderReviewListQuery.ts similarity index 73% rename from frontend/src/queries/useFolderReviewListQuery.ts rename to frontend/src/queries/folders/useFolderReviewListQuery.ts index 2dfcc32..02e8b8f 100644 --- a/frontend/src/queries/useFolderReviewListQuery.ts +++ b/frontend/src/queries/folders/useFolderReviewListQuery.ts @@ -1,7 +1,7 @@ import { getFolderReviewList } from '@/api/folderApi'; import { useSuspenseQuery } from '@tanstack/react-query'; -export function useFolderReviewListQuery(projectId: number, folderId: number, memberId: number) { +export default function useFolderReviewListQuery(projectId: number, folderId: number, memberId: number) { return useSuspenseQuery({ queryKey: ['folderReviewList', projectId, folderId, memberId], queryFn: () => getFolderReviewList(projectId, folderId, memberId), diff --git a/frontend/src/queries/projects/useAddProjectMemberQuery.ts b/frontend/src/queries/projects/useAddProjectMemberQuery.ts new file mode 100644 index 0000000..48e4124 --- /dev/null +++ b/frontend/src/queries/projects/useAddProjectMemberQuery.ts @@ -0,0 +1,22 @@ +import { useMutation, useQueryClient } from '@tanstack/react-query'; +import { addProjectMember } from '@/api/projectApi'; +import { ProjectMemberRequest } from '@/types'; + +export default function useAddProjectMemberQuery() { + const queryClient = useQueryClient(); + + return useMutation({ + mutationFn: ({ + projectId, + memberId, + newMember, + }: { + projectId: number; + memberId: number; + newMember: ProjectMemberRequest; + }) => addProjectMember(projectId, memberId, newMember), + onSuccess: (_, variables) => { + queryClient.invalidateQueries({ queryKey: ['projectMembers', variables.projectId] }); + }, + }); +} diff --git a/frontend/src/queries/projects/useCreateProjectQuery.ts b/frontend/src/queries/projects/useCreateProjectQuery.ts new file mode 100644 index 0000000..e8821c4 --- /dev/null +++ b/frontend/src/queries/projects/useCreateProjectQuery.ts @@ -0,0 +1,15 @@ +import { useMutation, useQueryClient } from '@tanstack/react-query'; +import { createProject } from '@/api/projectApi'; +import { ProjectRequest } from '@/types'; + +export default function useCreateProjectQuery() { + const queryClient = useQueryClient(); + + return useMutation({ + mutationFn: ({ workspaceId, memberId, data }: { workspaceId: number; memberId: number; data: ProjectRequest }) => + createProject(workspaceId, memberId, data), + onSuccess: (_, variables) => { + queryClient.invalidateQueries({ queryKey: ['projects', variables.workspaceId] }); + }, + }); +} diff --git a/frontend/src/queries/projects/useDeleteProjectQuery.ts b/frontend/src/queries/projects/useDeleteProjectQuery.ts new file mode 100644 index 0000000..9a1ff0a --- /dev/null +++ b/frontend/src/queries/projects/useDeleteProjectQuery.ts @@ -0,0 +1,14 @@ +import { useMutation, useQueryClient } from '@tanstack/react-query'; +import { deleteProject } from '@/api/projectApi'; + +export default function useDeleteProjectQuery() { + const queryClient = useQueryClient(); + + return useMutation({ + mutationFn: ({ projectId, memberId }: { projectId: number; memberId: number }) => + deleteProject(projectId, memberId), + onSuccess: (_, variables) => { + queryClient.invalidateQueries({ queryKey: ['projects', variables.projectId] }); + }, + }); +} diff --git a/frontend/src/queries/useProjectListQuery.ts b/frontend/src/queries/projects/useProjectListQuery.ts similarity index 100% rename from frontend/src/queries/useProjectListQuery.ts rename to frontend/src/queries/projects/useProjectListQuery.ts diff --git a/frontend/src/queries/useProjectMembersQuery.ts b/frontend/src/queries/projects/useProjectMembersQuery.ts similarity index 100% rename from frontend/src/queries/useProjectMembersQuery.ts rename to frontend/src/queries/projects/useProjectMembersQuery.ts diff --git a/frontend/src/queries/useProjectQuery.ts b/frontend/src/queries/projects/useProjectQuery.ts similarity index 100% rename from frontend/src/queries/useProjectQuery.ts rename to frontend/src/queries/projects/useProjectQuery.ts diff --git a/frontend/src/queries/projects/useRemoveProjectMemberQuery.ts b/frontend/src/queries/projects/useRemoveProjectMemberQuery.ts new file mode 100644 index 0000000..55e3918 --- /dev/null +++ b/frontend/src/queries/projects/useRemoveProjectMemberQuery.ts @@ -0,0 +1,21 @@ +import { useMutation, useQueryClient } from '@tanstack/react-query'; +import { removeProjectMember } from '@/api/projectApi'; + +export default function useRemoveProjectMemberQuery() { + const queryClient = useQueryClient(); + + return useMutation({ + mutationFn: ({ + projectId, + memberId, + targetMemberId, + }: { + projectId: number; + memberId: number; + targetMemberId: number; + }) => removeProjectMember(projectId, memberId, targetMemberId), + onSuccess: (_, variables) => { + queryClient.invalidateQueries({ queryKey: ['projectMembers', variables.projectId] }); + }, + }); +} diff --git a/frontend/src/queries/projects/useUpdateProjectMemberPrivilegeQuery.ts b/frontend/src/queries/projects/useUpdateProjectMemberPrivilegeQuery.ts new file mode 100644 index 0000000..4f60f1d --- /dev/null +++ b/frontend/src/queries/projects/useUpdateProjectMemberPrivilegeQuery.ts @@ -0,0 +1,22 @@ +import { useMutation, useQueryClient } from '@tanstack/react-query'; +import { updateProjectMemberPrivilege } from '@/api/projectApi'; +import { ProjectMemberRequest } from '@/types'; + +export default function useUpdateProjectMemberPrivilegeQuery() { + const queryClient = useQueryClient(); + + return useMutation({ + mutationFn: ({ + projectId, + memberId, + privilegeData, + }: { + projectId: number; + memberId: number; + privilegeData: ProjectMemberRequest; + }) => updateProjectMemberPrivilege(projectId, memberId, privilegeData), + onSuccess: (_, variables) => { + queryClient.invalidateQueries({ queryKey: ['projectMembers', variables.projectId] }); + }, + }); +} diff --git a/frontend/src/queries/projects/useUpdateProjectQuery.ts b/frontend/src/queries/projects/useUpdateProjectQuery.ts new file mode 100644 index 0000000..40fa953 --- /dev/null +++ b/frontend/src/queries/projects/useUpdateProjectQuery.ts @@ -0,0 +1,15 @@ +import { useMutation, useQueryClient } from '@tanstack/react-query'; +import { updateProject } from '@/api/projectApi'; +import { ProjectRequest } from '@/types'; + +export default function useUpdateProjectQuery() { + const queryClient = useQueryClient(); + + return useMutation({ + mutationFn: ({ projectId, memberId, data }: { projectId: number; memberId: number; data: ProjectRequest }) => + updateProject(projectId, memberId, data), + onSuccess: (_, variables) => { + queryClient.invalidateQueries({ queryKey: ['project', variables.projectId] }); + }, + }); +} diff --git a/frontend/src/queries/reviews/useCreateReviewQuery.ts b/frontend/src/queries/reviews/useCreateReviewQuery.ts new file mode 100644 index 0000000..00a1e0e --- /dev/null +++ b/frontend/src/queries/reviews/useCreateReviewQuery.ts @@ -0,0 +1,22 @@ +import { useMutation, useQueryClient } from '@tanstack/react-query'; +import { createReview } from '@/api/reviewApi'; +import { ReviewRequest } from '@/types'; + +export default function useCreateReviewQuery() { + const queryClient = useQueryClient(); + + return useMutation({ + mutationFn: ({ + projectId, + memberId, + reviewData, + }: { + projectId: number; + memberId: number; + reviewData: ReviewRequest; + }) => createReview(projectId, memberId, reviewData), + onSuccess: (_, variables) => { + queryClient.invalidateQueries({ queryKey: ['reviewList', variables.projectId, variables.memberId] }); + }, + }); +} diff --git a/frontend/src/queries/reviews/useDeleteReviewQuery.ts b/frontend/src/queries/reviews/useDeleteReviewQuery.ts new file mode 100644 index 0000000..255ba3a --- /dev/null +++ b/frontend/src/queries/reviews/useDeleteReviewQuery.ts @@ -0,0 +1,14 @@ +import { useMutation, useQueryClient } from '@tanstack/react-query'; +import { deleteReview } from '@/api/reviewApi'; + +export default function useDeleteReviewQuery() { + const queryClient = useQueryClient(); + + return useMutation({ + mutationFn: ({ projectId, reviewId, memberId }: { projectId: number; reviewId: number; memberId: number }) => + deleteReview(projectId, reviewId, memberId), + onSuccess: (_, variables) => { + queryClient.invalidateQueries({ queryKey: ['reviewDetail', variables.projectId, variables.reviewId] }); + }, + }); +} diff --git a/frontend/src/queries/useReviewByStatusQuery.ts b/frontend/src/queries/reviews/useReviewByStatusQuery.ts similarity index 100% rename from frontend/src/queries/useReviewByStatusQuery.ts rename to frontend/src/queries/reviews/useReviewByStatusQuery.ts diff --git a/frontend/src/queries/useReviewDetailQuery.ts b/frontend/src/queries/reviews/useReviewDetailQuery.ts similarity index 100% rename from frontend/src/queries/useReviewDetailQuery.ts rename to frontend/src/queries/reviews/useReviewDetailQuery.ts diff --git a/frontend/src/queries/reviews/useUpdateReviewQuery.ts b/frontend/src/queries/reviews/useUpdateReviewQuery.ts new file mode 100644 index 0000000..51f4aab --- /dev/null +++ b/frontend/src/queries/reviews/useUpdateReviewQuery.ts @@ -0,0 +1,24 @@ +import { useMutation, useQueryClient } from '@tanstack/react-query'; +import { updateReview } from '@/api/reviewApi'; +import { ReviewRequest } from '@/types'; + +export default function useUpdateReviewQuery() { + const queryClient = useQueryClient(); + + return useMutation({ + mutationFn: ({ + projectId, + reviewId, + memberId, + reviewData, + }: { + projectId: number; + reviewId: number; + memberId: number; + reviewData: ReviewRequest; + }) => updateReview(projectId, reviewId, memberId, reviewData), + onSuccess: (_, variables) => { + queryClient.invalidateQueries({ queryKey: ['reviewDetail', variables.projectId, variables.reviewId] }); + }, + }); +} diff --git a/frontend/src/queries/reviews/useUpdateReviewStatusQuery.ts b/frontend/src/queries/reviews/useUpdateReviewStatusQuery.ts new file mode 100644 index 0000000..48f5504 --- /dev/null +++ b/frontend/src/queries/reviews/useUpdateReviewStatusQuery.ts @@ -0,0 +1,23 @@ +import { useMutation, useQueryClient } from '@tanstack/react-query'; +import { updateReviewStatus } from '@/api/reviewApi'; + +export default function useUpdateReviewStatusQuery() { + const queryClient = useQueryClient(); + + return useMutation({ + mutationFn: ({ + projectId, + reviewId, + memberId, + reviewStatus, + }: { + projectId: number; + reviewId: number; + memberId: number; + reviewStatus: string; + }) => updateReviewStatus(projectId, reviewId, memberId, reviewStatus), + onSuccess: (_, variables) => { + queryClient.invalidateQueries({ queryKey: ['reviewDetail', variables.projectId, variables.reviewId] }); + }, + }); +} diff --git a/frontend/src/queries/workspaces/useAddWorkspaceMemberQuery.ts b/frontend/src/queries/workspaces/useAddWorkspaceMemberQuery.ts new file mode 100644 index 0000000..a1fcd58 --- /dev/null +++ b/frontend/src/queries/workspaces/useAddWorkspaceMemberQuery.ts @@ -0,0 +1,21 @@ +import { useMutation, useQueryClient } from '@tanstack/react-query'; +import { addWorkspaceMember } from '@/api/workspaceApi'; + +export default function useAddWorkspaceMemberQuery() { + const queryClient = useQueryClient(); + + return useMutation({ + mutationFn: ({ + workspaceId, + memberId, + newMemberId, + }: { + workspaceId: number; + memberId: number; + newMemberId: number; + }) => addWorkspaceMember(workspaceId, memberId, newMemberId), + onSuccess: (_, variables) => { + queryClient.invalidateQueries({ queryKey: ['workspace', variables.workspaceId] }); + }, + }); +} diff --git a/frontend/src/queries/workspaces/useCreateWorkspaceQuery.ts b/frontend/src/queries/workspaces/useCreateWorkspaceQuery.ts new file mode 100644 index 0000000..b05a37d --- /dev/null +++ b/frontend/src/queries/workspaces/useCreateWorkspaceQuery.ts @@ -0,0 +1,14 @@ +import { useMutation, useQueryClient } from '@tanstack/react-query'; +import { createWorkspace } from '@/api/workspaceApi'; +import { WorkspaceRequest } from '@/types'; + +export default function useCreateWorkspaceQuery() { + const queryClient = useQueryClient(); + + return useMutation({ + mutationFn: ({ memberId, data }: { memberId: number; data: WorkspaceRequest }) => createWorkspace(memberId, data), + onSuccess: () => { + queryClient.invalidateQueries({ queryKey: ['workspaceList'] }); + }, + }); +} diff --git a/frontend/src/queries/workspaces/useDeleteWorkspaceQuery.ts b/frontend/src/queries/workspaces/useDeleteWorkspaceQuery.ts new file mode 100644 index 0000000..242fb44 --- /dev/null +++ b/frontend/src/queries/workspaces/useDeleteWorkspaceQuery.ts @@ -0,0 +1,14 @@ +import { useMutation, useQueryClient } from '@tanstack/react-query'; +import { deleteWorkspace } from '@/api/workspaceApi'; + +export default function useDeleteWorkspaceQuery() { + const queryClient = useQueryClient(); + + return useMutation({ + mutationFn: ({ workspaceId, memberId }: { workspaceId: number; memberId: number }) => + deleteWorkspace(workspaceId, memberId), + onSuccess: (_, variables) => { + queryClient.invalidateQueries({ queryKey: ['workspace', variables.workspaceId] }); + }, + }); +} diff --git a/frontend/src/queries/workspaces/useRemoveWorkspaceMemberQuery.ts b/frontend/src/queries/workspaces/useRemoveWorkspaceMemberQuery.ts new file mode 100644 index 0000000..aa80ec0 --- /dev/null +++ b/frontend/src/queries/workspaces/useRemoveWorkspaceMemberQuery.ts @@ -0,0 +1,21 @@ +import { useMutation, useQueryClient } from '@tanstack/react-query'; +import { removeWorkspaceMember } from '@/api/workspaceApi'; + +export default function useRemoveWorkspaceMemberQuery() { + const queryClient = useQueryClient(); + + return useMutation({ + mutationFn: ({ + workspaceId, + memberId, + targetMemberId, + }: { + workspaceId: number; + memberId: number; + targetMemberId: number; + }) => removeWorkspaceMember(workspaceId, memberId, targetMemberId), + onSuccess: (_, variables) => { + queryClient.invalidateQueries({ queryKey: ['workspace', variables.workspaceId] }); + }, + }); +} diff --git a/frontend/src/queries/workspaces/useUpdateWorkspaceQuery.ts b/frontend/src/queries/workspaces/useUpdateWorkspaceQuery.ts new file mode 100644 index 0000000..e366274 --- /dev/null +++ b/frontend/src/queries/workspaces/useUpdateWorkspaceQuery.ts @@ -0,0 +1,15 @@ +import { useMutation, useQueryClient } from '@tanstack/react-query'; +import { updateWorkspace } from '@/api/workspaceApi'; +import { WorkspaceRequest } from '@/types'; + +export default function useUpdateWorkspaceQuery() { + const queryClient = useQueryClient(); + + return useMutation({ + mutationFn: ({ workspaceId, memberId, data }: { workspaceId: number; memberId: number; data: WorkspaceRequest }) => + updateWorkspace(workspaceId, memberId, data), + onSuccess: (_, variables) => { + queryClient.invalidateQueries({ queryKey: ['workspace', variables.workspaceId] }); + }, + }); +} diff --git a/frontend/src/queries/useWorkspaceListQuery.ts b/frontend/src/queries/workspaces/useWorkspaceListQuery.ts similarity index 100% rename from frontend/src/queries/useWorkspaceListQuery.ts rename to frontend/src/queries/workspaces/useWorkspaceListQuery.ts diff --git a/frontend/src/queries/useWorkspaceQuery.ts b/frontend/src/queries/workspaces/useWorkspaceQuery.ts similarity index 100% rename from frontend/src/queries/useWorkspaceQuery.ts rename to frontend/src/queries/workspaces/useWorkspaceQuery.ts