Customer Detail Page and Enhance dynamic breadcrumbs
This commit is contained in:
@@ -1,19 +1,18 @@
|
||||
// utils/getBreadcrumbs.ts
|
||||
import {breadcrumbMap} from '@/lib/breadcrumb-map';
|
||||
import {breadcrumbMap} from "@/lib/breadcrumb-map";
|
||||
|
||||
export type Breadcrumb = {
|
||||
label: string;
|
||||
export interface Breadcrumb {
|
||||
href: string;
|
||||
isCurrentPage?: boolean;
|
||||
};
|
||||
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('/')}`;
|
||||
// Use the mapping if it exists, otherwise format the segment
|
||||
const label = breadcrumbMap[segment.toLowerCase()] ||
|
||||
const label =
|
||||
breadcrumbMap[segment.toLowerCase()] ||
|
||||
segment
|
||||
.split('-')
|
||||
.map(word => word.charAt(0).toUpperCase() + word.slice(1))
|
||||
@@ -22,7 +21,7 @@ export function getBreadcrumbs(path: string): Breadcrumb[] {
|
||||
return {
|
||||
label,
|
||||
href,
|
||||
isCurrentPage: index === pathSegments.length - 1
|
||||
isCurrentPage: index === pathSegments.length - 1,
|
||||
};
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user