Skip to content

Commit

Permalink
[IMP] Add and edit services, get notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
Landris18 committed Feb 29, 2024
1 parent 4971dd6 commit a83b2d2
Show file tree
Hide file tree
Showing 11 changed files with 229 additions and 54 deletions.
2 changes: 2 additions & 0 deletions src/app/core/user/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ export class UserService {
return this._httpClient.get<User>(`${this._baseUrl}/user/${localStorage.getItem("userId")}`).pipe(
tap((user) => {
this._user.next(user);
console.log(user, "user logged in");

})
);
}
Expand Down
26 changes: 12 additions & 14 deletions src/app/layout/common/notifications/notifications.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
(click)="markAllAsRead()">
<mat-icon
class="icon-size-5 text-current"
[svgIcon]="'heroicons_solid:mail-open'"></mat-icon>
[svgIcon]="'heroicons_solid:bell'"></mat-icon>
</button>
</div>
</div>
Expand All @@ -48,7 +48,7 @@
<!-- Notifications -->
<ng-container *ngFor="let notification of notifications; trackBy: trackByFn">
<div class="flex group hover:bg-gray-50 dark:hover:bg-black dark:hover:bg-opacity-5 unread">
<ng-container *ngIf="notification.useRouter">
<ng-container>
<a class="flex flex-auto py-5 pl-6 cursor-pointer">
<ng-container *ngTemplateOutlet="notificationContent"></ng-container>
</a>
Expand All @@ -58,35 +58,33 @@
<!-- Notification content template -->
<ng-template #notificationContent>
<!-- Icon -->
<ng-container *ngIf="notification.icon && !notification.image">
<!-- <ng-container *ngIf="notification.icon && !notification.image"> -->
<div class="flex flex-shrink-0 items-center justify-center w-8 h-8 mr-4 rounded-full bg-gray-100 dark:bg-gray-700">
<mat-icon
class="icon-size-5"
[svgIcon]="notification.icon">
[svgIcon]="'heroicons_outline:bell'">
</mat-icon>
</div>
</ng-container>
<!-- </ng-container> -->
<!-- Image -->
<ng-container *ngIf="notification.image">
<!-- <ng-container *ngIf="notification.image">
<img
class="flex-shrink-0 w-8 h-8 mr-4 rounded-full overflow-hidden object-cover object-center"
[src]="notification.image"
[alt]="'Notification image'">
</ng-container>
</ng-container> -->
<!-- Title, description & time -->
<div class="flex flex-col flex-auto">
<ng-container *ngIf="notification.title">
<div
class="font-semibold line-clamp-1"
[innerHTML]="notification.title"></div>
<ng-container *ngIf="notification.name">
<div class="font-semibold line-clamp-1" [innerHTML]="notification.name"></div>
</ng-container>
<ng-container *ngIf="notification.description">
<ng-container *ngIf="notification.Description">
<div
class="line-clamp-2"
[innerHTML]="notification.description"></div>
[innerHTML]="notification.Description"></div>
</ng-container>
<div class="mt-2 text-sm leading-none text-secondary">
{{notification.time | date:'MMM dd, h:mm a'}}
{{notification.Date}}
</div>
</div>
</ng-template>
Expand Down
15 changes: 0 additions & 15 deletions src/app/layout/common/notifications/notifications.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</div>
<!-- Components -->
<div class="flex items-center ml-auto">
<notifications></notifications>
<notifications *ngIf="user.role === 'Client'"></notifications>
<user [showAvatar]="false"></user>
</div>
</div>
Expand Down
6 changes: 5 additions & 1 deletion src/app/layout/layouts/vertical/classy/classy.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ <h2 class="text-secondary text-3xl"><strong>Pas d'historiques de rendez-vous</st
<mat-datepicker-toggle matSuffix [for]="picker1"></mat-datepicker-toggle>
<mat-datepicker #picker1></mat-datepicker>
<mat-error *ngIf="rendezForm.get('startDate').hasError('required')">
Start date is required
Le champ dete debut est requis
</mat-error>
</mat-form-field>
<mat-form-field class="flex-auto">
Expand All @@ -220,7 +220,7 @@ <h2 class="text-secondary text-3xl"><strong>Pas d'historiques de rendez-vous</st
<mat-datepicker-toggle matSuffix [for]="picker2"></mat-datepicker-toggle>
<mat-datepicker #picker2></mat-datepicker>
<mat-error *ngIf="rendezForm.get('endDate').hasError('required')">
End date is required
Le champ dete fin est requis
</mat-error>
</mat-form-field>
</div>
Expand Down
93 changes: 91 additions & 2 deletions src/app/modules/admin/dashboards/project/project.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ <h2 class="text-3xl font-semibold tracking-tight leading-8">Services</h2>
</div>
</div>

<div class="grid grid-cols-1 sm:grid-cols-6 gap-6 w-full min-w-0 mt-8">
<div class="grid grid-cols-1 sm:grid-cols-6 gap-6 w-full min-w-0 mt-8" *ngIf="showDefault">
<!-- Liste des services -->
<div class="sm:col-span-6 flex flex-col flex-auto p-6 bg-card shadow rounded-2xl overflow-hidden">
<div class="text-lg font-medium tracking-tight leading-6 truncate">Liste des services</div>
Expand All @@ -379,6 +379,7 @@ <h2 class="text-3xl font-semibold tracking-tight leading-8">Services</h2>
<h2 class="text-secondary text-3xl"><strong>Aucun service trouvé</strong></h2>
</div>
<table
*ngIf="!loadingData && services?.rows?.length !== 0"
class="min-w-240 overflow-y-visible"
mat-table
[dataSource]="services.rows">
Expand Down Expand Up @@ -413,6 +414,20 @@ <h2 class="text-secondary text-3xl"><strong>Aucun service trouvé</strong></h2>
</td>
</ng-container>

<!-- Prix -->
<ng-container matColumnDef="commissionPercentage">
<th
mat-header-cell
*matHeaderCellDef>
Commission
</th>
<td
mat-cell
*matCellDef="let s">
{{s.commissionPercentage}}%
</td>
</ng-container>

<!-- processingTime -->
<ng-container matColumnDef="processingTime">
<th
Expand Down Expand Up @@ -455,7 +470,7 @@ <h2 class="text-secondary text-3xl"><strong>Aucun service trouvé</strong></h2>
Actions
</th>
<td mat-cell *matCellDef="let s" class="flex flex-row justify-end">
<button mat-icon-button>
<button mat-icon-button (click)="showDefault = false; isEdit = true; setServiceForm(s)">
<mat-icon>edit</mat-icon>
</button>
<button mat-icon-button>
Expand All @@ -474,6 +489,80 @@ <h2 class="text-secondary text-3xl"><strong>Aucun service trouvé</strong></h2>
</div>
</div>
</div>

<form class="xl:col-span-4 flex flex-col flex-auto bg-card shadow rounded-2xl mt-8 overflow-hidden"
[formGroup]="serviceForm"
*ngIf="!showDefault"
>
<!-- Alert -->
<div class="flex flex-col p-8" *ngIf="showAlert">
<fuse-alert
class="mb-4"
[appearance]="'outline'"
[showIcon]="false"
[type]="alert.type"
[@shake]="alert.type === 'error'">
{{alert.message}}
</fuse-alert>
</div>

<div class="bg-gray-50 dark:bg-gray-700 p-8 border-b">
<p class="text-lg font-medium">Créer un service</p>
<p class="text-secondary">Ajouter un nouveau service pour les clients</p>
</div>
<div class="flex flex-col p-8">
<mat-form-field class="fuse-mat-dense flex-auto">
<mat-label>Nom</mat-label>
<input matInput [formControlName]="'name'">
<mat-error *ngIf="serviceForm.get('name').hasError('required')">
Le champ nom est requis
</mat-error>
</mat-form-field>
<mat-form-field class="fuse-mat-dense flex-auto">
<mat-label>Prix en ariary</mat-label>
<input matInput [formControlName]="'price'">
<mat-error *ngIf="serviceForm.get('price').hasError('required')">
Le champ prix est requis
</mat-error>
</mat-form-field>
<mat-form-field class="fuse-mat-dense flex-auto">
<mat-label>Temps en heure</mat-label>
<input matInput [formControlName]="'processingTime'">
<mat-error *ngIf="serviceForm.get('processingTime').hasError('required')">
Le champ temps est requis
</mat-error>
</mat-form-field>
<mat-form-field class="fuse-mat-dense flex-auto">
<mat-label>Pourcentage de commission</mat-label>
<input matInput [formControlName]="'commissionPercentage'">
<mat-error *ngIf="serviceForm.get('commissionPercentage').hasError('required')">
Le champ temps est requis
</mat-error>
</mat-form-field>
</div>

<div class="flex items-center justify-end border-t px-8 py-5 bg-gray-50 dark:bg-gray-700">
<button mat-button (click)="cancel()">
Annuler
</button>
<button
class="px-6 ml-3"
mat-flat-button
[color]="'primary'"
[disabled]="serviceForm.disabled"
(click)="!isEdit ? createService() : updateService()">
<span *ngIf="!serviceForm.disabled">
Sauvegarder
</span>
<mat-progress-spinner
*ngIf="serviceForm.disabled"
[diameter]="24"
[mode]="'indeterminate'">
</mat-progress-spinner>
</button>
</div>
</form>

</ng-template>
</mat-tab>

Expand Down
Loading

0 comments on commit a83b2d2

Please sign in to comment.