update breadcrumb and create account module
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
export enum ACCOUNT_TYPES {
|
||||
'PARTNER',
|
||||
'BUSINESS',
|
||||
'SUPER_ADMIN',
|
||||
'ADMIN',
|
||||
'PROVIDER',
|
||||
'POS',
|
||||
}
|
||||
|
||||
export type TAccountType = keyof typeof ACCOUNT_TYPES;
|
||||
@@ -19,7 +19,7 @@ export interface RouteInfo {
|
||||
meta: {
|
||||
title: string;
|
||||
icon?: string;
|
||||
pagePath?: (params: any) => string;
|
||||
pagePath?: (params?: any) => string;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -5,24 +5,36 @@ import { filter } from 'rxjs/operators';
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class BreadcrumbService {
|
||||
private readonly _items = signal<MenuItem[]>([]);
|
||||
readonly _items = signal<MenuItem[]>([]);
|
||||
|
||||
private router = inject(Router);
|
||||
|
||||
constructor() {
|
||||
// Clear breadcrumb items on navigation start so previous page items don't persist.
|
||||
// Components for the new route can set their own items in their lifecycle (e.g. ngOnInit).
|
||||
this.router.events.pipe(filter((e) => e instanceof NavigationStart)).subscribe(() => {
|
||||
this.clear();
|
||||
// Clear breadcrumb items only when the path changes (not on query string changes)
|
||||
let lastPath = '';
|
||||
this.router.events.pipe(filter((e) => e instanceof NavigationStart)).subscribe((e) => {
|
||||
const nav = e as NavigationStart;
|
||||
const urlPath = nav.url.split('?')[0];
|
||||
|
||||
if (!lastPath || (lastPath && urlPath !== lastPath)) {
|
||||
this.clear();
|
||||
}
|
||||
lastPath = urlPath;
|
||||
});
|
||||
}
|
||||
|
||||
get items() {
|
||||
return this._items();
|
||||
setItems(items: MenuItem[]) {
|
||||
this._items.set(this.mapItems(items));
|
||||
}
|
||||
|
||||
setItems(items: MenuItem[]) {
|
||||
this._items.set(items);
|
||||
private readonly mapItems = (items: MenuItem[]) =>
|
||||
items.map((item) => ({
|
||||
...item,
|
||||
label: item.title || '',
|
||||
}));
|
||||
|
||||
addItems(items: MenuItem[]) {
|
||||
this._items.update((value) => ({ ...value, ...this.mapItems(items) }));
|
||||
}
|
||||
|
||||
clear() {
|
||||
|
||||
Reference in New Issue
Block a user