Refactor: 이미지 호출 함수 수정
This commit is contained in:
parent
92a368f172
commit
1bbf0bc77e
@ -2,10 +2,8 @@ import api from '@/api/axiosConfig';
|
||||
import { ImageMoveRequest, ImageStatusChangeRequest, ImagePresignedUrlResponse } from '@/types';
|
||||
import axios from 'axios';
|
||||
|
||||
export async function getImage(imageId: number, memberId: number) {
|
||||
return api.get(`/images/${imageId}`, {
|
||||
params: { memberId },
|
||||
});
|
||||
export async function getImage(projectId: number, folderId: number, imageId: number) {
|
||||
return api.get(`/api/projects/${projectId}/folders/${folderId}/images/${imageId}`);
|
||||
}
|
||||
|
||||
export async function moveImage(projectId: number, folderId: number, imageId: number, moveRequest: ImageMoveRequest) {
|
||||
|
10
frontend/src/hooks/useImage.ts
Normal file
10
frontend/src/hooks/useImage.ts
Normal file
@ -0,0 +1,10 @@
|
||||
import { getImage } from '@/api/imageApi';
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
|
||||
export default function useImage(projectId: number, folderId: number, imageId: number) {
|
||||
return useQuery({
|
||||
queryKey: ['image', projectId, folderId, imageId],
|
||||
queryFn: () => getImage(projectId, folderId, imageId),
|
||||
enabled: Boolean(projectId && folderId && imageId),
|
||||
});
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
import { getImage } from '@/api/imageApi';
|
||||
import { useSuspenseQuery } from '@tanstack/react-query';
|
||||
|
||||
export default function useImageQuery(imageId: number, memberId: number) {
|
||||
export default function useImageQuery(projectId: number, folderId: number, imageId: number) {
|
||||
return useSuspenseQuery({
|
||||
queryKey: ['image', imageId, memberId],
|
||||
queryFn: () => getImage(imageId, memberId),
|
||||
queryKey: ['image', projectId, folderId, imageId],
|
||||
queryFn: () => getImage(projectId, folderId, imageId),
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user