import { Component, Input, OnInit } from '@angular/core'; import { PaymentStats } from '@core/typings/application.typing'; import { AnalyticsService, EventType } from '@yourcause/common/analytics'; import { I18nService } from '@yourcause/common/i18n'; import { YCModalComponent } from '@yourcause/common/modals'; @Component({ selector: 'gc-delete-application-modal', templateUrl: './delete-application-modal.component.html', styleUrls: ['./delete-application-modal.component.scss'] }) export class DeleteApplicationModalComponent extends YCModalComponent implements OnInit { @Input() applicationId: number; @Input() appCanBeDeleted: boolean; @Input() applicationPaymentStats: PaymentStats; @Input() isNomination: boolean; recordText: string; desiredDeleteText = this.i18n.translate('common:btnDelete', {}, 'Delete').toUpperCase(); currentDeleteText: string; constructor ( private i18n: I18nService, private analyticsService: AnalyticsService ) { super(); } ngOnInit () { this.recordText = this.isNomination ? this.i18n.translate('FORMS:textNomination', {}, 'Nomination') : this.i18n.translate('common:lblApplication', {}, 'Application'); } onSubmit () { if (this.appCanBeDeleted) { if (this.currentDeleteText === this.desiredDeleteText) { this.closeModal.emit(true); } this.analyticsService.emitEvent({ eventName: 'Delete app modal submit', eventType: EventType.Click, extras: null }); } else { this.onCancel(); } } onCancel () { this.closeModal.emit(false); } }