import { ChangeDetectionStrategy, Component, OnInit, ViewContainerRef } from '@angular/core';
import { Router } from '@angular/router';
import { accountTranslations } from '@translations/account-translations';

@Component({
    selector: 'redaction-base-account-screen',
    templateUrl: './base-account-screen-component.html',
    styleUrls: ['./base-account-screen-component.scss'],
    changeDetection: ChangeDetectionStrategy.OnPush,
})
export class BaseAccountScreenComponent implements OnInit {
    readonly translations = accountTranslations;
    readonly path: string;

    constructor(private readonly _router: Router, private readonly _hostRef: ViewContainerRef) {
        this.path = this._router.url.split('/').pop();
    }

    ngOnInit(): void {
        this._setDialogWidth();
    }

    private _setDialogWidth() {
        const element = this._hostRef.element.nativeElement as HTMLElement;
        element.style.setProperty('--width', this.path === 'user-profile' ? 'unset' : '100%');
    }
}
