mirror of
https://github.com/ever-co/ever-gauzy.git
synced 2026-10-02 01:54:50 +08:00
fix: login components to handle workspace navigation and state
This commit is contained in:
+4
-4
@@ -46,7 +46,7 @@ export class NgxLoginWorkspaceComponent implements OnInit {
|
||||
private readonly _router: Router
|
||||
) {
|
||||
const navigation = this._router.getCurrentNavigation();
|
||||
this.state = navigation?.extras?.state as { email: string; password: string };
|
||||
this.state = navigation?.extras?.state;
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
@@ -166,9 +166,9 @@ export class NgxLoginWorkspaceComponent implements OnInit {
|
||||
|
||||
private handleWorkspaceNavigation(): void {
|
||||
if (this.state) {
|
||||
if (!this.state.email || !this.state.password) return;
|
||||
this.form.patchValue(this.state);
|
||||
this.onSubmit();
|
||||
this.workspaces = this.state.workspaces;
|
||||
this.showPopup = this.state.show_popup;
|
||||
this.confirmedEmail = this.state.confirmed_email;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,9 +6,9 @@ import { NB_AUTH_OPTIONS, NbAuthService, NbLoginComponent } from '@nebular/auth'
|
||||
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
|
||||
import { catchError, EMPTY, tap } from 'rxjs';
|
||||
import { AuthService } from '../auth';
|
||||
import { GAUZY_ENV } from '../constants';
|
||||
import { ElectronService } from '../electron/services';
|
||||
import { LanguageElectronService } from '../language/language-electron.service';
|
||||
import { GAUZY_ENV } from '../constants';
|
||||
import { ErrorHandlerService } from '../services';
|
||||
|
||||
@UntilDestroy({ checkProperties: true })
|
||||
@@ -63,21 +63,28 @@ export class NgxLoginComponent extends NbLoginComponent implements OnInit {
|
||||
}
|
||||
}),
|
||||
// Update component state with the fetched workspaces
|
||||
tap(async ({ total_workspaces }: IUserSigninWorkspaceResponse) => {
|
||||
/** */
|
||||
if (total_workspaces === 1) {
|
||||
super.login();
|
||||
} else {
|
||||
const extra: NavigationExtras = {
|
||||
state: {
|
||||
email,
|
||||
password
|
||||
}
|
||||
};
|
||||
await this.router.navigate(['/', 'auth', 'login-workspace'], extra);
|
||||
this.submitted = false;
|
||||
tap(
|
||||
async ({
|
||||
workspaces,
|
||||
show_popup,
|
||||
total_workspaces,
|
||||
confirmed_email
|
||||
}: IUserSigninWorkspaceResponse) => {
|
||||
if (total_workspaces === 1) {
|
||||
super.login();
|
||||
} else {
|
||||
const extra: NavigationExtras = {
|
||||
state: {
|
||||
confirmed_email,
|
||||
workspaces,
|
||||
show_popup
|
||||
}
|
||||
};
|
||||
await this.router.navigate(['/', 'auth', 'login-workspace'], extra);
|
||||
this.submitted = false;
|
||||
}
|
||||
}
|
||||
}),
|
||||
),
|
||||
catchError((error) => {
|
||||
this.submitted = false;
|
||||
// Handle and log errors using the error handling service
|
||||
|
||||
Reference in New Issue
Block a user