- bookmark management with dnd-kit reordering, bulk edit, search, category filter/rename, and meta auto-fetch - migrate /bookmarks → /dashboard/bookmarks under (main) layout - homepage redesign with category grid, /-key search, dock tooltips - theme toggle + use-theme, sonner toasts, alert-dialog/skeleton, visual refresh of auth pages Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
49 lines
1.2 KiB
TypeScript
49 lines
1.2 KiB
TypeScript
import { Suspense } from "react";
|
|
import { auth } from "@/auth";
|
|
import { HomePageClient } from "./home-page-client";
|
|
|
|
const SERVER_API_URL = process.env.SERVER_API_URL || "http://backend:8080";
|
|
const hasKeycloak = !!process.env.AUTH_KEYCLOAK_ISSUER;
|
|
|
|
interface Bookmark {
|
|
id: number;
|
|
title: string;
|
|
url: string;
|
|
description: string;
|
|
icon: string;
|
|
category: string;
|
|
}
|
|
|
|
async function fetchPublicBookmarks(): Promise<Bookmark[]> {
|
|
try {
|
|
const res = await fetch(`${SERVER_API_URL}/api/bookmarks/public`, {
|
|
next: { revalidate: 0 },
|
|
});
|
|
if (!res.ok) return [];
|
|
const data = await res.json();
|
|
return data.bookmarks || [];
|
|
} catch {
|
|
return [];
|
|
}
|
|
}
|
|
|
|
export default async function HomePage() {
|
|
const session = await auth();
|
|
const isAuthenticated = !!session?.user;
|
|
const role = (session?.user as { role?: string } | undefined)?.role;
|
|
const isAdmin = role === "admin";
|
|
|
|
const bookmarks = await fetchPublicBookmarks();
|
|
|
|
return (
|
|
<Suspense>
|
|
<HomePageClient
|
|
isAuthenticated={isAuthenticated}
|
|
isAdmin={isAdmin}
|
|
hasKeycloak={hasKeycloak}
|
|
bookmarks={bookmarks}
|
|
/>
|
|
</Suspense>
|
|
);
|
|
}
|