import { Component , OnInit , ViewChild } from '@angular/core' ; import { RolesEnum , IUser } from '@gauzy/contracts' ; import { NbDialogRef } from '@nebular/theme' ; import { Store , ToastrService } from '../../../@core/services' ; import { BasicInfoFormComponent } from '../forms/basic-info/basic-info-form.component' ; @ Component ( { selector : 'ga-user-mutation' , templateUrl : './user-mutation.component.html' , styleUrls : [ './user-mutation.component.scss' ] } ) export class UserMutationComponent implements OnInit { @ ViewChild ( 'userBasicInfo' ) userBasicInfo : BasicInfoFormComponent ; constructor ( protected readonly dialogRef , protected readonly store , private readonly toastrService ) { } ngOnInit ( ) { } closeDialog ( user = null ) { this . dialogRef . close ( { user } ) ; } async add ( ) { try { const organization = this . store . selectedOrganization ; const user = await this . userBasicInfo . registerUser ( RolesEnum . VIEWER , organization . id , this . store . userId ) ; this . closeDialog ( user ) ; } catch ( error ) { this . toastrService . danger ( error ) ; } } }