Improved article selector with titles and structure

This commit is contained in:
Adrian Rumpold
2025-04-25 09:18:53 +02:00
parent f21158c6c0
commit abb415c380
9 changed files with 86 additions and 46 deletions

View File

@@ -1,5 +1,4 @@
import TOC from "../components/TOC/TOC";
import { Language } from "./types";
import { Division, Language } from "./types";
const API_URL = import.meta.env.VITE_API_URL;
@@ -23,10 +22,13 @@ async function getArticleIds(celexId: string): Promise<number[]> {
return await response.json();
}
async function getToc(celexId: string, language: Language): Promise<TOC> {
async function getToc(
celexId: string,
language: Language
): Promise<Division[]> {
console.debug(`Fetching TOC for CELEX ID ${celexId}`);
const response = await fetch(`${API_URL}/${celexId}/toc/${language}`);
return await response.json();
return (await response.json()) as Division[];
}
export { getArticle, getArticleIds, getToc };