Skip to content
Snippets Groups Projects
Commit 541949e7 authored by Etienne LOUPIAS's avatar Etienne LOUPIAS
Browse files

improve test patch

parent 24d7c882
No related branches found
No related tags found
2 merge requests!993Draft: Notif,!983feat(dashboard) : create dashboard !
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { User } from '../../../models/user.model';
import { NotificationService } from '../../../services/notification.service';
import { OrientationService } from '../../../services/orientation.service';
import { ProfileService } from '../../services/profile.service';
@Component({
selector: 'app-orientation-details',
......@@ -13,10 +15,12 @@ export class OrientationDetailsComponent implements OnInit {
private route: ActivatedRoute,
public orientationService: OrientationService,
private notificationService: NotificationService,
private profileService: ProfileService,
) {}
public orientation;
public isModalOpenned = false;
public userProfile: User;
ngOnInit(): void {
this.route.params.subscribe((urlParams) => {
......@@ -27,6 +31,9 @@ export class OrientationDetailsComponent implements OnInit {
});
}
});
this.profileService.getProfile().then((profile) => {
this.userProfile = new User(profile);
});
}
public goBack(): void {
......@@ -40,29 +47,34 @@ export class OrientationDetailsComponent implements OnInit {
public closeOrientation(event): void {
if (event) {
// close orientation
// wip test patch
this.orientationService.patchOrientation(this.orientation._id, { status: 'completed' }).subscribe({
next: (orientation) => {
this.notificationService.showSuccess("L'orientation a bien été mise à jour.");
// Update the status displayed on the orientation details page
this.orientation.status = orientation.status;
// After the successful update, close the modal
this.isModalOpenned = false;
},
error: () => {
this.notificationService.showErrorPleaseRetry(
"Une erreur s'est produite lors de la mise à jour de l'orientation.",
);
},
this.patchOrientation({
status: 'completed',
closingComment: 'closing comment',
closingUser: this.userProfile._id,
closingDate: new Date(),
});
} else {
this.isModalOpenned = false;
}
this.isModalOpenned = false;
}
public setOrientationStatus(status): void {
// set status
console.log(status);
}
private patchOrientation(updatedFields): void {
this.orientationService.patchOrientation(this.orientation._id, updatedFields).subscribe({
next: (orientation) => {
this.notificationService.showSuccess("L'orientation a bien été mise à jour.");
// Display the updated values on the orientation details page
this.orientation = orientation;
},
error: () => {
this.notificationService.showErrorPleaseRetry(
"Une erreur s'est produite lors de la mise à jour de l'orientation.",
);
},
});
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment