working page tree

This commit is contained in:
Philipinho
2024-04-13 17:16:31 +01:00
parent 912fe6474b
commit f1bdce1662
13 changed files with 225 additions and 108 deletions

View File

@ -1,17 +1,14 @@
import {
useMutation,
useQuery,
UseQueryResult,
} from "@tanstack/react-query";
import { useMutation, useQuery, UseQueryResult } from "@tanstack/react-query";
import {
createPage,
deletePage,
getPageById,
getPages,
getRecentChanges,
getSpacePageOrder,
updatePage,
} from "@/features/page/services/page-service";
import { IPage } from "@/features/page/types/page.types";
import { IPage, IWorkspacePageOrder } from "@/features/page/types/page.types";
import { notifications } from "@mantine/notifications";
const RECENT_CHANGES_KEY = ["recentChanges"];
@ -25,10 +22,12 @@ export function usePageQuery(pageId: string): UseQueryResult<IPage, Error> {
});
}
export function useGetPagesQuery(): UseQueryResult<IPage[], Error> {
export function useGetPagesQuery(
spaceId: string,
): UseQueryResult<IPage[], Error> {
return useQuery({
queryKey: ["pages"],
queryFn: () => getPages(),
queryKey: ["pages", spaceId],
queryFn: () => getPages(spaceId),
staleTime: 5 * 60 * 1000,
});
}
@ -63,3 +62,14 @@ export function useDeletePageMutation() {
},
});
}
export default function useSpacePageOrder(
spaceId: string,
): UseQueryResult<IWorkspacePageOrder> {
return useQuery({
queryKey: ["page-order", spaceId],
queryFn: async () => {
return await getSpacePageOrder(spaceId);
},
});
}