Feat: 이미지, 폴더 관련 쿼리 추가
This commit is contained in:
parent
38f7add1b4
commit
3349cbf9ef
23
frontend/src/queries/folders/useCreateFolderQuery.ts
Normal file
23
frontend/src/queries/folders/useCreateFolderQuery.ts
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
||||||
|
import { createFolder } from '@/api/folderApi';
|
||||||
|
import { FolderRequest } from '@/types';
|
||||||
|
|
||||||
|
interface CreateFolderMutationVariables {
|
||||||
|
projectId: number;
|
||||||
|
memberId: number;
|
||||||
|
folderData: FolderRequest;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function useCreateFolderQuery() {
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
|
return useMutation({
|
||||||
|
mutationFn: ({ projectId, memberId, folderData }: CreateFolderMutationVariables) =>
|
||||||
|
createFolder(projectId, memberId, folderData),
|
||||||
|
onSuccess: (_, variables) => {
|
||||||
|
queryClient.invalidateQueries({
|
||||||
|
queryKey: ['folderList', variables.projectId, variables.memberId],
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
22
frontend/src/queries/folders/useDeleteFolderQuery.ts
Normal file
22
frontend/src/queries/folders/useDeleteFolderQuery.ts
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
||||||
|
import { deleteFolder } from '@/api/folderApi';
|
||||||
|
|
||||||
|
interface DeleteFolderMutationVariables {
|
||||||
|
projectId: number;
|
||||||
|
folderId: number;
|
||||||
|
memberId: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function useDeleteFolderQuery() {
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
|
return useMutation({
|
||||||
|
mutationFn: ({ projectId, folderId, memberId }: DeleteFolderMutationVariables) =>
|
||||||
|
deleteFolder(projectId, folderId, memberId),
|
||||||
|
onSuccess: (_, variables) => {
|
||||||
|
queryClient.invalidateQueries({
|
||||||
|
queryKey: ['folderList', variables.projectId, variables.folderId],
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
24
frontend/src/queries/folders/useUpdateFolderQuery.ts
Normal file
24
frontend/src/queries/folders/useUpdateFolderQuery.ts
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
||||||
|
import { updateFolder } from '@/api/folderApi';
|
||||||
|
import { FolderRequest } from '@/types';
|
||||||
|
|
||||||
|
interface UpdateFolderMutationVariables {
|
||||||
|
projectId: number;
|
||||||
|
folderId: number;
|
||||||
|
memberId: number;
|
||||||
|
folderData: FolderRequest;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function useUpdateFolderQuery() {
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
|
return useMutation({
|
||||||
|
mutationFn: ({ projectId, folderId, memberId, folderData }: UpdateFolderMutationVariables) =>
|
||||||
|
updateFolder(projectId, folderId, memberId, folderData),
|
||||||
|
onSuccess: (_, variables) => {
|
||||||
|
queryClient.invalidateQueries({
|
||||||
|
queryKey: ['folderList', variables.projectId, variables.folderId],
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
@ -1,18 +0,0 @@
|
|||||||
import { useMutation } from '@tanstack/react-query';
|
|
||||||
import { changeImageStatus } from '@/api/imageApi';
|
|
||||||
import { ImageStatusChangeRequest } from '@/types';
|
|
||||||
|
|
||||||
export default function useChangeImageStatusQuery(onSuccess?: () => void) {
|
|
||||||
return useMutation({
|
|
||||||
mutationFn: ({
|
|
||||||
imageId,
|
|
||||||
memberId,
|
|
||||||
statusChangeRequest,
|
|
||||||
}: {
|
|
||||||
imageId: number;
|
|
||||||
memberId: number;
|
|
||||||
statusChangeRequest: ImageStatusChangeRequest;
|
|
||||||
}) => changeImageStatus(imageId, memberId, statusChangeRequest),
|
|
||||||
onSuccess,
|
|
||||||
});
|
|
||||||
}
|
|
18
frontend/src/queries/images/useDeleteImageQuery.ts
Normal file
18
frontend/src/queries/images/useDeleteImageQuery.ts
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
||||||
|
import { deleteImage } from '@/api/imageApi';
|
||||||
|
|
||||||
|
interface DeleteImageMutationVariables {
|
||||||
|
imageId: number;
|
||||||
|
memberId: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function useDeleteImageQuery() {
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
|
return useMutation({
|
||||||
|
mutationFn: ({ imageId, memberId }: DeleteImageMutationVariables) => deleteImage(imageId, memberId),
|
||||||
|
onSuccess: (_, variables) => {
|
||||||
|
queryClient.invalidateQueries({ queryKey: ['image', variables.imageId] });
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
9
frontend/src/queries/images/useImageQuery.ts
Normal file
9
frontend/src/queries/images/useImageQuery.ts
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import { getImage } from '@/api/imageApi';
|
||||||
|
import { useSuspenseQuery } from '@tanstack/react-query';
|
||||||
|
|
||||||
|
export default function useImageQuery(imageId: number, memberId: number) {
|
||||||
|
return useSuspenseQuery({
|
||||||
|
queryKey: ['image', imageId, memberId],
|
||||||
|
queryFn: () => getImage(imageId, memberId),
|
||||||
|
});
|
||||||
|
}
|
21
frontend/src/queries/images/useMoveImageQuery.ts
Normal file
21
frontend/src/queries/images/useMoveImageQuery.ts
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
||||||
|
import { moveImage } from '@/api/imageApi';
|
||||||
|
import { ImageMoveRequest } from '@/types';
|
||||||
|
|
||||||
|
interface MoveImageMutationVariables {
|
||||||
|
imageId: number;
|
||||||
|
memberId: number;
|
||||||
|
moveRequest: ImageMoveRequest;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function useMoveImageQuery() {
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
|
return useMutation({
|
||||||
|
mutationFn: ({ imageId, memberId, moveRequest }: MoveImageMutationVariables) =>
|
||||||
|
moveImage(imageId, memberId, moveRequest),
|
||||||
|
onSuccess: (_, variables) => {
|
||||||
|
queryClient.invalidateQueries({ queryKey: ['image', variables.imageId] });
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user