Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions frontend/valora-web/app/admin/audit-logs/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { AdminAuditLogs } from "@/components/admin/admin-audit-logs";

export default function AdminAuditLogsPage(): React.JSX.Element {
return <AdminAuditLogs />;
}
16 changes: 16 additions & 0 deletions frontend/valora-web/app/admin/layout.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<AdminGuard>
<AdminShell>{children}</AdminShell>
</AdminGuard>
);
}
5 changes: 5 additions & 0 deletions frontend/valora-web/app/admin/model-performance/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { AdminModelPerformance } from "@/components/admin/admin-model-performance";

export default function AdminModelPerformancePage(): React.JSX.Element {
return <AdminModelPerformance />;
}
5 changes: 5 additions & 0 deletions frontend/valora-web/app/admin/models/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { AdminModelStats } from "@/components/admin/admin-model-stats";

export default function AdminModelsPage(): React.JSX.Element {
return <AdminModelStats />;
}
5 changes: 5 additions & 0 deletions frontend/valora-web/app/admin/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { AdminOverview } from "@/components/admin/admin-overview";

export default function AdminPage(): React.JSX.Element {
return <AdminOverview />;
}
2 changes: 1 addition & 1 deletion frontend/valora-web/app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

* {
Expand Down
102 changes: 102 additions & 0 deletions frontend/valora-web/components/admin/admin-audit-logs.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<div className="space-y-6">
<AdminHeader
eyebrow="Admin"
title="Audit logs"
description="Bekijk recente platformevents voor debugging, monitoring en beheer."
/>

<section className="soft-panel rounded-[2rem] p-6">
<div className="flex items-center justify-between gap-4">
<div>
<h2 className="text-2xl font-black text-emerald-950">Recente events</h2>
<p className="mt-2 text-sm leading-7 text-emerald-950/62">
Laatste {logsQuery.data?.count ?? 0} logs uit de backend.
</p>
</div>

<button
type="button"
onClick={() => void logsQuery.refetch()}
className="inline-flex items-center gap-2 rounded-full border border-emerald-200 bg-white px-4 py-2 text-sm font-semibold text-emerald-950 transition hover:bg-emerald-50"
>
<RefreshCcw className="h-4 w-4" />
Vernieuwen
</button>
</div>

{logsQuery.isLoading ? (
<p className="mt-6 text-sm text-emerald-950/60">Laden...</p>
) : null}

{logsQuery.isError ? (
<p className="mt-6 text-sm text-emerald-950/60">
Audit logs konden niet worden geladen.
</p>
) : null}

{logsQuery.data ? (
<div className="mt-6 overflow-x-auto">
<table className="min-w-full border-separate border-spacing-y-3">
<thead>
<tr className="text-left text-xs uppercase tracking-[0.18em] text-emerald-900/45">
<th className="px-4">Actie</th>
<th className="px-4">User</th>
<th className="px-4">Entity</th>
<th className="px-4">Details</th>
<th className="px-4">Tijd</th>
</tr>
</thead>
<tbody>
{logsQuery.data.logs.map((log) => (
<tr key={log.id} className="bg-white shadow-sm">
<td className="rounded-l-[1rem] px-4 py-4 font-semibold text-emerald-950">
{log.action}
</td>
<td className="px-4 py-4 text-sm text-emerald-950/70">
{log.userId ?? "-"}
</td>
<td className="px-4 py-4 text-sm text-emerald-950/70">
{log.entityType}
{log.entityId ? ` · ${log.entityId}` : ""}
</td>
<td className="px-4 py-4 text-sm text-emerald-950/70">
{log.details ?? "-"}
</td>
<td className="rounded-r-[1rem] px-4 py-4 text-sm text-emerald-950/70">
{formatDate(log.createdAtUtc)}
</td>
</tr>
))}
</tbody>
</table>
</div>
) : null}
</section>
</div>
);
}
48 changes: 48 additions & 0 deletions frontend/valora-web/components/admin/admin-header.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<section className="soft-panel rounded-[2.2rem] p-8">
<p className="text-sm font-bold uppercase tracking-[0.22em] text-emerald-900/50">
{eyebrow}
</p>

<div className="mt-3 flex flex-col gap-4 lg:flex-row lg:items-end lg:justify-between">
<div>
<h1 className="text-4xl font-black tracking-tight text-emerald-950 md:text-5xl">
{title}
</h1>
<p className="mt-4 max-w-3xl text-sm leading-7 text-emerald-950/65">
{description}
</p>
</div>

<div className="rounded-[1.5rem] border border-emerald-200 bg-white px-5 py-4 shadow-sm">
<p className="text-xs font-bold uppercase tracking-[0.18em] text-emerald-900/45">
Admin sessie
</p>
<p className="mt-2 text-lg font-black text-emerald-950">
{user?.displayName ?? "Admin"}
</p>
<p className="mt-1 text-sm text-emerald-950/55">
{user?.roles.join(", ") ?? "-"}
</p>
</div>
</div>
</section>
);
}
Loading
Loading