diff --git a/frontend/valora-web/app/admin/audit-logs/page.tsx b/frontend/valora-web/app/admin/audit-logs/page.tsx
new file mode 100644
index 0000000..eec3c6f
--- /dev/null
+++ b/frontend/valora-web/app/admin/audit-logs/page.tsx
@@ -0,0 +1,5 @@
+import { AdminAuditLogs } from "@/components/admin/admin-audit-logs";
+
+export default function AdminAuditLogsPage(): React.JSX.Element {
+ return ;
+}
\ No newline at end of file
diff --git a/frontend/valora-web/app/admin/layout.tsx b/frontend/valora-web/app/admin/layout.tsx
new file mode 100644
index 0000000..a3d2a78
--- /dev/null
+++ b/frontend/valora-web/app/admin/layout.tsx
@@ -0,0 +1,16 @@
+import { AdminGuard } from "@/components/auth/admin-guard";
+import { AdminShell } from "@/components/admin/admin-shell";
+
+interface AdminLayoutProps {
+ children: React.ReactNode;
+}
+
+export default function AdminLayout({
+ children,
+}: AdminLayoutProps): React.JSX.Element {
+ return (
+
+ {children}
+
+ );
+}
\ No newline at end of file
diff --git a/frontend/valora-web/app/admin/model-performance/page.tsx b/frontend/valora-web/app/admin/model-performance/page.tsx
new file mode 100644
index 0000000..5ca4188
--- /dev/null
+++ b/frontend/valora-web/app/admin/model-performance/page.tsx
@@ -0,0 +1,5 @@
+import { AdminModelPerformance } from "@/components/admin/admin-model-performance";
+
+export default function AdminModelPerformancePage(): React.JSX.Element {
+ return ;
+}
\ No newline at end of file
diff --git a/frontend/valora-web/app/admin/models/page.tsx b/frontend/valora-web/app/admin/models/page.tsx
new file mode 100644
index 0000000..b8362ea
--- /dev/null
+++ b/frontend/valora-web/app/admin/models/page.tsx
@@ -0,0 +1,5 @@
+import { AdminModelStats } from "@/components/admin/admin-model-stats";
+
+export default function AdminModelsPage(): React.JSX.Element {
+ return ;
+}
\ No newline at end of file
diff --git a/frontend/valora-web/app/admin/page.tsx b/frontend/valora-web/app/admin/page.tsx
new file mode 100644
index 0000000..f8163f4
--- /dev/null
+++ b/frontend/valora-web/app/admin/page.tsx
@@ -0,0 +1,5 @@
+import { AdminOverview } from "@/components/admin/admin-overview";
+
+export default function AdminPage(): React.JSX.Element {
+ return ;
+}
\ No newline at end of file
diff --git a/frontend/valora-web/app/globals.css b/frontend/valora-web/app/globals.css
index e77671b..71ce874 100644
--- a/frontend/valora-web/app/globals.css
+++ b/frontend/valora-web/app/globals.css
@@ -6,7 +6,7 @@
radial-gradient(circle at 85% 10%, rgba(187, 247, 208, 0.85), transparent 18%),
radial-gradient(circle at 40% 100%, rgba(209, 250, 229, 0.8), transparent 28%),
linear-gradient(180deg, #f7fff9 0%, #f0fdf4 45%, #ecfeff 100%);
- --foreground: #052e06;
+ --foreground: #052e16;
}
* {
diff --git a/frontend/valora-web/components/admin/admin-audit-logs.tsx b/frontend/valora-web/components/admin/admin-audit-logs.tsx
new file mode 100644
index 0000000..1c9455a
--- /dev/null
+++ b/frontend/valora-web/components/admin/admin-audit-logs.tsx
@@ -0,0 +1,102 @@
+"use client";
+
+import { useQuery } from "@tanstack/react-query";
+import { RefreshCcw } from "lucide-react";
+import { AdminHeader } from "@/components/admin/admin-header";
+import { adminApi } from "@/lib/api/admin-api";
+import { getAccessToken } from "@/lib/auth/token-storage";
+
+function formatDate(value: string): string {
+ return new Intl.DateTimeFormat("nl-NL", {
+ dateStyle: "medium",
+ timeStyle: "short",
+ }).format(new Date(value));
+}
+
+export function AdminAuditLogs(): React.JSX.Element {
+ const token = getAccessToken();
+
+ const logsQuery = useQuery({
+ queryKey: ["admin-audit-logs"],
+ queryFn: ({ signal }) => adminApi.getAuditLogs(token as string, signal),
+ enabled: Boolean(token),
+ });
+
+ return (
+
+
+
+
+
+
+
Recente events
+
+ Laatste {logsQuery.data?.count ?? 0} logs uit de backend.
+
+
+
+
+
+
+ {logsQuery.isLoading ? (
+ Laden...
+ ) : null}
+
+ {logsQuery.isError ? (
+
+ Audit logs konden niet worden geladen.
+
+ ) : null}
+
+ {logsQuery.data ? (
+
+
+
+
+ | Actie |
+ User |
+ Entity |
+ Details |
+ Tijd |
+
+
+
+ {logsQuery.data.logs.map((log) => (
+
+ |
+ {log.action}
+ |
+
+ {log.userId ?? "-"}
+ |
+
+ {log.entityType}
+ {log.entityId ? ` · ${log.entityId}` : ""}
+ |
+
+ {log.details ?? "-"}
+ |
+
+ {formatDate(log.createdAtUtc)}
+ |
+
+ ))}
+
+
+
+ ) : null}
+
+
+ );
+}
\ No newline at end of file
diff --git a/frontend/valora-web/components/admin/admin-header.tsx b/frontend/valora-web/components/admin/admin-header.tsx
new file mode 100644
index 0000000..aa4c3f1
--- /dev/null
+++ b/frontend/valora-web/components/admin/admin-header.tsx
@@ -0,0 +1,48 @@
+"use client";
+
+import { useCurrentUser } from "@/hooks/use-current-user";
+
+interface AdminHeaderProps {
+ eyebrow: string;
+ title: string;
+ description: string;
+}
+
+export function AdminHeader({
+ eyebrow,
+ title,
+ description,
+}: AdminHeaderProps): React.JSX.Element {
+ const { user } = useCurrentUser();
+
+ return (
+
+
+ {eyebrow}
+
+
+
+
+
+ {title}
+
+
+ {description}
+
+
+
+
+
+ Admin sessie
+
+
+ {user?.displayName ?? "Admin"}
+
+
+ {user?.roles.join(", ") ?? "-"}
+
+
+
+
+ );
+}
\ No newline at end of file
diff --git a/frontend/valora-web/components/admin/admin-model-performance.tsx b/frontend/valora-web/components/admin/admin-model-performance.tsx
new file mode 100644
index 0000000..f0860cd
--- /dev/null
+++ b/frontend/valora-web/components/admin/admin-model-performance.tsx
@@ -0,0 +1,290 @@
+"use client";
+
+import { useMemo, useState } from "react";
+import { useQuery } from "@tanstack/react-query";
+import { RefreshCcw } from "lucide-react";
+import { AdminHeader } from "@/components/admin/admin-header";
+import { SimpleBarChart } from "@/components/admin/charts/simple-bar-chart";
+import { adminApi } from "@/lib/api/admin-api";
+import { getAccessToken } from "@/lib/auth/token-storage";
+
+function formatCurrency(value: number): string {
+ return new Intl.NumberFormat("nl-NL", {
+ style: "currency",
+ currency: "EUR",
+ maximumFractionDigits: 0,
+ }).format(value);
+}
+
+function formatPercentage(value: number): string {
+ return `${value.toFixed(2)}%`;
+}
+
+export function AdminModelPerformance(): React.JSX.Element {
+ const token = getAccessToken();
+ const [selectedCategory, setSelectedCategory] = useState("");
+
+ const categoriesQuery = useQuery({
+ queryKey: ["admin-model-categories"],
+ queryFn: ({ signal }) => adminApi.getModelCategories(token as string, signal),
+ enabled: Boolean(token),
+ });
+
+ const overviewQuery = useQuery({
+ queryKey: ["admin-model-performance-overview"],
+ queryFn: ({ signal }) => adminApi.getModelPerformanceOverview(token as string, signal),
+ enabled: Boolean(token),
+ });
+
+ const listingsQuery = useQuery({
+ queryKey: ["admin-model-performance-listings"],
+ queryFn: ({ signal }) => adminApi.getModelPerformanceListings(token as string, signal),
+ enabled: Boolean(token),
+ });
+
+ const categoryQuery = useQuery({
+ queryKey: ["admin-model-performance-category", selectedCategory],
+ queryFn: ({ signal }) =>
+ adminApi.getModelPerformanceByCategory(selectedCategory, token as string, signal),
+ enabled: Boolean(token) && selectedCategory.length > 0,
+ retry: false,
+ });
+
+ const categories = useMemo(() => {
+ return categoriesQuery.data?.categories.map((item) => item.key) ?? [];
+ }, [categoriesQuery.data]);
+
+ return (
+
+
+
+
+
+
Categorieën
+
+ {overviewQuery.data?.summary.totalCategories ?? 0}
+
+
+
+
+
Listings
+
+ {overviewQuery.data?.summary.totalListings ?? 0}
+
+
+
+
+
Weighted MAE
+
+ {overviewQuery.data
+ ? formatCurrency(overviewQuery.data.summary.weightedMeanAbsoluteError)
+ : "-"}
+
+
+
+
+
Weighted MAPE
+
+ {overviewQuery.data
+ ? formatPercentage(
+ overviewQuery.data.summary.weightedMeanAbsolutePercentageError,
+ )
+ : "-"}
+
+
+
+
+
({
+ label: item.category,
+ value: item.meanAbsoluteError,
+ })) ?? []
+ }
+ valueFormatter={(value) => formatCurrency(value)}
+ />
+
+
+
+
+
Categorie-analyse
+
+ Kies een categorie om detailperformance te bekijken.
+
+
+
+
+
+
+
+
+
+
+
+
+ | Categorie |
+ Listings |
+ MAE |
+ MAPE |
+ Median AE |
+
+
+
+ {overviewQuery.data?.categories.map((item) => (
+
+ |
+ {item.category}
+ |
+
+ {item.totalListings}
+ |
+
+ {formatCurrency(item.meanAbsoluteError)}
+ |
+
+ {formatPercentage(item.meanAbsolutePercentageError)}
+ |
+
+ {formatCurrency(item.medianAbsoluteError)}
+ |
+
+ )) ?? null}
+
+
+
+
+
+ {selectedCategory ? (
+
+
+
+
+ Detailperformance · {selectedCategory}
+
+
+ Listing-level prestaties voor de gekozen categorie.
+
+
+
+
+
+
+ {categoryQuery.isLoading ? (
+ Laden...
+ ) : null}
+
+ {categoryQuery.isError ? (
+
+ Voor deze categorie is nog geen sold listing performance data beschikbaar.
+
+ ) : null}
+
+ {categoryQuery.data ? (
+ <>
+
+
+
Listings
+
+ {categoryQuery.data.totalListings}
+
+
+
+
+
MAE
+
+ {formatCurrency(categoryQuery.data.meanAbsoluteError)}
+
+
+
+
+
MAPE
+
+ {formatPercentage(categoryQuery.data.meanAbsolutePercentageError)}
+
+
+
+
+ ({
+ label: item.title,
+ value: item.absoluteError,
+ }))}
+ valueFormatter={(value) => formatCurrency(value)}
+ />
+
+
+
+
+
+ | Titel |
+ Actueel |
+ Voorspeld |
+ Absolute error |
+ APE |
+
+
+
+ {categoryQuery.data.listings.map((item) => (
+
+ |
+ {item.title}
+ |
+
+ {formatCurrency(item.actualPrice)}
+ |
+
+ {formatCurrency(item.predictedPrice)}
+ |
+
+ {formatCurrency(item.absoluteError)}
+ |
+
+ {formatPercentage(item.absolutePercentageError)}
+ |
+
+ ))}
+
+
+
+ >
+ ) : null}
+
+ ) : null}
+
+ ({
+ label: `${item.category} · ${item.title}`,
+ value: item.absoluteError,
+ })) ?? []
+ }
+ valueFormatter={(value) => formatCurrency(value)}
+ />
+
+ );
+}
\ No newline at end of file
diff --git a/frontend/valora-web/components/admin/admin-model-stats.tsx b/frontend/valora-web/components/admin/admin-model-stats.tsx
new file mode 100644
index 0000000..67411fe
--- /dev/null
+++ b/frontend/valora-web/components/admin/admin-model-stats.tsx
@@ -0,0 +1,208 @@
+"use client";
+
+import { useQuery } from "@tanstack/react-query";
+import { AdminHeader } from "@/components/admin/admin-header";
+import { SimpleBarChart } from "@/components/admin/charts/simple-bar-chart";
+import { SimpleDonutChart } from "@/components/admin/charts/simple-donut-chart";
+import { adminApi } from "@/lib/api/admin-api";
+import { getAccessToken } from "@/lib/auth/token-storage";
+
+function formatDate(value: string): string {
+ return new Intl.DateTimeFormat("nl-NL", {
+ dateStyle: "medium",
+ timeStyle: "short",
+ }).format(new Date(value));
+}
+
+export function AdminModelStats(): React.JSX.Element {
+ const token = getAccessToken();
+
+ const modelStatsQuery = useQuery({
+ queryKey: ["admin-model-stats"],
+ queryFn: ({ signal }) => adminApi.getModelStats(token as string, signal),
+ enabled: Boolean(token),
+ });
+
+ const userStatsQuery = useQuery({
+ queryKey: ["admin-user-stats"],
+ queryFn: ({ signal }) => adminApi.getUserStats(token as string, signal),
+ enabled: Boolean(token),
+ });
+
+ const listingStatsQuery = useQuery({
+ queryKey: ["admin-listing-stats"],
+ queryFn: ({ signal }) => adminApi.getListingStats(token as string, signal),
+ enabled: Boolean(token),
+ });
+
+ const predictionStatsQuery = useQuery({
+ queryKey: ["admin-prediction-stats"],
+ queryFn: ({ signal }) => adminApi.getPredictionStats(token as string, signal),
+ enabled: Boolean(token),
+ });
+
+ return (
+
+
+
+
+
+
Training runs
+
+ {modelStatsQuery.data?.totalTrainingRuns ?? 0}
+
+
+
+
+
Users
+
+ {userStatsQuery.data?.totalUsers ?? 0}
+
+
+
+
+
Listings
+
+ {listingStatsQuery.data?.total ?? 0}
+
+
+
+
+
Predictions
+
+ {predictionStatsQuery.data?.total ?? 0}
+
+
+
+
+
+
+
+ ({
+ label: item.category,
+ value: item.count,
+ })) ?? []
+ }
+ />
+
+ ({
+ label: `${item.category} (v${item.latestVersion})`,
+ value: item.count,
+ })) ?? []
+ }
+ />
+
+
+
({
+ label: `${item.category} · v${item.modelVersion}`,
+ value: item.count,
+ })) ?? []
+ }
+ />
+
+
+ Laatste training runs
+
+
+
+
+ | Categorie |
+ Versie |
+ R² |
+ RMSE |
+ MAE |
+ Tijd |
+
+
+
+ {modelStatsQuery.data?.latestRuns.map((run) => (
+
+ |
+ {run.categoryKey}
+ |
+
+ v{run.version}
+ |
+
+ {run.rSquared.toFixed(4)}
+ |
+
+ {run.rootMeanSquaredError.toFixed(2)}
+ |
+
+ {run.meanAbsoluteError.toFixed(2)}
+ |
+
+ {formatDate(run.createdAtUtc)}
+ |
+
+ )) ?? null}
+
+
+
+
+
+ );
+}
\ No newline at end of file
diff --git a/frontend/valora-web/components/admin/admin-overview.tsx b/frontend/valora-web/components/admin/admin-overview.tsx
new file mode 100644
index 0000000..12dd6dd
--- /dev/null
+++ b/frontend/valora-web/components/admin/admin-overview.tsx
@@ -0,0 +1,207 @@
+"use client";
+
+import { useQuery } from "@tanstack/react-query";
+import {
+ Activity,
+ BarChart3,
+ Database,
+ ReceiptText,
+ RefreshCcw,
+ Users,
+} from "lucide-react";
+import { AdminHeader } from "@/components/admin/admin-header";
+import { SimpleBarChart } from "@/components/admin/charts/simple-bar-chart";
+import { getAccessToken } from "@/lib/auth/token-storage";
+import { adminApi } from "@/lib/api/admin-api";
+
+function formatDate(value: string): string {
+ return new Intl.DateTimeFormat("nl-NL", {
+ dateStyle: "medium",
+ timeStyle: "short",
+ }).format(new Date(value));
+}
+
+export function AdminOverview(): React.JSX.Element {
+ const token = getAccessToken();
+
+ const dashboardQuery = useQuery({
+ queryKey: ["admin-dashboard"],
+ queryFn: ({ signal }) => adminApi.getDashboard(token as string, signal),
+ enabled: Boolean(token),
+ });
+
+ if (dashboardQuery.isLoading) {
+ return (
+
+
+
+
+ {Array.from({ length: 4 }).map((_, index) => (
+
+ ))}
+
+
+ );
+ }
+
+ if (dashboardQuery.isError || !dashboardQuery.data) {
+ return (
+
+
+
+
+
+ Controleer of je als admin bent ingelogd en of de backend bereikbaar is.
+
+
+
+
+
+ );
+ }
+
+ const data = dashboardQuery.data;
+
+ return (
+
+
+
+
+
+
+
+
+
Gebruikers
+
{data.totalUsers}
+
+
+
+
+
+
+
Listings
+
{data.totalListings}
+
+ {data.publishedListings} published · {data.soldListings} sold
+
+
+
+
+
+
Predictions
+
{data.totalPredictions}
+
+ {data.predictionsLast24Hours} in laatste 24 uur
+
+
+
+
+
+
+
+
Training runs
+
{data.totalTrainingRuns}
+
+ {data.listingsLast24Hours} listings in laatste 24 uur
+
+
+
+
+
+ ({
+ label: item.name,
+ value: item.value,
+ }))}
+ />
+
+ ({
+ label: item.name,
+ value: item.value,
+ }))}
+ />
+
+ ({
+ label: item.name,
+ value: item.value,
+ }))}
+ />
+
+
+
+
+
+
+
+
+
Recente audit logs
+
+ Laatste 20 events uit de backend.
+
+
+
+
+
+
+
+
+ | Actie |
+ Entity |
+ Details |
+ Tijd |
+
+
+
+ {data.recentAuditLogs.map((log) => (
+
+ |
+ {log.action}
+ |
+
+ {log.entityType}
+ {log.entityId ? ` · ${log.entityId}` : ""}
+ |
+
+ {log.details ?? "-"}
+ |
+
+ {formatDate(log.createdAtUtc)}
+ |
+
+ ))}
+
+
+
+
+
+ );
+}
\ No newline at end of file
diff --git a/frontend/valora-web/components/admin/admin-shell.tsx b/frontend/valora-web/components/admin/admin-shell.tsx
new file mode 100644
index 0000000..da92b33
--- /dev/null
+++ b/frontend/valora-web/components/admin/admin-shell.tsx
@@ -0,0 +1,16 @@
+import { AdminSidebar } from "@/components/admin/admin-sidebar";
+
+interface AdminShellProps {
+ children: React.ReactNode;
+}
+
+export function AdminShell({ children }: AdminShellProps): React.JSX.Element {
+ return (
+
+
+
+ );
+}
\ No newline at end of file
diff --git a/frontend/valora-web/components/admin/admin-sidebar.tsx b/frontend/valora-web/components/admin/admin-sidebar.tsx
new file mode 100644
index 0000000..6dd1ab1
--- /dev/null
+++ b/frontend/valora-web/components/admin/admin-sidebar.tsx
@@ -0,0 +1,63 @@
+"use client";
+
+import Link from "next/link";
+import { usePathname } from "next/navigation";
+import {
+ Activity,
+ BarChart3,
+ LayoutDashboard,
+ ScrollText,
+} from "lucide-react";
+
+const navigation = [
+ {
+ label: "Overzicht",
+ href: "/admin",
+ icon: LayoutDashboard,
+ },
+ {
+ label: "Model performance",
+ href: "/admin/model-performance",
+ icon: Activity,
+ },
+ {
+ label: "Audit logs",
+ href: "/admin/audit-logs",
+ icon: ScrollText,
+ },
+ {
+ label: "Model stats",
+ href: "/admin/models",
+ icon: BarChart3,
+ },
+];
+
+export function AdminSidebar(): React.JSX.Element {
+ const pathname = usePathname();
+
+ return (
+
+ );
+}
\ No newline at end of file
diff --git a/frontend/valora-web/components/admin/charts/simple-bar-chart.tsx b/frontend/valora-web/components/admin/charts/simple-bar-chart.tsx
new file mode 100644
index 0000000..ccc56de
--- /dev/null
+++ b/frontend/valora-web/components/admin/charts/simple-bar-chart.tsx
@@ -0,0 +1,57 @@
+interface SimpleBarChartItem {
+ label: string;
+ value: number;
+}
+
+interface SimpleBarChartProps {
+ title: string;
+ items: SimpleBarChartItem[];
+ valueFormatter?: (value: number) => string;
+ emptyText?: string;
+}
+
+export function SimpleBarChart({
+ title,
+ items,
+ valueFormatter = (value) => value.toString(),
+ emptyText = "Geen data beschikbaar.",
+}: SimpleBarChartProps): React.JSX.Element {
+ const maxValue = Math.max(...items.map((item) => item.value), 0);
+
+ return (
+
+ {title}
+
+ {items.length === 0 ? (
+ {emptyText}
+ ) : (
+
+ {items.map((item) => {
+ const widthPercentage =
+ maxValue === 0 ? 0 : Math.max((item.value / maxValue) * 100, 6);
+
+ return (
+
+
+
+ {item.label}
+
+
+ {valueFormatter(item.value)}
+
+
+
+
+
+ );
+ })}
+
+ )}
+
+ );
+}
\ No newline at end of file
diff --git a/frontend/valora-web/components/admin/charts/simple-donut-chart.tsx b/frontend/valora-web/components/admin/charts/simple-donut-chart.tsx
new file mode 100644
index 0000000..d00b949
--- /dev/null
+++ b/frontend/valora-web/components/admin/charts/simple-donut-chart.tsx
@@ -0,0 +1,84 @@
+interface SimpleDonutChartSegment {
+ label: string;
+ value: number;
+ toneClassName: string;
+}
+
+interface SimpleDonutChartProps {
+ title: string;
+ totalLabel: string;
+ segments: SimpleDonutChartSegment[];
+}
+
+export function SimpleDonutChart({
+ title,
+ totalLabel,
+ segments,
+}: SimpleDonutChartProps): React.JSX.Element {
+ const total = segments.reduce((sum, segment) => sum + segment.value, 0);
+
+ return (
+
+ {title}
+
+
+
+
+
+ {segments.map((segment) => {
+ const widthPercentage =
+ total === 0 ? 0 : (segment.value / total) * 100;
+
+ return (
+
+ );
+ })}
+
+
+
+
+ {total}
+
+ {totalLabel}
+
+
+
+
+
+ {segments.map((segment) => {
+ const percentage = total === 0 ? 0 : (segment.value / total) * 100;
+
+ return (
+
+
+
+
+ {segment.label}
+
+
+
+
+
+ {segment.value}
+
+
+ {percentage.toFixed(1)}%
+
+
+
+ );
+ })}
+
+
+
+ );
+}
\ No newline at end of file
diff --git a/frontend/valora-web/components/auth/admin-guard.tsx b/frontend/valora-web/components/auth/admin-guard.tsx
new file mode 100644
index 0000000..3c04295
--- /dev/null
+++ b/frontend/valora-web/components/auth/admin-guard.tsx
@@ -0,0 +1,53 @@
+"use client";
+
+import { useEffect } from "react";
+import { usePathname, useRouter } from "next/navigation";
+import { getAccessToken } from "@/lib/auth/token-storage";
+import { useCurrentUser } from "@/hooks/use-current-user";
+
+interface AdminGuardProps {
+ children: React.ReactNode;
+}
+
+export function AdminGuard({ children }: AdminGuardProps): React.JSX.Element {
+ const router = useRouter();
+ const pathname = usePathname();
+ const token = getAccessToken();
+ const { user, isAuthenticated, isLoading } = useCurrentUser();
+
+ useEffect(() => {
+ if (!token) {
+ const returnUrl = encodeURIComponent(pathname ?? "/admin");
+ router.replace(`/login?returnUrl=${returnUrl}`);
+ }
+ }, [pathname, router, token]);
+
+ useEffect(() => {
+ if (!isLoading && token && !isAuthenticated) {
+ const returnUrl = encodeURIComponent(pathname ?? "/admin");
+ router.replace(`/login?returnUrl=${returnUrl}`);
+ return;
+ }
+
+ if (!isLoading && isAuthenticated && user && !user.roles.includes("Admin")) {
+ router.replace("/dashboard");
+ }
+ }, [isAuthenticated, isLoading, pathname, router, token, user]);
+
+ if (!token || isLoading || !isAuthenticated || !user || !user.roles.includes("Admin")) {
+ return (
+
+
+
+ Adminrechten controleren...
+
+
+ We checken of je toegang hebt tot het admin dashboard.
+
+
+
+ );
+ }
+
+ return <>{children}>;
+}
\ No newline at end of file
diff --git a/frontend/valora-web/components/layout/navbar.tsx b/frontend/valora-web/components/layout/navbar.tsx
index 2399a70..be5ccbe 100644
--- a/frontend/valora-web/components/layout/navbar.tsx
+++ b/frontend/valora-web/components/layout/navbar.tsx
@@ -2,7 +2,7 @@
import Link from "next/link";
import { useRouter } from "next/navigation";
-import { LayoutDashboard, LogOut } from "lucide-react";
+import { LayoutDashboard, LogOut, Shield } from "lucide-react";
import { clearAccessToken } from "@/lib/auth/token-storage";
import { useCurrentUser } from "@/hooks/use-current-user";
@@ -22,6 +22,8 @@ export function Navbar(): React.JSX.Element {
router.refresh();
}
+ const isAdmin = user?.roles.includes("Admin") ?? false;
+
return (