Archived
fix: cleanup
This commit is contained in:
@@ -1,22 +1,10 @@
|
||||
/**
|
||||
* API client for the reader module — reading settings, chapters, and progress.
|
||||
* API client for the reader module — reading settings and progress.
|
||||
* Uses the shared axios client so JWT auth is attached automatically.
|
||||
*/
|
||||
|
||||
import api from "./client";
|
||||
import type {
|
||||
ChapterDetail,
|
||||
ChapterSummary,
|
||||
ReadingProgress,
|
||||
ReadingSettings,
|
||||
} from "../types/reader";
|
||||
|
||||
interface TocChapter {
|
||||
id: number;
|
||||
title: string;
|
||||
index: number;
|
||||
href?: string;
|
||||
}
|
||||
import type { ReadingProgress, ReadingSettings } from "../types/reader";
|
||||
|
||||
export async function getReadingSettings(): Promise<ReadingSettings> {
|
||||
const { data } = await api.get<ReadingSettings>("/reader/settings/");
|
||||
@@ -30,39 +18,6 @@ export async function updateReadingSettings(
|
||||
return data;
|
||||
}
|
||||
|
||||
export async function getChapters(bookId: number): Promise<ChapterSummary[]> {
|
||||
const { data } = await api.get<{ chapters: TocChapter[] }>(
|
||||
`/books/ebooks/${bookId}/toc/`,
|
||||
);
|
||||
const chapters = data.chapters ?? [];
|
||||
return chapters.map((ch) => ({
|
||||
id: ch.id,
|
||||
book: bookId,
|
||||
title: ch.title,
|
||||
number: ch.index + 1,
|
||||
}));
|
||||
}
|
||||
|
||||
export async function getChapterContent(
|
||||
bookId: number,
|
||||
chapterNumber: number,
|
||||
): Promise<ChapterDetail> {
|
||||
const { data } = await api.get<{
|
||||
page: number;
|
||||
chapter_title: string;
|
||||
content: string;
|
||||
}>(`/books/ebooks/${bookId}/content/`, { params: { page: chapterNumber } });
|
||||
return {
|
||||
id: chapterNumber,
|
||||
book: bookId,
|
||||
title: data.chapter_title ?? "",
|
||||
number: data.page ?? chapterNumber,
|
||||
content: data.content ?? "",
|
||||
created_at: "",
|
||||
updated_at: "",
|
||||
};
|
||||
}
|
||||
|
||||
export async function getReadingProgress(
|
||||
bookId: number,
|
||||
): Promise<ReadingProgress> {
|
||||
|
||||
Reference in New Issue
Block a user