import {Component, inject, OnInit} from '@angular/core';
import {VERSION} from 'app/app.constants';
import {AccountService} from 'app/core/auth/account.service';
import {Account} from 'app/core/auth/account.model';
import {EntityNavbarItems} from 'app/entities/entity-navbar-items';
import AdminSidebarItems from 'app/admin/sidebar.items';

@Component({
    templateUrl: 'sidebar.component.html',
    styleUrls: ['sidebar.component.scss'],
})
export class SidebarComponent implements OnInit {
    version = '';
    account: Account | null = null;

    protected readonly entities = EntityNavbarItems;
    protected entitiesOpen = false;
    protected readonly adminItems = AdminSidebarItems;
    protected adminItemsOpen = false;
    private accountService = inject(AccountService);

    constructor() {
        // TODO: this is site version
        if (VERSION) {
            this.version = VERSION.toLowerCase().startsWith('v') ? VERSION : `v${VERSION}`;
        }
    }

    ngOnInit() {
        this.accountService.getAuthenticationState().subscribe(account => {
            this.account = account;
        });
    }
}
