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:
27
internal_frontend/services/navigation/breadcrumb-utils.ts
Normal file
27
internal_frontend/services/navigation/breadcrumb-utils.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import {breadcrumbMap} from "@/lib/navigation/breadcrumb-map";
|
||||
|
||||
export interface Breadcrumb {
|
||||
href: string;
|
||||
label: string;
|
||||
isCurrentPage: boolean;
|
||||
}
|
||||
|
||||
export function getBreadcrumbs(path: string): Breadcrumb[] {
|
||||
const pathSegments = path.split('/').filter(Boolean);
|
||||
|
||||
return pathSegments.map((segment, index) => {
|
||||
const href = `/${pathSegments.slice(0, index + 1).join('/')}`;
|
||||
const label =
|
||||
breadcrumbMap[segment.toLowerCase()] ||
|
||||
segment
|
||||
.split('-')
|
||||
.map(word => word.charAt(0).toUpperCase() + word.slice(1))
|
||||
.join(' ');
|
||||
|
||||
return {
|
||||
label,
|
||||
href,
|
||||
isCurrentPage: index === pathSegments.length - 1,
|
||||
};
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user