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';

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,
})
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) {}
}
