- 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.
27 lines
765 B
TypeScript
27 lines
765 B
TypeScript
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,
|
|
};
|
|
});
|
|
} |