mirror of
https://github.com/docmost/docmost.git
synced 2026-05-07 14:43:06 +08:00
d42091ccb1
* feat: favorites and templates(ee) * rename migrations * fix sidebar * cleanup tabs * fix * turn off templates * cleanup * uuid validation
47 lines
1.2 KiB
TypeScript
47 lines
1.2 KiB
TypeScript
import api from "@/lib/api-client";
|
|
import { ITemplate } from "@/ee/template/types/template.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<any> {
|
|
const req = await api.post("/templates/use", data);
|
|
return req.data;
|
|
}
|