import { Component, EventEmitter, Input, Output } from '@angular/core';
import { RouterExtensions } from '@nativescript/angular';
import { ImageSource } from '@nativescript/core/image-source';
import { transitionOptions } from '~/constants/shared.constants';
import { LoginDataService } from '~/core/services/login-data.service';

@Component({
    selector: 'ProfileSection',
    moduleId: module.id,
    templateUrl: './profile-section.component.html',
    styleUrls: ['./_profile-section.component.scss']
})
export class ProfileSectionComponent {
    @Input()
    personPhotoResource: ImageSource;

    @Input()
    userData: any = null;
    @Output()
    routeChange = new EventEmitter<boolean>();

    @Output()
    handleUserRoleTap = new EventEmitter();

    constructor(
        private routerExtensions: RouterExtensions,
        private loginDataSrv: LoginDataService) {
    }

    async onUserRoleTap() {
        this.handleUserRoleTap.emit();
    }

    onPhotoTap(userId: number): void {
        this.routeChange.emit(true)
        setTimeout(() => {
            this.routerExtensions.navigate(['search/list/', userId, false], { transition: transitionOptions });
        }, 10);
    }
}
