Working initial version
This commit is contained in:
24
frontend/.gitignore
vendored
Normal file
24
frontend/.gitignore
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
pnpm-debug.log*
|
||||
lerna-debug.log*
|
||||
|
||||
node_modules
|
||||
dist
|
||||
dist-ssr
|
||||
*.local
|
||||
|
||||
# Editor directories and files
|
||||
.vscode/*
|
||||
!.vscode/extensions.json
|
||||
.idea
|
||||
.DS_Store
|
||||
*.suo
|
||||
*.ntvs*
|
||||
*.njsproj
|
||||
*.sln
|
||||
*.sw?
|
||||
54
frontend/README.md
Normal file
54
frontend/README.md
Normal file
@@ -0,0 +1,54 @@
|
||||
# React + TypeScript + Vite
|
||||
|
||||
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
|
||||
|
||||
Currently, two official plugins are available:
|
||||
|
||||
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) for Fast Refresh
|
||||
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
|
||||
|
||||
## Expanding the ESLint configuration
|
||||
|
||||
If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
|
||||
|
||||
```js
|
||||
export default tseslint.config({
|
||||
extends: [
|
||||
// Remove ...tseslint.configs.recommended and replace with this
|
||||
...tseslint.configs.recommendedTypeChecked,
|
||||
// Alternatively, use this for stricter rules
|
||||
...tseslint.configs.strictTypeChecked,
|
||||
// Optionally, add this for stylistic rules
|
||||
...tseslint.configs.stylisticTypeChecked,
|
||||
],
|
||||
languageOptions: {
|
||||
// other options...
|
||||
parserOptions: {
|
||||
project: ['./tsconfig.node.json', './tsconfig.app.json'],
|
||||
tsconfigRootDir: import.meta.dirname,
|
||||
},
|
||||
},
|
||||
})
|
||||
```
|
||||
|
||||
You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:
|
||||
|
||||
```js
|
||||
// eslint.config.js
|
||||
import reactX from 'eslint-plugin-react-x'
|
||||
import reactDom from 'eslint-plugin-react-dom'
|
||||
|
||||
export default tseslint.config({
|
||||
plugins: {
|
||||
// Add the react-x and react-dom plugins
|
||||
'react-x': reactX,
|
||||
'react-dom': reactDom,
|
||||
},
|
||||
rules: {
|
||||
// other rules...
|
||||
// Enable its recommended typescript rules
|
||||
...reactX.configs['recommended-typescript'].rules,
|
||||
...reactDom.configs.recommended.rules,
|
||||
},
|
||||
})
|
||||
```
|
||||
28
frontend/eslint.config.js
Normal file
28
frontend/eslint.config.js
Normal file
@@ -0,0 +1,28 @@
|
||||
import js from '@eslint/js'
|
||||
import globals from 'globals'
|
||||
import reactHooks from 'eslint-plugin-react-hooks'
|
||||
import reactRefresh from 'eslint-plugin-react-refresh'
|
||||
import tseslint from 'typescript-eslint'
|
||||
|
||||
export default tseslint.config(
|
||||
{ ignores: ['dist'] },
|
||||
{
|
||||
extends: [js.configs.recommended, ...tseslint.configs.recommended],
|
||||
files: ['**/*.{ts,tsx}'],
|
||||
languageOptions: {
|
||||
ecmaVersion: 2020,
|
||||
globals: globals.browser,
|
||||
},
|
||||
plugins: {
|
||||
'react-hooks': reactHooks,
|
||||
'react-refresh': reactRefresh,
|
||||
},
|
||||
rules: {
|
||||
...reactHooks.configs.recommended.rules,
|
||||
'react-refresh/only-export-components': [
|
||||
'warn',
|
||||
{ allowConstantExport: true },
|
||||
],
|
||||
},
|
||||
},
|
||||
)
|
||||
13
frontend/index.html
Normal file
13
frontend/index.html
Normal file
@@ -0,0 +1,13 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>EU Legislation Explorer</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script type="module" src="/src/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
3380
frontend/package-lock.json
generated
Normal file
3380
frontend/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
32
frontend/package.json
Normal file
32
frontend/package.json
Normal file
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"name": "frontend",
|
||||
"private": true,
|
||||
"version": "0.0.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "tsc -b && vite build",
|
||||
"lint": "eslint .",
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"@tanstack/react-query": "^5.74.4",
|
||||
"@tanstack/react-query-devtools": "^5.74.6",
|
||||
"react": "^19.0.0",
|
||||
"react-dom": "^19.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^9.22.0",
|
||||
"@tanstack/eslint-plugin-query": "^5.73.3",
|
||||
"@types/react": "^19.0.10",
|
||||
"@types/react-dom": "^19.0.4",
|
||||
"@vitejs/plugin-react": "^4.3.4",
|
||||
"eslint": "^9.22.0",
|
||||
"eslint-plugin-react-hooks": "^5.2.0",
|
||||
"eslint-plugin-react-refresh": "^0.4.19",
|
||||
"globals": "^16.0.0",
|
||||
"typescript": "~5.7.2",
|
||||
"typescript-eslint": "^8.26.1",
|
||||
"vite": "^6.3.1"
|
||||
}
|
||||
}
|
||||
1
frontend/public/vite.svg
Normal file
1
frontend/public/vite.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|
||||
|
After Width: | Height: | Size: 1.5 KiB |
26
frontend/src/App.css
Normal file
26
frontend/src/App.css
Normal file
@@ -0,0 +1,26 @@
|
||||
.App {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2rem;
|
||||
padding: 2rem;
|
||||
align-items: center;
|
||||
justify-content: start;
|
||||
height: 100vh;
|
||||
}
|
||||
|
||||
.panel-container {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
gap: 2rem;
|
||||
}
|
||||
|
||||
.controls {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
gap: 2rem;
|
||||
|
||||
label {
|
||||
margin-right: 0.5rem;
|
||||
}
|
||||
}
|
||||
91
frontend/src/App.tsx
Normal file
91
frontend/src/App.tsx
Normal file
@@ -0,0 +1,91 @@
|
||||
import { useState } from "react";
|
||||
import Panel from "./components/Panel";
|
||||
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import "./App.css";
|
||||
import ArticleSelector from "./components/ArticleSelector";
|
||||
import CelexSelector from "./components/CelexSelector";
|
||||
import { getArticleIds } from "./lib/api";
|
||||
import { Language } from "./lib/types";
|
||||
|
||||
function App() {
|
||||
const [celexId, setCelexId] = useState("32024R1689");
|
||||
const [selectedArticle, setSelectedArticle] = useState<number>(1);
|
||||
const [numPanels, setNumPanels] = useState(1);
|
||||
const [selectedParagraphId, setSelectedParagraphId] = useState<string | null>(
|
||||
null
|
||||
);
|
||||
|
||||
const {
|
||||
data: articleIds,
|
||||
isPending,
|
||||
error,
|
||||
} = useQuery({
|
||||
queryKey: ["articleIds", celexId],
|
||||
queryFn: () => getArticleIds(celexId),
|
||||
enabled: !!celexId,
|
||||
});
|
||||
|
||||
if (isPending) {
|
||||
return <div>Loading...</div>;
|
||||
}
|
||||
if (error) {
|
||||
return <div>Error: {error.message}</div>;
|
||||
}
|
||||
|
||||
const examples = [
|
||||
{ name: "GDPR", id: "32016R0679" },
|
||||
{ name: "AI Act", id: "32024R1689" },
|
||||
{ name: "Cyber Resilience Act", id: "32024R2847" },
|
||||
];
|
||||
|
||||
return (
|
||||
<div className="App">
|
||||
<div className="controls">
|
||||
<div>
|
||||
<label htmlFor="examples">Select example:</label>
|
||||
<select
|
||||
id="examples"
|
||||
value={celexId}
|
||||
onChange={(e) => {
|
||||
setSelectedArticle(1);
|
||||
setSelectedParagraphId(null);
|
||||
setCelexId(e.currentTarget.value);
|
||||
}}
|
||||
>
|
||||
{examples.map((example) => (
|
||||
<option key={example.id} value={example.id}>
|
||||
{example.name}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
<CelexSelector defaultId={celexId} onSelected={setCelexId} />
|
||||
<ArticleSelector
|
||||
articleIds={articleIds}
|
||||
selectedId={selectedArticle}
|
||||
onSelected={setSelectedArticle}
|
||||
/>
|
||||
<button onClick={() => setNumPanels((prev) => prev + 1)}>
|
||||
Add Panel
|
||||
</button>
|
||||
</div>
|
||||
<div className="panel-container">
|
||||
{Array.from({ length: numPanels }, (_, index) => (
|
||||
<Panel
|
||||
key={index}
|
||||
celexId={celexId}
|
||||
language={
|
||||
Object.values(Language)[index % Object.values(Language).length]
|
||||
}
|
||||
articleId={selectedArticle}
|
||||
selectedParagraphId={selectedParagraphId || undefined}
|
||||
onParagraphSelected={setSelectedParagraphId}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default App;
|
||||
37
frontend/src/components/ArticleSelector.tsx
Normal file
37
frontend/src/components/ArticleSelector.tsx
Normal file
@@ -0,0 +1,37 @@
|
||||
type ArticleSelectorProps = {
|
||||
articleIds: number[];
|
||||
selectedId: number;
|
||||
onSelected(articleId: number): void;
|
||||
};
|
||||
|
||||
function ArticleSelector({
|
||||
articleIds,
|
||||
selectedId,
|
||||
onSelected,
|
||||
}: ArticleSelectorProps) {
|
||||
return (
|
||||
<>
|
||||
{selectedId > 1 && (
|
||||
<button onClick={() => onSelected(selectedId - 1)}>prev</button>
|
||||
)}
|
||||
<select
|
||||
value={selectedId}
|
||||
onChange={(e) => {
|
||||
const id = parseInt(e.currentTarget.value);
|
||||
onSelected(id);
|
||||
}}
|
||||
>
|
||||
{articleIds.map((id) => (
|
||||
<option key={id} value={id}>
|
||||
Article {id}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
{selectedId < articleIds[articleIds.length - 1] && (
|
||||
<button onClick={() => onSelected(selectedId + 1)}>next</button>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export default ArticleSelector;
|
||||
20
frontend/src/components/CelexSelector.tsx
Normal file
20
frontend/src/components/CelexSelector.tsx
Normal file
@@ -0,0 +1,20 @@
|
||||
type CelexSelectorProps = {
|
||||
defaultId?: string;
|
||||
onSelected(celexId: string): void;
|
||||
};
|
||||
|
||||
function CelexSelector({ defaultId, onSelected }: CelexSelectorProps) {
|
||||
return (
|
||||
<form
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
onSelected(e.currentTarget.celexId.value);
|
||||
}}
|
||||
>
|
||||
<label htmlFor="celexId">CELEX ID:</label>
|
||||
<input type="text" id="celexId" defaultValue={defaultId} />
|
||||
</form>
|
||||
);
|
||||
}
|
||||
|
||||
export default CelexSelector;
|
||||
7
frontend/src/components/LanguageSwitcher.css
Normal file
7
frontend/src/components/LanguageSwitcher.css
Normal file
@@ -0,0 +1,7 @@
|
||||
.language-switcher {
|
||||
margin: 0 10px;
|
||||
padding: 5px;
|
||||
font-size: 14px;
|
||||
border-radius: 4px;
|
||||
border: 1px solid #ccc;
|
||||
}
|
||||
29
frontend/src/components/LanguageSwitcher.tsx
Normal file
29
frontend/src/components/LanguageSwitcher.tsx
Normal file
@@ -0,0 +1,29 @@
|
||||
import { Language } from "../lib/types";
|
||||
|
||||
import "./LanguageSwitcher.css";
|
||||
|
||||
function LanguageSwitcher({
|
||||
defaultLang,
|
||||
onChange,
|
||||
}: {
|
||||
defaultLang: Language;
|
||||
onChange: (lang: Language) => void;
|
||||
}) {
|
||||
return (
|
||||
<>
|
||||
<select
|
||||
defaultValue={defaultLang}
|
||||
onChange={(ev) => onChange(ev.currentTarget.value as Language)}
|
||||
className="language-switcher"
|
||||
>
|
||||
{Object.values(Language).map((lang) => (
|
||||
<option key={lang} value={lang}>
|
||||
{lang.toUpperCase()}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export default LanguageSwitcher;
|
||||
25
frontend/src/components/Panel.css
Normal file
25
frontend/src/components/Panel.css
Normal file
@@ -0,0 +1,25 @@
|
||||
.panel {
|
||||
flex-grow: 1;
|
||||
padding: 1rem;
|
||||
border-radius: 8px;
|
||||
border: 1px solid #ccc;
|
||||
|
||||
.highlight {
|
||||
background-color: rgba(100, 255, 100, 0.2);
|
||||
}
|
||||
|
||||
article {
|
||||
.list-lower-alpha {
|
||||
list-style-type: lower-alpha;
|
||||
}
|
||||
|
||||
ol .item-number {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.paragraph-number {
|
||||
float: left;
|
||||
margin-right: 1ch;
|
||||
}
|
||||
}
|
||||
}
|
||||
96
frontend/src/components/Panel.tsx
Normal file
96
frontend/src/components/Panel.tsx
Normal file
@@ -0,0 +1,96 @@
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { getArticle } from "../lib/api";
|
||||
import { Language } from "../lib/types";
|
||||
import LanguageSwitcher from "./LanguageSwitcher";
|
||||
import "./Panel.css";
|
||||
|
||||
type PanelProps = {
|
||||
celexId: string;
|
||||
language?: Language;
|
||||
articleId: number;
|
||||
selectedParagraphId?: string;
|
||||
onParagraphSelected(paragraphId: string): void;
|
||||
};
|
||||
|
||||
function Panel({
|
||||
celexId,
|
||||
language,
|
||||
articleId,
|
||||
onParagraphSelected,
|
||||
selectedParagraphId,
|
||||
}: PanelProps) {
|
||||
const [lang, setLang] = useState(language || Language.ENG);
|
||||
const articleRef = useRef<HTMLDivElement>(null);
|
||||
const { data, isPending, error } = useQuery({
|
||||
queryKey: ["article", celexId, articleId, lang],
|
||||
queryFn: () => getArticle(celexId, articleId, lang),
|
||||
enabled: !!celexId,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
const articleElement = articleRef.current;
|
||||
if (!articleElement) return;
|
||||
|
||||
const paragraphs = articleElement.querySelectorAll(".paragraph");
|
||||
|
||||
// Highlight the selected paragraph
|
||||
paragraphs.forEach((p) => {
|
||||
p.classList.remove("highlight");
|
||||
});
|
||||
if (selectedParagraphId) {
|
||||
const selectedParagraph = Array.from(paragraphs).find(
|
||||
(p) => p.getAttribute("data-paragraph-id") === selectedParagraphId
|
||||
);
|
||||
if (selectedParagraph) {
|
||||
selectedParagraph.classList.add("highlight");
|
||||
}
|
||||
}
|
||||
|
||||
// Add click event listeners
|
||||
const handleClick = (target: Element) => () => {
|
||||
const paragraphId = target.getAttribute("data-paragraph-id");
|
||||
paragraphs.forEach((p) => {
|
||||
p.classList.remove("highlight");
|
||||
});
|
||||
if (!paragraphId) {
|
||||
console.warn("No paragraph ID found for target:", target);
|
||||
return;
|
||||
}
|
||||
target.classList.add("highlight");
|
||||
onParagraphSelected(paragraphId);
|
||||
};
|
||||
|
||||
paragraphs.forEach((element) => {
|
||||
element.addEventListener("click", handleClick(element));
|
||||
});
|
||||
|
||||
// Cleanup event listeners
|
||||
return () => {
|
||||
console.log("Cleaning up event listeners");
|
||||
paragraphs.forEach((element) => {
|
||||
element.removeEventListener("click", handleClick(element));
|
||||
});
|
||||
};
|
||||
}, [articleRef, data, selectedParagraphId, onParagraphSelected]);
|
||||
|
||||
if (isPending) return "Loading...";
|
||||
if (error) return "An error has occurred: " + error.message;
|
||||
|
||||
return (
|
||||
<div className={"panel"}>
|
||||
<LanguageSwitcher
|
||||
defaultLang={lang}
|
||||
onChange={setLang}
|
||||
></LanguageSwitcher>
|
||||
<div
|
||||
ref={articleRef}
|
||||
lang={lang.substring(0, 2)}
|
||||
className="article-text"
|
||||
dangerouslySetInnerHTML={{ __html: data || "" }}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default Panel;
|
||||
68
frontend/src/index.css
Normal file
68
frontend/src/index.css
Normal file
@@ -0,0 +1,68 @@
|
||||
:root {
|
||||
font-family: system-ui, Avenir, Helvetica, Arial, sans-serif;
|
||||
line-height: 1.5;
|
||||
font-weight: 400;
|
||||
|
||||
color-scheme: light dark;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
background-color: #242424;
|
||||
|
||||
font-synthesis: none;
|
||||
text-rendering: optimizeLegibility;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
a {
|
||||
font-weight: 500;
|
||||
color: #646cff;
|
||||
text-decoration: inherit;
|
||||
}
|
||||
a:hover {
|
||||
color: #535bf2;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
display: flex;
|
||||
place-items: center;
|
||||
min-width: 320px;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 3.2em;
|
||||
line-height: 1.1;
|
||||
}
|
||||
|
||||
button {
|
||||
border-radius: 8px;
|
||||
border: 1px solid transparent;
|
||||
padding: 0.6em 1.2em;
|
||||
font-size: 1em;
|
||||
font-weight: 500;
|
||||
font-family: inherit;
|
||||
background-color: #1a1a1a;
|
||||
cursor: pointer;
|
||||
transition: border-color 0.25s;
|
||||
}
|
||||
button:hover {
|
||||
border-color: #646cff;
|
||||
}
|
||||
button:focus,
|
||||
button:focus-visible {
|
||||
outline: 4px auto -webkit-focus-ring-color;
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: light) {
|
||||
:root {
|
||||
color: #213547;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
a:hover {
|
||||
color: #747bff;
|
||||
}
|
||||
button {
|
||||
background-color: #f9f9f9;
|
||||
}
|
||||
}
|
||||
23
frontend/src/lib/api.ts
Normal file
23
frontend/src/lib/api.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
const API_URL = import.meta.env.VITE_API_URL;
|
||||
|
||||
async function getArticle(
|
||||
celexId: string,
|
||||
article: number,
|
||||
language: string
|
||||
): Promise<string> {
|
||||
console.debug(
|
||||
`Fetching article ${article} for CELEX ID ${celexId} in ${language} language`
|
||||
);
|
||||
const response = await fetch(
|
||||
`${API_URL}/${celexId}/articles/${article}/${language}`
|
||||
);
|
||||
return await response.text();
|
||||
}
|
||||
|
||||
async function getArticleIds(celexId: string): Promise<number[]> {
|
||||
console.debug(`Fetching article list for CELEX ID ${celexId}`);
|
||||
const response = await fetch(`${API_URL}/${celexId}/articles`);
|
||||
return await response.json();
|
||||
}
|
||||
|
||||
export { getArticle, getArticleIds };
|
||||
9
frontend/src/lib/types.ts
Normal file
9
frontend/src/lib/types.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
enum Language {
|
||||
ENG = "eng",
|
||||
DEU = "deu",
|
||||
FRA = "fra",
|
||||
ITA = "ita",
|
||||
ESP = "esp",
|
||||
}
|
||||
|
||||
export { Language };
|
||||
17
frontend/src/main.tsx
Normal file
17
frontend/src/main.tsx
Normal file
@@ -0,0 +1,17 @@
|
||||
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
||||
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
|
||||
import { StrictMode } from "react";
|
||||
import { createRoot } from "react-dom/client";
|
||||
import App from "./App.tsx";
|
||||
import "./index.css";
|
||||
|
||||
const queryClient = new QueryClient();
|
||||
|
||||
createRoot(document.getElementById("root")!).render(
|
||||
<StrictMode>
|
||||
<QueryClientProvider client={queryClient}>
|
||||
<ReactQueryDevtools />
|
||||
<App />
|
||||
</QueryClientProvider>
|
||||
</StrictMode>
|
||||
);
|
||||
10
frontend/src/vite-env.d.ts
vendored
Normal file
10
frontend/src/vite-env.d.ts
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
/// <reference types="vite/client" />
|
||||
|
||||
interface ImportMetaEnv {
|
||||
readonly VITE_APP_TITLE: string;
|
||||
readonly VITE_API_URL: string;
|
||||
}
|
||||
|
||||
interface ImportMeta {
|
||||
readonly env: ImportMetaEnv;
|
||||
}
|
||||
26
frontend/tsconfig.app.json
Normal file
26
frontend/tsconfig.app.json
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
|
||||
"target": "ES2020",
|
||||
"useDefineForClassFields": true,
|
||||
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
||||
"module": "ESNext",
|
||||
"skipLibCheck": true,
|
||||
|
||||
/* Bundler mode */
|
||||
"moduleResolution": "bundler",
|
||||
"allowImportingTsExtensions": true,
|
||||
"isolatedModules": true,
|
||||
"moduleDetection": "force",
|
||||
"noEmit": true,
|
||||
"jsx": "react-jsx",
|
||||
|
||||
/* Linting */
|
||||
"strict": true,
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noUncheckedSideEffectImports": true
|
||||
},
|
||||
"include": ["src"]
|
||||
}
|
||||
7
frontend/tsconfig.json
Normal file
7
frontend/tsconfig.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"files": [],
|
||||
"references": [
|
||||
{ "path": "./tsconfig.app.json" },
|
||||
{ "path": "./tsconfig.node.json" }
|
||||
]
|
||||
}
|
||||
24
frontend/tsconfig.node.json
Normal file
24
frontend/tsconfig.node.json
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
|
||||
"target": "ES2022",
|
||||
"lib": ["ES2023"],
|
||||
"module": "ESNext",
|
||||
"skipLibCheck": true,
|
||||
|
||||
/* Bundler mode */
|
||||
"moduleResolution": "bundler",
|
||||
"allowImportingTsExtensions": true,
|
||||
"isolatedModules": true,
|
||||
"moduleDetection": "force",
|
||||
"noEmit": true,
|
||||
|
||||
/* Linting */
|
||||
"strict": true,
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noUncheckedSideEffectImports": true
|
||||
},
|
||||
"include": ["vite.config.ts"]
|
||||
}
|
||||
7
frontend/vite.config.ts
Normal file
7
frontend/vite.config.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import { defineConfig } from 'vite'
|
||||
import react from '@vitejs/plugin-react'
|
||||
|
||||
// https://vite.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [react()],
|
||||
})
|
||||
Reference in New Issue
Block a user