Files
docmost/apps/client/src/features/favorite/services/favorite-service.ts
T
2026-04-12 20:16:46 +01:00

32 lines
764 B
TypeScript

import api from "@/lib/api-client";
import { IPagination } from "@/lib/types.ts";
import { IFavorite, FavoriteType } from "../types/favorite.types";
export type ToggleFavoriteParams = {
type: FavoriteType;
pageId?: string;
spaceId?: string;
templateId?: string;
};
export async function addFavorite(
params: ToggleFavoriteParams,
): Promise<void> {
await api.post("/favorites/add", params);
}
export async function removeFavorite(
params: ToggleFavoriteParams,
): Promise<void> {
await api.post("/favorites/remove", params);
}
export async function getFavorites(params?: {
type?: FavoriteType;
limit?: number;
cursor?: string;
}): Promise<IPagination<IFavorite>> {
const req = await api.post("/favorites", params);
return req.data;
}