Archived
32 lines
861 B
TypeScript
32 lines
861 B
TypeScript
import api from "./client";
|
|
import type { PaginatedResponse } from "@cloud-reader/shared";
|
|
import type { Bookmark, CreateMarkerPayload } from "../types";
|
|
|
|
export async function fetchBookmarks(
|
|
ebookId?: string | number,
|
|
): Promise<PaginatedResponse<Bookmark>> {
|
|
const params: Record<string, string> = {};
|
|
if (ebookId != null && ebookId !== "") {
|
|
params.ebook = String(ebookId);
|
|
}
|
|
const { data } = await api.get<PaginatedResponse<Bookmark>>(
|
|
"/api/annotations/bookmarks/",
|
|
{ params },
|
|
);
|
|
return data;
|
|
}
|
|
|
|
export async function createMarker(
|
|
payload: CreateMarkerPayload,
|
|
): Promise<Bookmark> {
|
|
const { data } = await api.post<Bookmark>(
|
|
"/api/annotations/bookmarks/",
|
|
payload,
|
|
);
|
|
return data;
|
|
}
|
|
|
|
export async function deleteBookmark(id: string): Promise<void> {
|
|
await api.delete(`/api/annotations/bookmarks/${id}/`);
|
|
}
|