red-ui/apps/red-ui/src/app/modules/account/account-side-nav/account-side-nav.component.ts
2024-06-20 10:28:34 +03:00

58 lines
2.0 KiB
TypeScript

import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { IqserPermissionsService } from '@iqser/common-ui';
import { Roles } from '@users/roles';
import { User } from '@red/domain';
import { getCurrentUser } from '@iqser/common-ui/lib/users';
import { SideNavComponent } from '@common-ui/shared';
import { TranslateModule } from '@ngx-translate/core';
import { NgForOf, NgIf } from '@angular/common';
import { RouterLink, RouterLinkActive } from '@angular/router';
interface NavItem {
readonly label: string;
readonly screen: string;
readonly show?: boolean;
readonly helpModeKey?: string;
}
@Component({
selector: 'redaction-account-side-nav',
templateUrl: './account-side-nav.component.html',
styleUrls: ['./account-side-nav.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
standalone: true,
imports: [SideNavComponent, TranslateModule, NgForOf, NgIf, RouterLinkActive, RouterLink],
})
export class AccountSideNavComponent {
readonly currentUser = getCurrentUser<User>();
readonly items: NavItem[] = [
{
screen: 'user-profile',
label: _('user-profile'),
show: true,
helpModeKey: 'my_profile',
},
{
screen: 'notifications',
show: this.currentUser.isUser && this._permissionsService.has(Roles.notifications.write),
label: _('notifications.label'),
helpModeKey: 'notification_preferences',
},
{
screen: 'preferences',
label: _('preferences-screen.label'),
show: this.currentUser.isUser,
helpModeKey: 'user_preferences',
},
{
screen: 'warnings-preferences',
label: _('preferences-screen.warnings-label'),
show: this.currentUser.isUser,
helpModeKey: 'prompts_and_dialogs',
},
];
constructor(private readonly _permissionsService: IqserPermissionsService) {}
}