- 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.
20 lines
708 B
TypeScript
20 lines
708 B
TypeScript
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',
|
|
};
|
|
|
|
export const breadcrumbResolvers: Record<string, (id: string) => Promise<string>> = {
|
|
"customers": async (id: string) => {
|
|
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}`;
|
|
},
|
|
};
|