@movalib/movalib-commons 1.59.36 → 1.59.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/MovaLogin.js +6 -5
- package/dist/src/assets/images/logo/header_logo_admin.png +0 -0
- package/dist/src/assets/images/logo/logo_admin_large.png +0 -0
- package/dist/src/components/vehicle/VehicleFullCard.d.ts +5 -5
- package/dist/src/components/vehicle/VehicleFullCard.js +101 -82
- package/dist/src/helpers/ApiHelper.js +5 -0
- package/dist/src/helpers/CookieUtils.d.ts +1 -0
- package/dist/src/helpers/CookieUtils.js +2 -1
- package/dist/src/helpers/Enums.d.ts +7 -6
- package/dist/src/helpers/Enums.js +6 -5
- package/dist/src/models/Document.d.ts +2 -1
- package/dist/src/models/Document.js +3 -5
- package/dist/src/models/Event.d.ts +12 -1
- package/dist/src/models/Event.js +2 -1
- package/dist/src/models/Product.d.ts +2 -1
- package/dist/src/models/Product.js +2 -1
- package/dist/src/services/AuthenticationService.d.ts +1 -1
- package/dist/src/services/AuthenticationService.js +38 -9
- package/dist/src/services/GarageService.d.ts +3 -1
- package/dist/src/services/GarageService.js +18 -4
- package/package.json +1 -1
- package/src/MovaLogin.tsx +6 -5
- package/src/assets/images/logo/header_logo_admin.png +0 -0
- package/src/assets/images/logo/logo_admin_large.png +0 -0
- package/src/components/vehicle/VehicleFullCard.tsx +847 -559
- package/src/helpers/ApiHelper.ts +6 -1
- package/src/helpers/CookieUtils.ts +1 -0
- package/src/helpers/Enums.ts +216 -217
- package/src/models/Document.ts +42 -37
- package/src/models/Event.ts +13 -1
- package/src/models/Product.ts +40 -26
- package/src/services/AuthenticationService.ts +31 -6
- package/src/services/GarageService.ts +667 -621
package/src/models/Event.ts
CHANGED
|
@@ -10,6 +10,15 @@ import Supplier from "./Supplier";
|
|
|
10
10
|
import User from "./User";
|
|
11
11
|
import Vehicle from "./Vehicle";
|
|
12
12
|
|
|
13
|
+
interface order {
|
|
14
|
+
id: string;
|
|
15
|
+
supplier: Supplier;
|
|
16
|
+
orderPreference: string;
|
|
17
|
+
orderType: string;
|
|
18
|
+
orderDate: Date;
|
|
19
|
+
comment: string;
|
|
20
|
+
deliveryDate: Date | null;
|
|
21
|
+
}
|
|
13
22
|
export default class Event {
|
|
14
23
|
// Properties
|
|
15
24
|
id: string; //UUID
|
|
@@ -25,6 +34,7 @@ export default class Event {
|
|
|
25
34
|
prestations?: Prestation[];
|
|
26
35
|
operations?: Operation[];
|
|
27
36
|
products?: Product[];
|
|
37
|
+
orders?: order[];
|
|
28
38
|
/**
|
|
29
39
|
* Un tableau d'invités, dans notre cas d'usage nous n'aurons qu'un invité de type Client
|
|
30
40
|
*/
|
|
@@ -100,7 +110,8 @@ export default class Event {
|
|
|
100
110
|
vehicleAvailableNotificationTime?: Date,
|
|
101
111
|
interventionEndTime?: Date,
|
|
102
112
|
quoteLastSendingTime?: Date,
|
|
103
|
-
invoiceSendingDate?: Date
|
|
113
|
+
invoiceSendingDate?: Date,
|
|
114
|
+
orders?: order[]
|
|
104
115
|
) {
|
|
105
116
|
this.id = id;
|
|
106
117
|
this.notes = notes;
|
|
@@ -137,6 +148,7 @@ export default class Event {
|
|
|
137
148
|
this.invoiceSendingDate = invoiceSendingDate
|
|
138
149
|
? new Date(invoiceSendingDate)
|
|
139
150
|
: undefined;
|
|
151
|
+
this.orders = orders;
|
|
140
152
|
}
|
|
141
153
|
|
|
142
154
|
static getPrestationsList(event: Event): string[] {
|
package/src/models/Product.ts
CHANGED
|
@@ -1,31 +1,45 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
OrderPreference,
|
|
3
|
+
OrderState,
|
|
4
|
+
PartsApplicationType,
|
|
5
|
+
ProductType,
|
|
6
|
+
} from "../helpers/Enums";
|
|
2
7
|
import Operation from "./Operation";
|
|
3
8
|
import Supplier from "./Supplier";
|
|
4
9
|
|
|
5
10
|
export default class Product {
|
|
11
|
+
// Properties
|
|
12
|
+
id: string; //UUID
|
|
13
|
+
name: string;
|
|
14
|
+
code: string;
|
|
15
|
+
type: ProductType;
|
|
16
|
+
order?: String;
|
|
17
|
+
orderPreference?: OrderPreference;
|
|
18
|
+
originReferences?: string[];
|
|
19
|
+
// Eventuelle opération associée au produit
|
|
20
|
+
operation?: Operation;
|
|
21
|
+
// Eventuel statut commande associé au produit
|
|
22
|
+
orderState?: OrderState;
|
|
23
|
+
// Eventuel fournisseur du produit
|
|
24
|
+
supplier?: Supplier;
|
|
25
|
+
// Eventuelle application du produit (avant, arrière)
|
|
26
|
+
application?: PartsApplicationType;
|
|
6
27
|
|
|
7
|
-
|
|
8
|
-
id: string
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
type: ProductType
|
|
12
|
-
orderPreference
|
|
13
|
-
originReferences
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
this.name = name;
|
|
26
|
-
this.code = code;
|
|
27
|
-
this.type = type;
|
|
28
|
-
this.orderPreference = orderPreference;
|
|
29
|
-
this.originReferences = originReferences;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
28
|
+
constructor(
|
|
29
|
+
id: string,
|
|
30
|
+
code: string,
|
|
31
|
+
name: string,
|
|
32
|
+
type: ProductType,
|
|
33
|
+
orderPreference: OrderPreference,
|
|
34
|
+
originReferences: string[],
|
|
35
|
+
order?: string
|
|
36
|
+
) {
|
|
37
|
+
this.id = id;
|
|
38
|
+
this.name = name;
|
|
39
|
+
this.code = code;
|
|
40
|
+
this.type = type;
|
|
41
|
+
this.orderPreference = orderPreference;
|
|
42
|
+
this.originReferences = originReferences;
|
|
43
|
+
this.order = order;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { APIResponse, API_BASE_URL, request } from "../helpers/ApiHelper";
|
|
2
|
-
import { COOKIE_PRO_TOKEN, COOKIE_INDIVIDUAL_TOKEN, createCookie } from "../helpers/CookieUtils";
|
|
2
|
+
import { COOKIE_PRO_TOKEN, COOKIE_INDIVIDUAL_TOKEN, COOKIE_ADMIN_TOKEN, createCookie } from "../helpers/CookieUtils";
|
|
3
3
|
import { APIMethod, MovaAppType } from "../helpers/Enums";
|
|
4
4
|
import Logger from "../helpers/Logger";
|
|
5
5
|
import User from "../models/User";
|
|
@@ -42,6 +42,14 @@ export default class AuthenticationService {
|
|
|
42
42
|
password: password
|
|
43
43
|
}
|
|
44
44
|
break;
|
|
45
|
+
case MovaAppType.ADMIN:
|
|
46
|
+
url = `${API_BASE_URL}/garage/login`;
|
|
47
|
+
tokenCookie = COOKIE_ADMIN_TOKEN;
|
|
48
|
+
req = {
|
|
49
|
+
email : phoneEmail,
|
|
50
|
+
password: password
|
|
51
|
+
}
|
|
52
|
+
break;
|
|
45
53
|
}
|
|
46
54
|
|
|
47
55
|
let tokenResponse = await request({
|
|
@@ -53,7 +61,7 @@ export default class AuthenticationService {
|
|
|
53
61
|
|
|
54
62
|
if(tokenResponse.success){
|
|
55
63
|
// CSM CASE
|
|
56
|
-
if (tokenResponse.data.accessToken === null && tokenResponse.data.role.includes('ROLE_CSM')) {
|
|
64
|
+
if (tokenResponse.data.accessToken === null && (tokenResponse.data.role.includes('ROLE_CSM') || tokenResponse.data.role.includes('ROLE_SUPER_ADMIN'))) {
|
|
57
65
|
return { success: true, data: tokenResponse.data };
|
|
58
66
|
}
|
|
59
67
|
Logger.info(tokenResponse);
|
|
@@ -82,7 +90,7 @@ export default class AuthenticationService {
|
|
|
82
90
|
return { success: false, error: errorMessage };
|
|
83
91
|
}
|
|
84
92
|
}
|
|
85
|
-
static async ValidateSecurityCode(req: { securityCode: string
|
|
93
|
+
static async ValidateSecurityCode(req: { securityCode: string}, appType?: MovaAppType ): Promise<APIResponse<User>> {
|
|
86
94
|
try {
|
|
87
95
|
//For now it's only for CSM
|
|
88
96
|
const tokenResponse = await request({
|
|
@@ -90,8 +98,21 @@ export default class AuthenticationService {
|
|
|
90
98
|
method: APIMethod.POST,
|
|
91
99
|
body: JSON.stringify(req)
|
|
92
100
|
});
|
|
93
|
-
const tokenCookie = COOKIE_PRO_TOKEN;
|
|
94
101
|
|
|
102
|
+
let tokenCookie = COOKIE_PRO_TOKEN;
|
|
103
|
+
if(appType){
|
|
104
|
+
switch(appType){
|
|
105
|
+
case MovaAppType.GARAGE:
|
|
106
|
+
tokenCookie = COOKIE_PRO_TOKEN;
|
|
107
|
+
break;
|
|
108
|
+
case MovaAppType.INDIVIDUAL:
|
|
109
|
+
tokenCookie = COOKIE_INDIVIDUAL_TOKEN;
|
|
110
|
+
break;
|
|
111
|
+
case MovaAppType.ADMIN:
|
|
112
|
+
tokenCookie = COOKIE_ADMIN_TOKEN;
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
95
116
|
|
|
96
117
|
if (tokenResponse.success) {
|
|
97
118
|
|
|
@@ -100,8 +121,12 @@ export default class AuthenticationService {
|
|
|
100
121
|
createCookie(tokenCookie, tokenResponse.data.accessToken);
|
|
101
122
|
|
|
102
123
|
// Si le login est un succès, on renvoie les infos de l'utilisateur connecté
|
|
103
|
-
let userResponse
|
|
104
|
-
|
|
124
|
+
let userResponse;
|
|
125
|
+
if(appType){
|
|
126
|
+
userResponse = await UserService.getCurrentUser(appType);
|
|
127
|
+
}else{
|
|
128
|
+
userResponse = await UserService.getCurrentUser(MovaAppType.GARAGE);
|
|
129
|
+
}
|
|
105
130
|
if (!userResponse || !userResponse.success) {
|
|
106
131
|
const errorMsg = 'Erreur au chargement de votre profil';
|
|
107
132
|
Logger.error(errorMsg);
|