Display new user data if user updatet the data (tried with another email)

pull/7995/head
Inga Mai 5 years ago
parent 5f422e46d9
commit 99f6339a65
  1. 25
      frontend/src/app/components/enterprise/enterprise-active-trial/ee-active-trial.component.ts
  2. 2
      frontend/src/app/components/enterprise/enterprise-modal/enterprise-trial.modal.ts
  3. 7
      frontend/src/app/components/enterprise/enterprise-trial.service.ts

@ -26,10 +26,11 @@
// See docs/COPYRIGHT.rdoc for more details.
// ++
import {Component, ElementRef, OnInit} from "@angular/core";
import {ChangeDetectorRef, Component, ElementRef, OnInit} from "@angular/core";
import {distinctUntilChanged} from "rxjs/operators";
import {UntilDestroyedMixin} from "core-app/helpers/angular/until-destroyed.mixin";
import {I18nService} from "app/modules/common/i18n/i18n.service";
import {baseUrlAugur, EnterpriseTrialService} from "app/components/enterprise/enterprise-trial.service";
import {DynamicBootstrapper} from "core-app/globals/dynamic-bootstrapper";
import {HttpClient, HttpErrorResponse} from "@angular/common/http";
export const enterpriseActiveTrialSelector = 'enterprise-active-trial';
@ -39,7 +40,7 @@ export const enterpriseActiveTrialSelector = 'enterprise-active-trial';
templateUrl: './ee-active-trial.component.html',
styleUrls: ['./ee-active-trial.component.sass']
})
export class EEActiveTrialComponent implements OnInit {
export class EEActiveTrialComponent extends UntilDestroyedMixin implements OnInit {
public text = {
label_email: this.I18n.t('js.admin.enterprise.trial.form.label_email'),
label_expires_at: this.I18n.t('js.admin.enterprise.trial.form.label_expires_at'),
@ -55,13 +56,26 @@ export class EEActiveTrialComponent implements OnInit {
public expiresAt = this.elementRef.nativeElement.dataset['expiresAt'];
constructor(readonly elementRef:ElementRef,
readonly cdRef:ChangeDetectorRef,
readonly I18n:I18nService,
protected http:HttpClient,
public eeTrialService:EnterpriseTrialService) {
super();
}
ngOnInit() {
if (!this.subscriber) {
this.eeTrialService.userData$
.pipe(
distinctUntilChanged(),
this.untilDestroyed()
)
.subscribe(data => {
this.subscriber = data.subscriber;
this.email = data.email;
this.cdRef.detectChanges();
});
this.initialize();
}
}
@ -69,13 +83,10 @@ export class EEActiveTrialComponent implements OnInit {
private initialize():void {
let eeTrialKey = this.loadGonData();
if (eeTrialKey) {
if (eeTrialKey && !this.eeTrialService.userData) {
// after reload: get data from Augur using the trial key saved in gon
this.eeTrialService.trialLink = baseUrlAugur + '/public/v1/trials/' + eeTrialKey.value;
this.getUserDataFromAugur();
} else {
this.subscriber = this.eeTrialService.userData.subscriber;
this.email = this.eeTrialService.userData.email;
}
}

@ -98,7 +98,7 @@ export class EnterpriseTrialModal extends OpModalComponent implements AfterViewI
public headerText() {
if (this.eeTrialService.mailSubmitted) {
return this.text.heading_confirmation;
} else if(this.eeTrialService.trialStarted) {
} else if (this.eeTrialService.trialStarted) {
return this.text.heading_next_steps;
} else {
return this.text.heading_test_ee;

@ -4,11 +4,15 @@ import {HttpClient, HttpErrorResponse} from "@angular/common/http";
import {PathHelperService} from "core-app/modules/common/path-helper/path-helper.service";
import {NotificationsService} from "core-app/modules/common/notifications/notifications.service";
import {FormGroup} from "@angular/forms";
import {BehaviorSubject} from 'rxjs';
export const baseUrlAugur = 'https://augur.openproject-edge.com';
@Injectable()
export class EnterpriseTrialService {
// user data needs to be sync in ee-active-trial.component.ts
private userDataSubject = new BehaviorSubject<any>({});
public userData$ = this.userDataSubject.asObservable();
public userData:{subscriber:string, email:string};
public trialLink:string;
@ -36,11 +40,14 @@ export class EnterpriseTrialService {
subscriber: form.value.first_name + ' ' + form.value.last_name,
email: form.value.email
};
this.userDataSubject.next(this.userData);
this.cancelled = false;
this.http.post(baseUrlAugur + '/public/v1/trials', form.value)
.toPromise()
.then((enterpriseTrial:any) => {
this.trialLink = enterpriseTrial._links.self.href;
this.saveTrialKey(this.trialLink);
this.retryConfirmation();
})

Loading…
Cancel
Save