mirror of
https://github.com/akveo/ngx-admin.git
synced 2025-12-16 15:40:11 +01:00
Profile creation part completed
This commit is contained in:
parent
f75e93e3eb
commit
f0a980b182
6 changed files with 21 additions and 29 deletions
|
|
@ -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
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,10 +77,12 @@
|
|||
<h2>Certifications</h2>
|
||||
<ul>
|
||||
<li *ngFor="let cert of userCertificates">
|
||||
<p><strong>Certificate Name:</strong> {{ cert.certificateName }}</p>
|
||||
<p><strong>Issuer:</strong> {{ cert.certificateIssuer }}</p>
|
||||
<p><strong>Year:</strong> {{ cert.certificateYear }}</p>
|
||||
<p><strong>Relevance:</strong> {{ cert.certificateRelevance }}</p>
|
||||
<p><strong>Certificate Name:</strong> {{ cert.name }}</p>
|
||||
<p><strong>Issuer:</strong> {{ cert.issuer }}</p>
|
||||
<p>
|
||||
<strong>Date:</strong> {{ cert.startDate }} - {{ cert.endDate }}
|
||||
</p>
|
||||
<p><strong>Relevance:</strong> {{ cert.description }}</p>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -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 || [];
|
||||
|
|
|
|||
|
|
@ -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';
|
||||
|
||||
|
|
@ -100,25 +100,17 @@ export class StepperComponent implements OnInit {
|
|||
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
|
||||
|
|
|
|||
|
|
@ -22,37 +22,31 @@ export class UserAPI {
|
|||
|
||||
// Get single user
|
||||
getUserDetails(userId: string): Observable<any> {
|
||||
console.log(userId)
|
||||
const headers = new HttpHeaders().set('Authorization', `Bearer ${this.token}`);
|
||||
return this.http.get<any>(`${this.baseUrl}/users/${userId}`, { headers });
|
||||
}
|
||||
|
||||
saveExperience(data: any, userId: string): Observable<any> {
|
||||
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<any> {
|
||||
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<any> {
|
||||
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<any> {
|
||||
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<any> {
|
||||
console.log(userId)
|
||||
const headers = new HttpHeaders().set('Authorization', `Bearer ${this.token}`);
|
||||
return this.http.post(`${this.baseUrl}/certifications?userId=${userId}`, data, { headers });
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<firebase.default.User | null>;
|
||||
|
||||
constructor(private fireAuth: AngularFireAuth, private router: Router) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue