Refactor navigation structure and API routes
- Centralize user menu, sidebar items, and breadcrumb logic. - Map consistent API endpoints in `customerRoutes`. - Replace inline route definitions with reusable constants. - Refactor auth configuration file location. - Improve `<Link>` usage to replace static `<a>` elements. - Adjust sidebar and dropdown components to use dynamic navigation configurations.
This commit is contained in:
@@ -15,10 +15,10 @@ const {
|
||||
NEXTAUTH_SECRET,
|
||||
} = process.env;
|
||||
|
||||
// if (!KEYCLOAK_CLIENT_ID) throw new Error("Missing KEYCLOAK_CLIENT_ID");
|
||||
// if (!KEYCLOAK_CLIENT_SECRET) throw new Error("Missing KEYCLOAK_CLIENT_SECRET");
|
||||
// if (!KEYCLOAK_ISSUER) throw new Error("Missing KEYCLOAK_ISSUER");
|
||||
// if (!NEXTAUTH_SECRET) throw new Error("Missing NEXTAUTH_SECRET");
|
||||
if (!KEYCLOAK_CLIENT_ID) throw new Error("Missing KEYCLOAK_CLIENT_ID");
|
||||
if (!KEYCLOAK_CLIENT_SECRET) throw new Error("Missing KEYCLOAK_CLIENT_SECRET");
|
||||
if (!KEYCLOAK_ISSUER) throw new Error("Missing KEYCLOAK_ISSUER");
|
||||
if (!NEXTAUTH_SECRET) throw new Error("Missing NEXTAUTH_SECRET");
|
||||
|
||||
console.log("[auth] Using Keycloak provider:");
|
||||
console.log(" - Client ID:", KEYCLOAK_CLIENT_ID);
|
||||
@@ -42,8 +42,8 @@ async function isTokenValid(token: string): Promise<boolean> {
|
||||
export const authOptions: NextAuthOptions = {
|
||||
providers: [
|
||||
KeycloakProvider({
|
||||
clientId: KEYCLOAK_CLIENT_ID as string,
|
||||
clientSecret: KEYCLOAK_CLIENT_SECRET as string,
|
||||
clientId: KEYCLOAK_CLIENT_ID,
|
||||
clientSecret: KEYCLOAK_CLIENT_SECRET,
|
||||
issuer: KEYCLOAK_ISSUER,
|
||||
}),
|
||||
],
|
||||
@@ -1,6 +1,6 @@
|
||||
// lib/callBackendApi.ts
|
||||
import {getServerSession} from "next-auth";
|
||||
import {authOptions} from "@/lib/auth/authOptions";
|
||||
import {authOptions} from "@/lib/api/auth/authOptions";
|
||||
|
||||
export async function serverCall(
|
||||
path: string,
|
||||
|
||||
@@ -1,20 +1,19 @@
|
||||
// lib/breadcrumb-map.ts
|
||||
import {customerRoutes} from "@/app/api/customers/customerRoutes";
|
||||
|
||||
export const breadcrumbMap: Record<string, string> = {
|
||||
'dashboard': 'Dashboard',
|
||||
'settings': 'Settings',
|
||||
'demo': 'Demo',
|
||||
'users': 'User Management',
|
||||
'customers': 'Kundenübersicht',
|
||||
// Add more mappings as needed
|
||||
};
|
||||
|
||||
export const breadcrumbResolvers: Record<string, (id: string) => Promise<string>> = {
|
||||
"customers": async (id: string) => {
|
||||
const res = await fetch(`/api/customers/${id}`, {cache: "no-store"});
|
||||
const customer = await res .json();
|
||||
const res = await fetch(`/api${customerRoutes.getById(id)}`, {cache: "no-store"});
|
||||
const customer = await res.json();
|
||||
if (customer.companyName) return `Firma: ${customer.companyName}`;
|
||||
if (customer.name) return `Name: ${customer.name}`;
|
||||
return `ID: ${id}`;
|
||||
},
|
||||
// Add more mappings as needed
|
||||
};
|
||||
38
internal_frontend/lib/navigation/sidebar-items.ts
Normal file
38
internal_frontend/lib/navigation/sidebar-items.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import {AppWindowIcon, Home, LayoutDashboard} from "lucide-react";
|
||||
import {MenuItem, SubMenuItem} from "@/types/navigation/sidebar";
|
||||
|
||||
export const rheinItems: MenuItem[] = [
|
||||
{
|
||||
title: "Dashboard",
|
||||
url: "/",
|
||||
icon: Home,
|
||||
},
|
||||
{
|
||||
title: "Apps",
|
||||
url: "/apps",
|
||||
icon: AppWindowIcon,
|
||||
},
|
||||
];
|
||||
|
||||
export const customerItems: MenuItem[] = [
|
||||
{
|
||||
title: "Kundenübersicht",
|
||||
url: "/customers",
|
||||
icon: LayoutDashboard,
|
||||
},
|
||||
];
|
||||
|
||||
export const kanzleiItems: SubMenuItem[] = [
|
||||
{
|
||||
title: "Steuer",
|
||||
url: "/demo/kanzlei/steuer",
|
||||
},
|
||||
{
|
||||
title: "Rechtsanwalt",
|
||||
url: "/demo/kanzlei/rechtsanwalt",
|
||||
},
|
||||
{
|
||||
title: "Bilanzbuchhalter",
|
||||
url: "/demo/kanzlei/bilanzbuchhalter",
|
||||
},
|
||||
];
|
||||
20
internal_frontend/lib/navigation/user-menu-items.ts
Normal file
20
internal_frontend/lib/navigation/user-menu-items.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import {LogOut, Settings} from "lucide-react";
|
||||
|
||||
export interface UserMenuItem {
|
||||
title: string;
|
||||
url: string;
|
||||
icon?: typeof Settings;
|
||||
}
|
||||
|
||||
export const userMenuItems: UserMenuItem[] = [
|
||||
{
|
||||
title: "Settings",
|
||||
url: "/settings",
|
||||
icon: Settings,
|
||||
},
|
||||
{
|
||||
title: "Ausloggen",
|
||||
url: "/api/auth/signout",
|
||||
icon: LogOut,
|
||||
},
|
||||
];
|
||||
Reference in New Issue
Block a user