Feat: 로그아웃 쿼리 추가
This commit is contained in:
parent
8009108119
commit
cf97dc4d20
16
frontend/src/queries/auth/useLogoutQuery.ts
Normal file
16
frontend/src/queries/auth/useLogoutQuery.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
||||
import useAuthStore from '@/stores/useAuthStore';
|
||||
import { logout } from '@/api/authApi';
|
||||
|
||||
export default function useLogoutQuery() {
|
||||
const queryClient = useQueryClient();
|
||||
const { clearAuth } = useAuthStore();
|
||||
|
||||
return useMutation({
|
||||
mutationFn: logout,
|
||||
onSuccess: () => {
|
||||
clearAuth();
|
||||
queryClient.invalidateQueries({ queryKey: ['profile'] });
|
||||
},
|
||||
});
|
||||
}
|
@ -1,13 +1,22 @@
|
||||
import { useSuspenseInfiniteQuery } from '@tanstack/react-query';
|
||||
import { getReviewByStatus } from '@/api/reviewApi';
|
||||
import { useSuspenseQuery } from '@tanstack/react-query';
|
||||
import { ReviewResponse } from '@/types';
|
||||
|
||||
export default function useReviewByStatusQuery(
|
||||
projectId: number,
|
||||
memberId: number,
|
||||
reviewStatus: 'REQUESTED' | 'APPROVED' | 'REJECTED' | undefined
|
||||
) {
|
||||
return useSuspenseQuery({
|
||||
return useSuspenseInfiniteQuery<ReviewResponse[]>({
|
||||
queryKey: ['reviewByStatus', projectId, reviewStatus],
|
||||
queryFn: () => getReviewByStatus(projectId, memberId, reviewStatus),
|
||||
queryFn: ({ pageParam = undefined }) => {
|
||||
return getReviewByStatus(projectId, memberId, reviewStatus, pageParam as number | undefined);
|
||||
},
|
||||
getNextPageParam: (lastPage) => {
|
||||
if (lastPage.length === 0) return undefined;
|
||||
const lastReview = lastPage[lastPage.length - 1];
|
||||
return lastReview.reviewId;
|
||||
},
|
||||
initialPageParam: undefined,
|
||||
});
|
||||
}
|
||||
|
@ -1,15 +1,24 @@
|
||||
import { useSuspenseInfiniteQuery } from '@tanstack/react-query';
|
||||
import { getWorkspaceReviews } from '@/api/workspaceApi';
|
||||
import { useSuspenseQuery } from '@tanstack/react-query';
|
||||
import { ReviewResponse } from '@/types';
|
||||
|
||||
export default function useWorkspaceReviewsQuery(
|
||||
workspaceId: number,
|
||||
memberId: number,
|
||||
reviewStatus?: 'REQUESTED' | 'APPROVED' | 'REJECTED',
|
||||
lastReviewId?: number,
|
||||
limitPage?: number
|
||||
limitPage: number = 10
|
||||
) {
|
||||
return useSuspenseQuery({
|
||||
queryKey: ['workspaceReviews', workspaceId, reviewStatus, lastReviewId],
|
||||
queryFn: () => getWorkspaceReviews(workspaceId, memberId, reviewStatus, lastReviewId, limitPage),
|
||||
return useSuspenseInfiniteQuery<ReviewResponse[]>({
|
||||
queryKey: ['workspaceReviews', workspaceId, reviewStatus],
|
||||
queryFn: ({ pageParam = undefined }) =>
|
||||
getWorkspaceReviews(workspaceId, memberId, reviewStatus, pageParam as number | undefined, limitPage),
|
||||
|
||||
getNextPageParam: (lastPage) => {
|
||||
if (lastPage.length === 0) return undefined;
|
||||
const lastReview = lastPage[lastPage.length - 1];
|
||||
return lastReview.reviewId;
|
||||
},
|
||||
|
||||
initialPageParam: undefined,
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user