diff --git a/src/app/@theme/components/header/header.component.ts b/src/app/@theme/components/header/header.component.ts index 4ab086a4..5b669eda 100644 --- a/src/app/@theme/components/header/header.component.ts +++ b/src/app/@theme/components/header/header.component.ts @@ -6,6 +6,7 @@ import { LayoutService } from '../../../@core/utils'; import { map, takeUntil } from 'rxjs/operators'; import { Subject } from 'rxjs'; import { AuthService } from '../../../service/auth.service'; +import { Router } from '@angular/router'; @Component({ selector: 'ngx-header', @@ -47,7 +48,8 @@ export class HeaderComponent implements OnInit, OnDestroy { private userService: UserData, private layoutService: LayoutService, private breakpointService: NbMediaBreakpointsService, - private authService: AuthService) { + private authService: AuthService, + private router: Router) { } ngOnInit() { @@ -75,6 +77,8 @@ export class HeaderComponent implements OnInit, OnDestroy { this.menuService.onItemClick().subscribe((event: { item: NbMenuItem }) => { if (event.item.title === 'Log out') { this.logout(); + } else if (event.item.title === 'Profile') { + this.router.navigate(['/pages/layout/stepper/profile']); // Redirect to profile page } }); } diff --git a/src/app/pages/layout/stepper/profile/profile.component.html b/src/app/pages/layout/stepper/profile/profile.component.html index 87bd1fec..59dd87a4 100644 --- a/src/app/pages/layout/stepper/profile/profile.component.html +++ b/src/app/pages/layout/stepper/profile/profile.component.html @@ -77,10 +77,12 @@

Certifications

diff --git a/src/app/pages/layout/stepper/profile/profile.component.ts b/src/app/pages/layout/stepper/profile/profile.component.ts index 1779994e..01726b21 100644 --- a/src/app/pages/layout/stepper/profile/profile.component.ts +++ b/src/app/pages/layout/stepper/profile/profile.component.ts @@ -23,10 +23,13 @@ export class ProfileComponent implements OnInit { this.route.queryParams.subscribe((params) => { const userId = params['userId']; // Get the userId from query params + console.log(userId); + if (userId) { this.userAPI.getUserDetails(userId).subscribe((response) => { if (response.success) { this.userDetails = response.data; + console.log(this.userDetails) this.userExperiences = this.userDetails.experiences || []; this.userEducation = this.userDetails.education || []; this.userProjects = this.userDetails.projects || []; diff --git a/src/app/pages/layout/stepper/stepper.component.ts b/src/app/pages/layout/stepper/stepper.component.ts index 3343b95e..8c5c231a 100644 --- a/src/app/pages/layout/stepper/stepper.component.ts +++ b/src/app/pages/layout/stepper/stepper.component.ts @@ -1,6 +1,6 @@ import { Component, OnInit } from '@angular/core'; import { FormBuilder, FormGroup } from '@angular/forms'; -import { Router, NavigationExtras } from '@angular/router'; +import { Router } from '@angular/router'; import { UserAPI } from '../../../service/api/user-api.service'; @@ -99,26 +99,18 @@ export class StepperComponent implements OnInit { // Save personal details including professional summary const userDetailsResponse = await this.userAPI.saveUserDetails(personalDetailsWithSummary).toPromise(); this.userId = userDetailsResponse.data.id; - - console.log(this.userId) // Save other details using the obtained user ID - await Promise.all([ - this.userAPI.saveExperience(this.experience.value, this.userId).toPromise(), - this.userAPI.saveEducation(this.education.value, this.userId).toPromise(), - this.userAPI.saveProjects(this.project.value, this.userId).toPromise(), - this.userAPI.saveSkills(this.skills.value, this.userId).toPromise(), - this.userAPI.saveCertifications(this.certifications.value, this.userId).toPromise() - ]); + await this.userAPI.saveExperience(this.experience.value, this.userId).toPromise(); + await this.userAPI.saveEducation(this.education.value, this.userId).toPromise(); + await this.userAPI.saveProjects(this.project.value, this.userId).toPromise(); + await this.userAPI.saveSkills(this.skills.value, this.userId).toPromise(); + await this.userAPI.saveCertifications(this.certifications.value, this.userId).toPromise(); console.log("userID: ", this.userId) - // Navigate to the profile page - const navigationExtras: NavigationExtras = { - queryParams: { userId: this.userId } - }; - this.router.navigateByUrl('/pages/layout/stepper/profile', navigationExtras); + this.router.navigateByUrl(`/pages/layout/stepper/profile?userId=${this.userId}`); } catch (error) { console.error('Error occurred while saving user details:', error); // Handle error diff --git a/src/app/service/api/user-api.service.ts b/src/app/service/api/user-api.service.ts index e94d7c55..9ff3025c 100644 --- a/src/app/service/api/user-api.service.ts +++ b/src/app/service/api/user-api.service.ts @@ -22,37 +22,31 @@ export class UserAPI { // Get single user getUserDetails(userId: string): Observable { - console.log(userId) const headers = new HttpHeaders().set('Authorization', `Bearer ${this.token}`); return this.http.get(`${this.baseUrl}/users/${userId}`, { headers }); } saveExperience(data: any, userId: string): Observable { - console.log(userId) const headers = new HttpHeaders().set('Authorization', `Bearer ${this.token}`); return this.http.post(`${this.baseUrl}/experiences?userId=${userId}`, data, { headers }); } saveEducation(data: any, userId: string): Observable { - console.log(userId) const headers = new HttpHeaders().set('Authorization', `Bearer ${this.token}`); return this.http.post(`${this.baseUrl}/education?userId=${userId}`, data, { headers }); } saveProjects(data: any, userId: string): Observable { - console.log(userId) const headers = new HttpHeaders().set('Authorization', `Bearer ${this.token}`); return this.http.post(`${this.baseUrl}/projects?userId=${userId}`, data, { headers }); } saveSkills(data: any, userId: string): Observable { - console.log(userId) const headers = new HttpHeaders().set('Authorization', `Bearer ${this.token}`); return this.http.post(`${this.baseUrl}/skills?userId=${userId}`, data, { headers }); } saveCertifications(data: any, userId: string): Observable { - console.log(userId) const headers = new HttpHeaders().set('Authorization', `Bearer ${this.token}`); return this.http.post(`${this.baseUrl}/certifications?userId=${userId}`, data, { headers }); } diff --git a/src/app/service/auth.service.ts b/src/app/service/auth.service.ts index c097ef6e..7f763738 100644 --- a/src/app/service/auth.service.ts +++ b/src/app/service/auth.service.ts @@ -1,15 +1,12 @@ import { Injectable } from '@angular/core'; import { AngularFireAuth } from '@angular/fire/compat/auth'; import { Router } from '@angular/router'; - import { Observable } from 'rxjs'; - @Injectable({ providedIn: 'root' }) export class AuthService { - user$: Observable; constructor(private fireAuth: AngularFireAuth, private router: Router) {