mirror of
https://github.com/docmost/docmost.git
synced 2026-05-07 06:23:06 +08:00
9b682c8af5
* replace next with vite * disable strictmode (it interferes with collaboration in dev mode)
35 lines
969 B
TypeScript
35 lines
969 B
TypeScript
import { useMutation, useQuery, UseQueryResult } from '@tanstack/react-query';
|
|
import { ICurrentUserResponse } from '@/features/user/types/user.types';
|
|
import { getUserInfo } from '@/features/user/services/user-service';
|
|
import { createPage, deletePage, getPageById, updatePage } from '@/features/page/services/page-service';
|
|
import { IPage } from '@/features/page/types/page.types';
|
|
|
|
|
|
export default function usePage() {
|
|
|
|
const createMutation = useMutation(
|
|
(data: Partial<IPage>) => createPage(data),
|
|
);
|
|
|
|
const getPageByIdQuery = (id: string) => ({
|
|
queryKey: ['page', id],
|
|
queryFn: async () => getPageById(id),
|
|
});
|
|
|
|
const updateMutation = useMutation(
|
|
(data: Partial<IPage>) => updatePage(data),
|
|
);
|
|
|
|
|
|
const deleteMutation = useMutation(
|
|
(id: string) => deletePage(id),
|
|
);
|
|
|
|
return {
|
|
create: createMutation.mutate,
|
|
getPageById: getPageByIdQuery,
|
|
update: updateMutation.mutate,
|
|
delete: deleteMutation.mutate,
|
|
};
|
|
}
|