import { Component, EventEmitter, Input, Output } from '@angular/core'; import { MatDialog } from '@angular/material/dialog'; import { WarnDialogComponent } from 'src/app/modules/warn-dialog/warn-dialog.component'; import { HumanView as AuthHumanView, UserState as AuthUserState } from 'src/app/proto/generated/auth_pb'; import { HumanView as MgmtHumanView, UserState as MgmtUserState } from 'src/app/proto/generated/management_pb'; import { CodeDialogComponent } from '../auth-user-detail/code-dialog/code-dialog.component'; import { EditDialogType } from '../user-detail/user-detail.component'; @Component({ selector: 'app-contact', templateUrl: './contact.component.html', styleUrls: ['./contact.component.scss'], }) export class ContactComponent { @Input() disablePhoneCode: boolean = false; @Input() canWrite: boolean = false; @Input() human!: AuthHumanView.AsObject | MgmtHumanView.AsObject; @Input() state!: AuthUserState | MgmtUserState; @Output() editType: EventEmitter = new EventEmitter(); @Output() resendEmailVerification: EventEmitter = new EventEmitter(); @Output() resendPhoneVerification: EventEmitter = new EventEmitter(); @Output() enteredPhoneCode: EventEmitter = new EventEmitter(); @Output() deletedPhone: EventEmitter = new EventEmitter(); @Input() public userStateEnum: any; public EditDialogType: any = EditDialogType; constructor(private dialog: MatDialog) { } emitDeletePhone(): void { const dialogRef = this.dialog.open(WarnDialogComponent, { data: { confirmKey: 'ACTIONS.DELETE', cancelKey: 'ACTIONS.CANCEL', titleKey: 'USER.LOGINMETHODS.PHONE.DELETETITLE', descriptionKey: 'USER.LOGINMETHODS.PHONE.DELETEDESC', }, width: '400px', }); dialogRef.afterClosed().subscribe(resp => { if (resp) { this.deletedPhone.emit(); } }); } emitEmailVerification(): void { this.resendEmailVerification.emit(); } emitPhoneVerification(): void { this.resendPhoneVerification.emit(); } public enterCode(): void { if (this.human) { const dialogRef = this.dialog.open(CodeDialogComponent, { data: { number: this.human.phone, }, width: '400px', }); dialogRef.afterClosed().subscribe(code => { if (code) { this.enteredPhoneCode.emit(code); } }); } } public openEditDialog(type: EditDialogType): void { this.editType.emit(type); } }