diff --git a/src/app/core/user/user.service.ts b/src/app/core/user/user.service.ts index e118f83..9ae78fc 100644 --- a/src/app/core/user/user.service.ts +++ b/src/app/core/user/user.service.ts @@ -51,6 +51,8 @@ export class UserService { return this._httpClient.get(`${this._baseUrl}/user/${localStorage.getItem("userId")}`).pipe( tap((user) => { this._user.next(user); + console.log(user, "user logged in"); + }) ); } diff --git a/src/app/layout/common/notifications/notifications.component.html b/src/app/layout/common/notifications/notifications.component.html index bb6f16d..be23e59 100644 --- a/src/app/layout/common/notifications/notifications.component.html +++ b/src/app/layout/common/notifications/notifications.component.html @@ -38,7 +38,7 @@ (click)="markAllAsRead()"> + [svgIcon]="'heroicons_solid:bell'"> @@ -48,7 +48,7 @@
- + @@ -58,35 +58,33 @@ - +
+ [svgIcon]="'heroicons_outline:bell'">
-
+ - +
- -
+ +
- +
+ [innerHTML]="notification.Description">
- {{notification.time | date:'MMM dd, h:mm a'}} + {{notification.Date}}
diff --git a/src/app/layout/common/notifications/notifications.component.ts b/src/app/layout/common/notifications/notifications.component.ts index bf5346e..3e70f9f 100644 --- a/src/app/layout/common/notifications/notifications.component.ts +++ b/src/app/layout/common/notifications/notifications.component.ts @@ -42,20 +42,6 @@ export class NotificationsComponent implements OnInit, OnDestroy { * On init */ ngOnInit(): void { - // Subscribe to notification changes - this._notificationsService.notifications$ - .pipe(takeUntil(this._unsubscribeAll)) - .subscribe((notifications: Notification[]) => { - - // Load the notifications - this.notifications = []; - - // Calculate the unread count - this._calculateUnreadCount(); - - // Mark for check - this._changeDetectorRef.markForCheck(); - }); this.getNotificationsByUserId(); } @@ -210,7 +196,6 @@ export class NotificationsComponent implements OnInit, OnDestroy { this._notificationsService.getNotifications(queryParams).pipe(finalize(() => { })).subscribe((notifications: any) => { // Load the notifications this.notifications = notifications?.notifications; - console.log(notifications?.notifications); // // Calculate the unread count this._calculateUnreadCount(); diff --git a/src/app/layout/layouts/vertical/classy/classy.component.html b/src/app/layout/layouts/vertical/classy/classy.component.html index 5bc9b77..407456c 100644 --- a/src/app/layout/layouts/vertical/classy/classy.component.html +++ b/src/app/layout/layouts/vertical/classy/classy.component.html @@ -19,7 +19,7 @@
- +
diff --git a/src/app/layout/layouts/vertical/classy/classy.component.ts b/src/app/layout/layouts/vertical/classy/classy.component.ts index 2fb2bcb..d8771a5 100644 --- a/src/app/layout/layouts/vertical/classy/classy.component.ts +++ b/src/app/layout/layouts/vertical/classy/classy.component.ts @@ -63,8 +63,12 @@ export class ClassyLayoutComponent implements OnInit, OnDestroy { this._navigationService.navigation$ .pipe(takeUntil(this._unsubscribeAll)) .subscribe((navigation: Navigation) => { - const filterNavigation = navigation.default[0].children.filter(item => item.accessRole === this.user.role); + const filterNavigation = navigation.default[0].children.filter((item) => { + console.log(item.accessRole, this.user.role); + return item.accessRole === this.user.role; + }); navigation.default[0].children = filterNavigation; + console.log(navigation); this.navigation = navigation; }); diff --git a/src/app/modules/admin/dashboards/finance/finance.component.html b/src/app/modules/admin/dashboards/finance/finance.component.html index dc20cc8..0c6ce72 100644 --- a/src/app/modules/admin/dashboards/finance/finance.component.html +++ b/src/app/modules/admin/dashboards/finance/finance.component.html @@ -209,7 +209,7 @@

Pas d'historiques de rendez-vous - Start date is required + Le champ dete debut est requis @@ -220,7 +220,7 @@

Pas d'historiques de rendez-vous - End date is required + Le champ dete fin est requis diff --git a/src/app/modules/admin/dashboards/project/project.component.html b/src/app/modules/admin/dashboards/project/project.component.html index a9586a8..fb6a5b3 100644 --- a/src/app/modules/admin/dashboards/project/project.component.html +++ b/src/app/modules/admin/dashboards/project/project.component.html @@ -364,7 +364,7 @@

Services

-
+
Liste des services
@@ -379,6 +379,7 @@

Services

Aucun service trouvé

@@ -413,6 +414,20 @@

Aucun service trouvé

+ + + + + +
+ Commission + + {{s.commissionPercentage}}% + Aucun service trouvé Actions - + + + + diff --git a/src/app/modules/admin/dashboards/project/project.component.ts b/src/app/modules/admin/dashboards/project/project.component.ts index b25590b..d7f600d 100644 --- a/src/app/modules/admin/dashboards/project/project.component.ts +++ b/src/app/modules/admin/dashboards/project/project.component.ts @@ -7,7 +7,7 @@ import { ProjectService } from 'app/modules/admin/dashboards/project/project.ser import { UserService } from 'app/core/user/user.service'; import { User } from 'app/core/user/user.types'; import { FinanceService } from '../finance/finance.service'; -import { FormGroup } from '@angular/forms'; +import { FormBuilder, FormGroup, Validators } from '@angular/forms'; import { FuseAlertType } from '@fuse/components/alert'; @Component({ @@ -23,7 +23,6 @@ export class ProjectComponent implements OnInit, OnDestroy { chartMonthlyExpenses: ApexOptions = {}; chartYearlyExpenses: ApexOptions = {}; data: any; - selectedProject: string = 'ACME Corp. Backend App'; private _unsubscribeAll: Subject = new Subject(); user: User; employes: any; @@ -40,7 +39,10 @@ export class ProjectComponent implements OnInit, OnDestroy { Client: "/client/rendez-vous", Employee: "/employee/calendrier", Manager: "/manager/dashboard" - } + }; + configForm: FormGroup; + isEdit: boolean = false; + service: any; /** * Constructor @@ -49,7 +51,8 @@ export class ProjectComponent implements OnInit, OnDestroy { private _projectService: ProjectService, private _userService: UserService, private _financeService: FinanceService, - private _router: Router + private _router: Router, + private _formBuilder: FormBuilder, ) { } @@ -61,6 +64,12 @@ export class ProjectComponent implements OnInit, OnDestroy { * On init */ ngOnInit(): void { + this.serviceForm = this._formBuilder.group({ + name: ["", [Validators.required]], + price: ["", [Validators.required]], + processingTime: ["", [Validators.required]], + commissionPercentage: ["", [Validators.required]] + }); // Subscribe to the user service this._userService.user$ @@ -129,7 +138,7 @@ export class ProjectComponent implements OnInit, OnDestroy { this.loadingData = true; this._financeService.getAllServices().subscribe((res) => { this.services = { - columns: ["name", "price", "processingTime", "actions"], + columns: ["name", "price", "processingTime", "commissionPercentage", "actions"], rows: res }; }); @@ -144,8 +153,76 @@ export class ProjectComponent implements OnInit, OnDestroy { this.showDefault = true; this.serviceForm.reset(); this.showAlert = false; + this.isEdit = false; this.getAllServices(); } + + createService(): void { + if (this.serviceForm.invalid) { + return; + } + + this.serviceForm.disable(); + this.showAlert = false; + + this._projectService.createService(this.serviceForm.value).subscribe(() => { + window.scroll(0, 0); + this.alert = { + type: 'success', + message: 'Service créé avec succès' + }; + this.showAlert = true; + this.serviceForm.enable(); + this.serviceForm.reset(); + }, () => { + window.scroll(0, 0); + this.serviceForm.enable(); + this.alert = { + type: 'error', + message: 'Impossible de créer le service' + }; + this.showAlert = true; + }); + } + + updateService(): void { + if (this.serviceForm.invalid) { + return; + } + + this.serviceForm.disable(); + this.showAlert = false; + + this._projectService.updateService(this.service._id, this.serviceForm.value).subscribe(() => { + window.scroll(0, 0); + this.alert = { + type: 'success', + message: 'Service mis à jour avec succès' + }; + this.showAlert = true; + this.serviceForm.enable(); + this.serviceForm.reset(); + }, () => { + window.scroll(0, 0); + this.serviceForm.enable(); + this.alert = { + type: 'error', + message: 'Impossible de mettre à jour le service' + }; + this.showAlert = true; + }); + } + + setServiceForm(service: any) { + this.service = service; + this.serviceForm = this._formBuilder.group({ + name: [service.name, [Validators.required]], + price: [service.price, [Validators.required]], + processingTime: [service.processingTime, [Validators.required]], + commissionPercentage: [service.commissionPercentage, [Validators.required]] + }); + } + // ----------------------------------------------------------------------------------------------------- // @ Public methods // ----------------------------------------------------------------------------------------------------- diff --git a/src/app/modules/admin/dashboards/project/project.module.ts b/src/app/modules/admin/dashboards/project/project.module.ts index 734e076..3d316c7 100644 --- a/src/app/modules/admin/dashboards/project/project.module.ts +++ b/src/app/modules/admin/dashboards/project/project.module.ts @@ -17,6 +17,13 @@ import { SharedModule } from 'app/shared/shared.module'; import { ProjectComponent } from 'app/modules/admin/dashboards/project/project.component'; import { projectRoutes } from 'app/modules/admin/dashboards/project/project.routing'; import { MatProgressSpinnerModule } from '@angular/material/progress-spinner'; +import { MatCheckboxModule } from '@angular/material/checkbox'; +import { MatFormFieldModule } from '@angular/material/form-field'; +import { MatInputModule } from '@angular/material/input'; +import { MatRadioModule } from '@angular/material/radio'; +import { MatSelectModule } from '@angular/material/select'; +import { MatDatepickerModule } from '@angular/material/datepicker'; +import { FuseAlertModule } from '@fuse/components/alert'; @NgModule({ declarations: [ @@ -38,7 +45,14 @@ import { MatProgressSpinnerModule } from '@angular/material/progress-spinner'; NgApexchartsModule, TranslocoModule, SharedModule, - MatProgressSpinnerModule + MatProgressSpinnerModule, + MatCheckboxModule, + MatFormFieldModule, + MatInputModule, + MatRadioModule, + MatSelectModule, + MatDatepickerModule, + FuseAlertModule ] }) export class ProjectModule diff --git a/src/app/modules/admin/dashboards/project/project.service.ts b/src/app/modules/admin/dashboards/project/project.service.ts index 3cec81c..5edc757 100644 --- a/src/app/modules/admin/dashboards/project/project.service.ts +++ b/src/app/modules/admin/dashboards/project/project.service.ts @@ -2,19 +2,19 @@ import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { BehaviorSubject, Observable } from 'rxjs'; import { tap } from 'rxjs/operators'; +import { environment } from 'environments/environment'; @Injectable({ providedIn: 'root' }) -export class ProjectService -{ +export class ProjectService { private _data: BehaviorSubject = new BehaviorSubject(null); + public _baseUrl: string = environment.apiUrl; /** * Constructor */ - constructor(private _httpClient: HttpClient) - { + constructor(private _httpClient: HttpClient) { } // ----------------------------------------------------------------------------------------------------- @@ -24,8 +24,7 @@ export class ProjectService /** * Getter for data */ - get data$(): Observable - { + get data$(): Observable { return this._data.asObservable(); } @@ -36,12 +35,19 @@ export class ProjectService /** * Get data */ - getData(): Observable - { + getData(): Observable { return this._httpClient.get('api/dashboards/project').pipe( tap((response: any) => { this._data.next(response); }) ); } + + createService(data: any): Observable { + return this._httpClient.post(`${this._baseUrl}/service`, data); + } + + updateService(id: string, data: any): Observable { + return this._httpClient.put(`${this._baseUrl}/service/${id}`, data); + } } diff --git a/src/app/modules/auth/sign-out/sign-out.component.html b/src/app/modules/auth/sign-out/sign-out.component.html index c89a67f..c63efb0 100644 --- a/src/app/modules/auth/sign-out/sign-out.component.html +++ b/src/app/modules/auth/sign-out/sign-out.component.html @@ -7,25 +7,25 @@ -
You have signed out!
+
Vous avez deconnecté!
- Redirecting in {{countdown | i18nPlural: countdownMapping }} + Redirection dans {{countdown | i18nPlural: countdownMapping }} - You are now being redirected! + Redirection en cours