import { AfterViewInit, Component, Inject } from '@angular/core'; import { WPT_DIALOG_DATA, WptDialogRef } from '@arrow/warpaint/dialog'; import { AnalyticsService, AnalyticsEvent, BomService } from '@arrow/bom/core'; @Component({ templateUrl: './ask-engineer-modal.component.html', styleUrls: ['./ask-engineer-modal.component.scss'] }) export class AskEngineerModalComponent implements AfterViewInit { message = ''; constructor( public dialogRef: WptDialogRef, @Inject(WPT_DIALOG_DATA) public data: any, private bomService: BomService, public analyticsService: AnalyticsService ) {} ngAfterViewInit(): void { this.dialogRef.beforeClosed().subscribe(message => { if (message) { this.analyticsService.googleTrackEvent(AnalyticsEvent.CLICK, { category: 'BOM', action: 'Ask an engineer', label: 'Submit' }); this.bomService.askEngineerMessage(message); } else { this.analyticsService.googleTrackEvent(AnalyticsEvent.CLICK, { category: 'BOM', action: 'Ask an engineer', label: 'Close' }); } }); } }