Skip to content

Commit 10e66a2

Browse files
committed
🎉 Initialisation de l'app module
1 parent 7b3ee9f commit 10e66a2

File tree

4 files changed

+89
-31
lines changed

4 files changed

+89
-31
lines changed

src/app/app.module.ts

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
import { APP_INITIALIZER, ErrorHandler, NgModule } from '@angular/core';
1+
import {
2+
APP_INITIALIZER,
3+
ErrorHandler,
4+
LOCALE_ID,
5+
NgModule,
6+
} from '@angular/core';
27
import { HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http';
38
import { BrowserModule } from '@angular/platform-browser';
49
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
@@ -8,28 +13,39 @@ import { StoreDevtoolsModule } from '@ngrx/store-devtools';
813
import { EffectsModule } from '@ngrx/effects';
914
import { StoreRouterConnectingModule } from '@ngrx/router-store';
1015
import * as Sentry from '@sentry/angular';
16+
import { Router } from '@angular/router';
17+
import localeFr from '@angular/common/locales/fr';
18+
import { registerLocaleData } from '@angular/common';
19+
import { NgxPermissionsModule } from 'ngx-permissions';
1120

12-
import { environment } from '../environments/environment';
21+
import { environment } from 'environments/environment';
1322
import { AppRoutingModule } from './core/routes/app-routing.module';
1423
import { AppComponent } from './core/components/app/app.component';
1524
import { ROOT_REDUCERS } from './core/store/app.store';
16-
import { Router } from '@angular/router';
1725
import { AuthInterceptor } from './modules/authentication/interceptors/auth.interceptor';
26+
import { HttpLoadingInterceptor } from './shared/interceptors/http-loading.interceptor';
27+
import { AuthenticationModule } from './modules/authentication/authentication.module';
28+
import { ErrorInterceptor } from './shared/interceptors/error.interceptor';
29+
30+
registerLocaleData(localeFr);
1831

1932
@NgModule({
20-
declarations: [
21-
AppComponent,
22-
],
33+
declarations: [AppComponent],
2334
imports: [
2435
AppRoutingModule,
36+
AuthenticationModule,
2537
BrowserAnimationsModule,
2638
BrowserModule,
2739
EffectsModule.forRoot(),
2840
FormsModule,
2941
HttpClientModule,
42+
NgxPermissionsModule.forRoot(),
3043
ReactiveFormsModule,
3144
StoreModule.forRoot(ROOT_REDUCERS),
32-
StoreDevtoolsModule.instrument({ maxAge: 25, logOnly: environment.production }),
45+
StoreDevtoolsModule.instrument({
46+
maxAge: 25,
47+
logOnly: environment.production,
48+
}),
3349
StoreRouterConnectingModule.forRoot(),
3450
],
3551
providers: [
@@ -53,8 +69,22 @@ import { AuthInterceptor } from './modules/authentication/interceptors/auth.inte
5369
provide: HTTP_INTERCEPTORS,
5470
useClass: AuthInterceptor,
5571
multi: true,
56-
}
72+
},
73+
{
74+
provide: HTTP_INTERCEPTORS,
75+
useClass: ErrorInterceptor,
76+
multi: true,
77+
},
78+
{
79+
provide: HTTP_INTERCEPTORS,
80+
useClass: HttpLoadingInterceptor,
81+
multi: true,
82+
},
83+
{
84+
provide: LOCALE_ID,
85+
useValue: 'fr-FR',
86+
},
5787
],
5888
bootstrap: [AppComponent],
5989
})
60-
export class AppModule { }
90+
export class AppModule {}
Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { ADMIN_ROLE, DEVELOPER_ROLE } from '@app/core/guards/user.roles';
12
import { Menu } from '@app/shared/interfaces/menu';
23

34
export const adminMenu: Menu[] = [
@@ -7,37 +8,41 @@ export const adminMenu: Menu[] = [
78
{
89
title: 'Tableau de bord',
910
svgPath: [
10-
'M12 16v5m6 0-3.951-3.293c-.73-.607-1.094-.91-1.5-1.027a2 2 0 0 0-1.098 0c-.406.116-.77.42-1.5 1.027L6 21m2-10v1m4-3v3m4-5v5m6-9H2m1 0h18v8.2c0 1.68 0 2.52-.327 3.162a3 3 0 0 1-1.311 1.311C18.72 16 17.88 16 16.2 16H7.8c-1.68 0-2.52 0-3.162-.327a3 3 0 0 1-1.311-1.311C3 13.72 3 12.88 3 11.2V3Z'
11+
'M12 16v5m6 0-3.951-3.293c-.73-.607-1.094-.91-1.5-1.027a2 2 0 0 0-1.098 0c-.406.116-.77.42-1.5 1.027L6 21m2-10v1m4-3v3m4-5v5m6-9H2m1 0h18v8.2c0 1.68 0 2.52-.327 3.162a3 3 0 0 1-1.311 1.311C18.72 16 17.88 16 16.2 16H7.8c-1.68 0-2.52 0-3.162-.327a3 3 0 0 1-1.311-1.311C3 13.72 3 12.88 3 11.2V3Z',
1112
],
1213
link: '/dashboard',
14+
roles: [ADMIN_ROLE, DEVELOPER_ROLE],
1315
},
1416
{
1517
title: 'Transactions',
1618
svgPath: [
17-
'm6 6 2-2m0 0L6 2m2 2H6a4 4 0 0 0-4 4m16 10-2 2m0 0 2 2m-2-2h2a4 4 0 0 0 4-4M10.189 6.5a6 6 0 1 1 7.311 7.311M14 16a6 6 0 1 1-12 0 6 6 0 0 1 12 0Z'
19+
'm6 6 2-2m0 0L6 2m2 2H6a4 4 0 0 0-4 4m16 10-2 2m0 0 2 2m-2-2h2a4 4 0 0 0 4-4M10.189 6.5a6 6 0 1 1 7.311 7.311M14 16a6 6 0 1 1-12 0 6 6 0 0 1 12 0Z',
1820
],
19-
link: '/dashboard/transactions',
20-
}
21-
]
21+
link: '/transactions',
22+
roles: [ADMIN_ROLE, DEVELOPER_ROLE],
23+
},
24+
],
2225
},
2326
{
2427
group: 'Management',
2528
items: [
2629
{
2730
title: 'Utilisateurs',
2831
svgPath: [
29-
'M18 18.72a9.094 9.094 0 0 0 3.741-.479 3 3 0 0 0-4.682-2.72m.94 3.198.001.031c0 .225-.012.447-.037.666A11.944 11.944 0 0 1 12 21c-2.17 0-4.207-.576-5.963-1.584A6.062 6.062 0 0 1 6 18.719m12 0a5.971 5.971 0 0 0-.941-3.197m0 0A5.995 5.995 0 0 0 12 12.75a5.995 5.995 0 0 0-5.058 2.772m0 0a3 3 0 0 0-4.681 2.72 8.986 8.986 0 0 0 3.74.477m.94-3.197a5.971 5.971 0 0 0-.94 3.197M15 6.75a3 3 0 1 1-6 0 3 3 0 0 1 6 0Zm6 3a2.25 2.25 0 1 1-4.5 0 2.25 2.25 0 0 1 4.5 0Zm-13.5 0a2.25 2.25 0 1 1-4.5 0 2.25 2.25 0 0 1 4.5 0Z'
32+
'M18 18.72a9.094 9.094 0 0 0 3.741-.479 3 3 0 0 0-4.682-2.72m.94 3.198.001.031c0 .225-.012.447-.037.666A11.944 11.944 0 0 1 12 21c-2.17 0-4.207-.576-5.963-1.584A6.062 6.062 0 0 1 6 18.719m12 0a5.971 5.971 0 0 0-.941-3.197m0 0A5.995 5.995 0 0 0 12 12.75a5.995 5.995 0 0 0-5.058 2.772m0 0a3 3 0 0 0-4.681 2.72 8.986 8.986 0 0 0 3.74.477m.94-3.197a5.971 5.971 0 0 0-.94 3.197M15 6.75a3 3 0 1 1-6 0 3 3 0 0 1 6 0Zm6 3a2.25 2.25 0 1 1-4.5 0 2.25 2.25 0 0 1 4.5 0Zm-13.5 0a2.25 2.25 0 1 1-4.5 0 2.25 2.25 0 0 1 4.5 0Z',
3033
],
3134
link: '/users',
35+
roles: [ADMIN_ROLE],
3236
},
3337
{
3438
title: 'Promotions',
3539
svgPath: [
36-
'M16.5 6v.75m0 3v.75m0 3v.75m0 3V18m-9-5.25h5.25M7.5 15h3M3.375 5.25c-.621 0-1.125.504-1.125 1.125v3.026a2.999 2.999 0 0 1 0 5.198v3.026c0 .621.504 1.125 1.125 1.125h17.25c.621 0 1.125-.504 1.125-1.125v-3.026a2.999 2.999 0 0 1 0-5.198V6.375c0-.621-.504-1.125-1.125-1.125H3.375Z'
40+
'M16.5 6v.75m0 3v.75m0 3v.75m0 3V18m-9-5.25h5.25M7.5 15h3M3.375 5.25c-.621 0-1.125.504-1.125 1.125v3.026a2.999 2.999 0 0 1 0 5.198v3.026c0 .621.504 1.125 1.125 1.125h17.25c.621 0 1.125-.504 1.125-1.125v-3.026a2.999 2.999 0 0 1 0-5.198V6.375c0-.621-.504-1.125-1.125-1.125H3.375Z',
3741
],
3842
link: '/promotions',
39-
}
40-
]
43+
roles: [ADMIN_ROLE],
44+
},
45+
],
4146
},
4247
{
4348
group: 'Opérations',
@@ -49,14 +54,16 @@ export const adminMenu: Menu[] = [
4954
'M18.727 14.727a1.5 1.5 0 0 0 .3 1.655l.055.054a1.816 1.816 0 0 1 0 2.573 1.818 1.818 0 0 1-2.573 0l-.055-.055a1.5 1.5 0 0 0-1.654-.3 1.5 1.5 0 0 0-.91 1.373v.155a1.818 1.818 0 1 1-3.636 0V20.1a1.5 1.5 0 0 0-.981-1.373 1.5 1.5 0 0 0-1.655.3l-.054.055a1.818 1.818 0 0 1-3.106-1.287 1.818 1.818 0 0 1 .533-1.286l.054-.055a1.5 1.5 0 0 0 .3-1.654 1.5 1.5 0 0 0-1.372-.91h-.155a1.818 1.818 0 1 1 0-3.636H3.9a1.5 1.5 0 0 0 1.373-.981 1.5 1.5 0 0 0-.3-1.655l-.055-.054A1.818 1.818 0 1 1 7.491 4.99l.054.054a1.5 1.5 0 0 0 1.655.3h.073a1.5 1.5 0 0 0 .909-1.372v-.155a1.818 1.818 0 0 1 3.636 0V3.9a1.499 1.499 0 0 0 .91 1.373 1.5 1.5 0 0 0 1.654-.3l.054-.055a1.817 1.817 0 0 1 2.573 0 1.819 1.819 0 0 1 0 2.573l-.055.054a1.5 1.5 0 0 0-.3 1.655v.073a1.5 1.5 0 0 0 1.373.909h.155a1.818 1.818 0 0 1 0 3.636H20.1a1.499 1.499 0 0 0-1.373.91Z',
5055
],
5156
link: '/settings',
57+
roles: [DEVELOPER_ROLE],
5258
},
5359
{
5460
title: 'Rapports',
5561
svgPath: [
56-
'M14 2.27V6.4c0 .56 0 .84.109 1.054a1 1 0 0 0 .437.437c.214.11.494.11 1.054.11h4.13M16 13H8m8 4H8m2-8H8m6-7H8.8c-1.68 0-2.52 0-3.162.327a3 3 0 0 0-1.311 1.311C4 4.28 4 5.12 4 6.8v10.4c0 1.68 0 2.52.327 3.162a3 3 0 0 0 1.311 1.311C6.28 22 7.12 22 8.8 22h6.4c1.68 0 2.52 0 3.162-.327a3 3 0 0 0 1.311-1.311C20 19.72 20 18.88 20 17.2V8l-6-6Z'
62+
'M14 2.27V6.4c0 .56 0 .84.109 1.054a1 1 0 0 0 .437.437c.214.11.494.11 1.054.11h4.13M16 13H8m8 4H8m2-8H8m6-7H8.8c-1.68 0-2.52 0-3.162.327a3 3 0 0 0-1.311 1.311C4 4.28 4 5.12 4 6.8v10.4c0 1.68 0 2.52.327 3.162a3 3 0 0 0 1.311 1.311C6.28 22 7.12 22 8.8 22h6.4c1.68 0 2.52 0 3.162-.327a3 3 0 0 0 1.311-1.311C20 19.72 20 18.88 20 17.2V8l-6-6Z',
5763
],
58-
link: '/dashboard/reports',
59-
}
60-
]
64+
link: '/reports',
65+
roles: [ADMIN_ROLE, DEVELOPER_ROLE],
66+
},
67+
],
6168
},
62-
];
69+
];
Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,31 @@
11
import { Routes } from '@angular/router';
2+
import { NgxPermissionsGuard } from 'ngx-permissions';
23

34
import { AuthGuard } from '@app/core/guards/auth.guard';
5+
import { RoleGuard } from '@app/core/guards/role.guard';
46
import { UserDataGuard } from '@app/core/guards/user-data.guard';
57

68
import { CpanelComponent } from '@app/shared/themes/layouts/cpanel/cpanel.component';
79
import { DashboardComponent } from '../pages/dashboard/dashboard.component';
810

11+
import { ADMIN_ROLE, DEVELOPER_ROLE } from '@app/core/guards/user.roles';
12+
913
export const dashboardRoutes: Routes = [
1014
{
1115
path: '',
1216
component: CpanelComponent,
13-
canActivateChild: [AuthGuard, UserDataGuard],
17+
canActivate: [AuthGuard, UserDataGuard, RoleGuard],
1418
children: [
15-
{ path: '', component: DashboardComponent },
19+
{
20+
path: '',
21+
component: DashboardComponent,
22+
canActivate: [NgxPermissionsGuard],
23+
data: {
24+
permissions: {
25+
only: [ADMIN_ROLE, DEVELOPER_ROLE],
26+
},
27+
},
28+
},
1629
],
17-
}
18-
];
30+
},
31+
];

src/app/modules/user/interfaces/user.interface.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
import { Pagination } from '@app/shared/interfaces/response.interface';
2+
import { DefaultState } from '@app/shared/interfaces/state.interfaces';
3+
4+
export interface UserState extends DefaultState {
5+
pagination: Pagination;
6+
}
7+
18
export interface AuthResponse {
29
message: string;
310
data: {
@@ -6,7 +13,9 @@ export interface AuthResponse {
613
token_type: string;
714
expires_at: FromDate;
815
expires_in: number;
9-
}
16+
roles: string[];
17+
permissions: string[];
18+
};
1019
}
1120

1221
export interface FromDate {
@@ -21,10 +30,9 @@ export interface User {
2130
email: string;
2231
phoneNumber: string;
2332
accountType: string;
33+
profilePhotoUrl: string;
2434
timezone: string;
2535
emailVerifiedAt: string;
26-
roles: string[];
27-
permissions: string[];
2836
createdAt: Date;
2937
updatedAt: Date;
30-
}
38+
}

0 commit comments

Comments
 (0)