Files
docmost/apps/client/src/ee/template/services/template-service.ts
T
Philipinho cc691d1138 fix tree
2026-05-19 02:37:14 +01:00

48 lines
1.3 KiB
TypeScript

import api from "@/lib/api-client";
import { ITemplate } from "@/ee/template/types/template.types";
import { IPage } from "@/features/page/types/page.types";
import { IPagination } from "@/lib/types.ts";
export async function getTemplates(params?: {
spaceId?: string;
cursor?: string;
limit?: number;
}): Promise<IPagination<ITemplate>> {
const req = await api.post("/templates", params);
return req.data;
}
export async function getTemplateById(
templateId: string,
): Promise<ITemplate> {
const req = await api.post<ITemplate>("/templates/info", { templateId });
return req.data;
}
export async function createTemplate(
data: Partial<ITemplate>,
): Promise<ITemplate> {
const req = await api.post<ITemplate>("/templates/create", data);
return req.data;
}
export async function updateTemplate(
data: Partial<ITemplate> & { templateId: string },
): Promise<ITemplate> {
const req = await api.post<ITemplate>("/templates/update", data);
return req.data;
}
export async function deleteTemplate(templateId: string): Promise<void> {
await api.post<void>("/templates/delete", { templateId });
}
export async function useTemplate(data: {
templateId: string;
spaceId: string;
parentPageId?: string;
}): Promise<IPage> {
const req = await api.post<IPage>("/templates/use", data);
return req.data;
}