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'; export interface ManageFilterFormGroup { filterName: string; } @Component({ selector: 'gc-manage-filter-modal', templateUrl: './manage-filter-modal.component.html', styleUrls: ['./manage-filter-modal.component.scss'] }) export class ManageFilterModalComponent extends YCModalComponent< ManageFilterFormGroup > implements OnInit { @Input() name: string; formGroup: TypeSafeFormGroup; constructor ( private formBuilder: TypeSafeFormBuilder, private analyticsService: AnalyticsService ) { super(); } ngOnInit () { this.formGroup = this.formBuilder.group({ filterName: [ this.name ?? '', Validators.required ] }); } handlePrimaryClick () { this.closeModal.emit(this.formGroup.value); this.analyticsService.emitEvent({ eventName: 'Manage filter modal save', eventType: EventType.Click, extras: null }); } }