Skip to content

Commit

Permalink
Minor
Browse files Browse the repository at this point in the history
  • Loading branch information
bistaastha committed Jan 8, 2025
1 parent be9c210 commit caa94af
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions src/app/post-verification/invited-user/invited-user.page.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, EventEmitter, OnInit } from '@angular/core';
import { Observable, noop, concat, from } from 'rxjs';
import { Observable, noop, concat, from, forkJoin } from 'rxjs';
import { NetworkService } from 'src/app/core/services/network.service';
import { FormBuilder, FormGroup, ValidationErrors, Validators } from '@angular/forms';
import { switchMap, finalize, tap } from 'rxjs/operators';
Expand All @@ -12,6 +12,9 @@ import { TrackingService } from '../../core/services/tracking.service';
import { ToastMessageComponent } from 'src/app/shared/components/toast-message/toast-message.component';
import { MatSnackBar } from '@angular/material/snack-bar';
import { SnackbarPropertiesService } from 'src/app/core/services/snackbar-properties.service';
import { OrgSettingsService } from 'src/app/core/services/org-settings.service';
import { SpenderOnboardingService } from 'src/app/core/services/spender-onboarding.service';
import { OnboardingState } from 'src/app/core/models/onboarding-state.enum';

@Component({
selector: 'app-invited-user',
Expand Down Expand Up @@ -58,7 +61,9 @@ export class InvitedUserPage implements OnInit {
private router: Router,
private trackingService: TrackingService,
private matSnackBar: MatSnackBar,
private snackbarProperties: SnackbarPropertiesService
private snackbarProperties: SnackbarPropertiesService,
private orgSettingsService: OrgSettingsService,
private spenderOnboardingService: SpenderOnboardingService
) {}

ngOnInit(): void {
Expand Down Expand Up @@ -90,6 +95,23 @@ export class InvitedUserPage implements OnInit {
this.showPasswordTooltip = value;
}

navigateToDashboard(): void {
forkJoin([this.orgSettingsService.get(), this.spenderOnboardingService.getOnboardingStatus()]).subscribe(
([orgSettings, onboardingStatus]) => {
if (
(orgSettings.visa_enrollment_settings.enabled ||
orgSettings.mastercard_enrollment_settings.enabled ||
orgSettings.amex_feed_enrollment_settings.enabled) &&
onboardingStatus.state !== OnboardingState.COMPLETED
) {
this.router.navigate(['/', 'enterprise', 'spender_onboarding']);
} else {
this.router.navigate(['/', 'enterprise', 'my_dashboard']);
}
}
);
}

async saveData(): Promise<void> {
this.isLoading = true;
this.fg.markAllAsTouched();
Expand All @@ -113,8 +135,7 @@ export class InvitedUserPage implements OnInit {
})
)
.subscribe(() => {
this.router.navigate(['/', 'enterprise', 'my_dashboard']);
// return $state.go('enterprise.my_dashboard');
this.navigateToDashboard();
});
} else {
const message = `Please enter a valid ${!this.fg.controls.fullName.valid ? 'name' : 'password'}`;
Expand Down

0 comments on commit caa94af

Please sign in to comment.