import { Component, Input, OnInit } from '@angular/core'; import { SpinnerService } from '@core/services/spinner.service'; import { CommunicationsService } from '@features/communications/communications.service'; import { Communication } from '@features/communications/communications.typing'; import { YCModalComponent } from '@yourcause/common/modals'; @Component({ selector: 'gc-communications-modal', templateUrl: './communications-modal.component.html', styleUrls: ['./communications-modal.component.scss'] }) export class CommunicationsModalComponent extends YCModalComponent implements OnInit { @Input() isNomination = false; @Input() applicationId: number; hideModal = false; constructor ( private communicationsService: CommunicationsService, private spinnerService: SpinnerService ) { super(); } get allComms () { return this.communicationsService.applicationCommunicationsMap[this.applicationId]; } get currentComm () { return this.allComms ? this.allComms[0] : {} as Communication[]; } async ngOnInit () { this.spinnerService.startSpinner(); await this.communicationsService.getCommunicationsForApplication( this.applicationId, true ); this.spinnerService.stopSpinner(); } async sendInviteEmail (comm: Communication) { this.spinnerService.startSpinner(); await this.communicationsService.handleSendInviteEmail( comm, this.applicationId ); await this.communicationsService.getCommunicationsForApplication( this.applicationId, true ); this.spinnerService.stopSpinner(); } }