import { Component, Input, OnInit } from '@angular/core'; import { Validators } from '@angular/forms'; import { TypeSafeFormBuilder, TypeSafeFormGroup } from '@yourcause/common'; import { AnalyticsService, EventType } from '@yourcause/common/analytics'; import { YCModalComponent } from '@yourcause/common/modals'; interface WorkflowDetailsModalResponse { workflowName: string; workflowDescription: string; } @Component({ selector: 'gc-workflow-details-modal', templateUrl: './workflow-details-modal.component.html', styleUrls: ['./workflow-details-modal.component.scss'] }) export class WorkflowDetailsModalComponent extends YCModalComponent< WorkflowDetailsModalResponse > implements OnInit { @Input() isNew = false; @Input() name: string; @Input() description: string; formGroup: TypeSafeFormGroup; constructor ( private formBuilder: TypeSafeFormBuilder, private analyticsService: AnalyticsService ) { super(); } ngOnInit () { this.formGroup = this.formBuilder.group({ workflowName: [this.name, Validators.required], workflowDescription: [this.description, Validators.required] }); } handlePrimaryClick () { this.closeModal.emit(this.formGroup.value); this.analyticsService.emitEvent({ eventName: 'Save workflow details', eventType: EventType.Click, extras: null }); } }