import { Component , Injector , OnInit } from '@angular/core' ; import { PlusService } from '../../plus/plus.service' ; import { WireModalService } from '../../wire/wire-modal.service' ; import { WireEventType } from '../../wire/v2/wire-v2.service' ; import { WirePaymentHandlersService } from '../../wire/wire-payment-handlers.service' ; import { Session } from '../../../services/session' ; import { ComposerService } from '../../composer/services/composer.service' ; import { ModalService } from '../../composer/components/modal/modal.service' ; import { ConfigsService } from '../../../common/services/configs.service' ; @ Component ( { selector : 'm-discovery__plusUpgrade' , templateUrl : './plus-upgrade.component.html' , styleUrls : [ './plus-upgrade.component.ng.scss' ] , providers : [ ComposerService ] , } ) export class DiscoveryPlusUpgradeComponent implements OnInit { isPlus : boolean = false ; constructor ( private plusService , private wireModal , private wirePaymentHandlers , private session , private configs , private composerService , private composerModal , private injector ) { } ngOnInit ( ) { this . setup ( ) ; } async setup ( ) { this . isPlus = this . session . getLoggedInUser ( ) . plus ; this . isPlus = await this . plusService . isActive ( ) ; } async showUpgradeModal ( ) { const plusGuid = await this . wirePaymentHandlers . get ( 'plus' ) ; const wireEvent = await this . wireModal . present ( plusGuid , { default : { type : 'money' , upgradeType : 'plus' , } , } ) . toPromise ( ) ; if ( wireEvent . type === WireEventType . Completed ) { this . isPlus = true ; } } openComposerWithPlus ( ) { const plusSupportTierUrn = this . configs . get ( 'plus' ) . support_tier_urn || 'urn:support-tier:plus' ; const support_tier = { urn : plusSupportTierUrn , } ; this . composerService . pendingMonetization$ . next ( { type : 'plus' , support_tier : support_tier , } ) ; this . composerModal . setInjector ( this . injector ) . present ( ) . toPromise ( ) ; } }