diff --git a/bundestag.io/admin/src/app/list/_components/PageTemplate.tsx b/bundestag.io/admin/src/app/list/_components/PageTemplate.tsx
new file mode 100644
index 00000000..254a304a
--- /dev/null
+++ b/bundestag.io/admin/src/app/list/_components/PageTemplate.tsx
@@ -0,0 +1,39 @@
+import Entry from '../_components/entry';
+import { PaginationNavigation } from '../_components/pagination-navigation';
+import { IProcedure } from '@democracy-deutschland/bundestagio-common';
+import { ITEMS_PER_PAGE } from '../_utils/fetchProcedures';
+
+interface PageTemplateProps {
+ title: string;
+ procedures: IProcedure[];
+ count: number;
+ currentPage: number;
+}
+
+export default function PageTemplate({ title, procedures, count, currentPage }: PageTemplateProps) {
+ const totalPages = Math.ceil(count / ITEMS_PER_PAGE);
+
+ return (
+ <>
+
{title}
+ {totalPages === 0 && There are no {title.toLowerCase()}.
}
+ {totalPages > 0 && (
+ <>
+
+ {procedures.map((procedure) => (
+ ({
+ party: vote.party,
+ decision: vote.main,
+ }))}
+ />
+ ))}
+
+ >
+ )}
+ >
+ );
+}
diff --git a/bundestag.io/admin/src/app/list/_utils/fetchProcedures.ts b/bundestag.io/admin/src/app/list/_utils/fetchProcedures.ts
new file mode 100644
index 00000000..bcc2814d
--- /dev/null
+++ b/bundestag.io/admin/src/app/list/_utils/fetchProcedures.ts
@@ -0,0 +1,22 @@
+import { IProcedure } from '@democracy-deutschland/bundestagio-common';
+
+const ITEMS_PER_PAGE = 10;
+
+export async function fetchProcedures(url: string, page: number): Promise<{ procedures: IProcedure[]; count: number }> {
+ const limit = ITEMS_PER_PAGE;
+
+ const res = await fetch(`${url}?limit=${limit}&page=${page}`, {
+ headers: {
+ 'Cache-Control': 'no-cache',
+ cache: 'no-store',
+ },
+ });
+
+ if (!res.ok) {
+ throw new Error('Fehler beim Abrufen der Daten');
+ }
+
+ return res.json();
+}
+
+export { ITEMS_PER_PAGE };
diff --git a/bundestag.io/admin/src/app/list/past/page.tsx b/bundestag.io/admin/src/app/list/past/page.tsx
index ea580072..992b48b4 100644
--- a/bundestag.io/admin/src/app/list/past/page.tsx
+++ b/bundestag.io/admin/src/app/list/past/page.tsx
@@ -1,54 +1,16 @@
-import Entry from '../_components/entry';
-import { IProcedure } from '@democracy-deutschland/bundestagio-common';
import { unstable_noStore as noStore } from 'next/cache';
-import Link from 'next/link';
-import { PaginationNavigation } from '../_components/pagination-navigation';
-
-const ITEMS_PER_PAGE = 10;
+import { fetchProcedures } from '../_utils/fetchProcedures';
+import PageTemplate from '../_components/PageTemplate';
export const dynamic = 'force-dynamic';
-async function getData(page: number = 1): Promise<{ procedures: IProcedure[]; count: number }> {
- const limit = ITEMS_PER_PAGE;
-
- const res = await fetch(`${process.env.PROCEDURES_SERVER_URL}/procedures/list/past?limit=${limit}&page=${page}`, {
- headers: {
- 'Cache-Control': 'no-cache',
- cache: 'no-store',
- },
- });
-
- if (!res.ok) {
- throw new Error('Fehler beim Abrufen der Daten');
- }
-
- return res.json();
-}
-
export default async function Page({ searchParams }: { searchParams: { page?: string } }) {
noStore();
- const currentPage = searchParams.page ? parseInt(searchParams.page, 10) : 1; // Standardwert ist Seite 1
- const { procedures, count } = await getData(currentPage);
- const totalPages = Math.ceil(count / ITEMS_PER_PAGE); // Berechne die Gesamtseitenzahl basierend auf der Anzahl der Elemente
-
- return (
- <>
- Past procedures
-
-
- {procedures.map((procedure) => (
- ({
- party: vote.party,
- decision: vote.main,
- }))}
- />
- ))}
-
-
- >
+ const currentPage = searchParams.page ? parseInt(searchParams.page, 10) : 1;
+ const { procedures, count } = await fetchProcedures(
+ `${process.env.PROCEDURES_SERVER_URL}/procedures/list/past`,
+ currentPage,
);
+
+ return ;
}
diff --git a/bundestag.io/admin/src/app/list/upcoming/page.tsx b/bundestag.io/admin/src/app/list/upcoming/page.tsx
index 7018ab70..8cdb1ae5 100644
--- a/bundestag.io/admin/src/app/list/upcoming/page.tsx
+++ b/bundestag.io/admin/src/app/list/upcoming/page.tsx
@@ -1,55 +1,16 @@
-import Entry from '../_components/entry';
-import { IProcedure } from '@democracy-deutschland/bundestagio-common';
import { unstable_noStore as noStore } from 'next/cache';
-import Link from 'next/link';
-import { PaginationNavigation } from '../_components/pagination-navigation';
-
-const ITEMS_PER_PAGE = 10;
+import { fetchProcedures } from '../_utils/fetchProcedures';
+import PageTemplate from '../_components/PageTemplate';
export const dynamic = 'force-dynamic';
-async function getData(page: number = 1): Promise<{ procedures: IProcedure[]; count: number }> {
- const limit = ITEMS_PER_PAGE;
-
- const res = await fetch(`${process.env.PROCEDURES_SERVER_URL}/procedures/list/upcoming?limit=${limit}&page=${page}`, {
- headers: {
- 'Cache-Control': 'no-cache',
- cache: 'no-store',
- },
- });
-
- if (!res.ok) {
- throw new Error('Fehler beim Abrufen der Daten');
- }
-
- return res.json();
-}
-
export default async function Page({ searchParams }: { searchParams: { page?: string } }) {
noStore();
- const currentPage = searchParams.page ? parseInt(searchParams.page, 10) : 1; // Standardwert ist Seite 1
- const { procedures, count } = await getData(currentPage);
- const totalPages = Math.ceil(count / ITEMS_PER_PAGE); // Berechne die Gesamtseitenzahl basierend auf der Anzahl der Elemente
-
- return (
- <>
- Upcoming procedures
-
-
-
- {procedures.map((procedure) => (
- ({
- party: vote.party,
- decision: vote.main,
- }))}
- />
- ))}
-
-
- >
+ const currentPage = searchParams.page ? parseInt(searchParams.page, 10) : 1;
+ const { procedures, count } = await fetchProcedures(
+ `${process.env.PROCEDURES_SERVER_URL}/procedures/list/upcoming`,
+ currentPage,
);
+
+ return ;
}