import { Component, Input, OnChanges } from '@angular/core'; import { PaymentType, ProcessingTypes } from '@core/typings/payment.typing'; import { PaymentStatus } from '@core/typings/status.typing'; @Component({ selector: 'gc-payment-type-display', templateUrl: './payment-type-display.component.html', styleUrls: ['./payment-type-display.component.scss'] }) export class PaymentTypeDisplayComponent implements OnChanges { @Input() paymentType: PaymentType; @Input() paymentStatus: PaymentStatus; @Input() processorType: ProcessingTypes; @Input() showPaymentTypePrefix: boolean; @Input() isInKind = false; // do not display for in kind payments showPaymentType = false; ngOnChanges () { // If client processed, always show payment type // If YC processed, only in certain statuses const isValidYcStatus = ![ PaymentStatus.Pending, PaymentStatus.Scheduled, PaymentStatus.Processing, PaymentStatus.ProcessingHold ].includes(this.paymentStatus); this.showPaymentType = this.paymentType && !this.isInKind && ( isValidYcStatus || this.processorType === ProcessingTypes.Client ); } }