import { Component , ChangeDetectorRef , Input , Output , EventEmitter , } from '@angular/core' ; import { WalletV2Service } from '../../../wallet-v2.service' ; import { Client , Upload } from '../../../../../../services/api' ; @ Component ( { selector : 'm-walletCashOnboardingExtras' , templateUrl : './cash-onboarding-extras.component.html' , } ) export class WalletCashOnboardingExtrasComponent { @ Input ( ) account ; @ Input ( ) allowedCountries : string [ ] ; @ Output ( ) submitted : EventEmitter < any > = new EventEmitter ( ) ; inProgress : boolean ; error : string = '' ; constructor ( protected walletService , private client , private cd , private upload ) { } async uploadDocument ( fileInput , documentType ) { const file = fileInput ? fileInput . files [ 0 ] : null ; this . inProgress = true ; this . detectChanges ( ) ; const response = await this . upload . post ( 'api/v2/payments/stripe/connect/document/' + documentType , [ file ] ) ; this . handleResponse ( response ) ; } async updateField ( fieldName , value ) { this . inProgress = true ; this . detectChanges ( ) ; let body = { } ; body [ fieldName ] = value ; const response = await this . client . post ( 'api/v2/payments/stripe/connect/update' , body ) ; this . handleResponse ( response ) ; } async acceptTos ( ) { this . inProgress = true ; this . detectChanges ( ) ; const response = await this . client . put ( 'api/v2/payments/stripe/connect/terms' ) ; this . handleResponse ( response ) ; } handleResponse ( response ) { if ( response . status === 'error' ) { this . error = response . message ; this . inProgress = false ; this . detectChanges ( ) ; } else { this . submitted . emit ( ) ; } } detectChanges ( ) { this . cd . markForCheck ( ) ; this . cd . detectChanges ( ) ; } }