@movalib/movalib-commons 1.59.7 → 1.59.9
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/devIndex.tsx +2 -2
- package/dist/devIndex.js +3 -2
- package/dist/src/VehiclePlateField.js +1 -1
- package/dist/src/helpers/Enums.d.ts +2 -1
- package/dist/src/helpers/Enums.js +1 -0
- package/dist/src/models/User.d.ts +4 -1
- package/dist/src/models/User.js +7 -1
- package/dist/src/services/AuthenticationService.d.ts +3 -0
- package/dist/src/services/AuthenticationService.js +43 -0
- package/dist/src/services/GarageService.d.ts +5 -1
- package/dist/src/services/GarageService.js +18 -2
- package/package.json +1 -1
- package/src/VehiclePlateField.tsx +7 -1
- package/src/helpers/Enums.ts +1 -0
- package/src/models/User.ts +11 -1
- package/src/services/AuthenticationService.ts +44 -1
- package/src/services/GarageService.ts +20 -2
- package/movalib-movalib-commons-1.59.23.tgz +0 -0
package/devIndex.tsx
CHANGED
|
@@ -51,12 +51,12 @@ const App = () => {
|
|
|
51
51
|
Logger.info(response.data);
|
|
52
52
|
|
|
53
53
|
// Chargement des données du garage
|
|
54
|
-
GarageService.getAdministratedGarages()
|
|
54
|
+
GarageService.getAdministratedGarages({garageId: response?.data?.garages?.[0]?.id!})
|
|
55
55
|
.then(response => {
|
|
56
56
|
|
|
57
57
|
if (response.success) {
|
|
58
58
|
Logger.info(response.data);
|
|
59
|
-
setGarage(response.data ? response.data
|
|
59
|
+
setGarage(response.data ? response.data : undefined);
|
|
60
60
|
} else {
|
|
61
61
|
Logger.error(response.error);
|
|
62
62
|
}
|
package/dist/devIndex.js
CHANGED
|
@@ -75,14 +75,15 @@ var App = function () {
|
|
|
75
75
|
var refreshGarageData = function () {
|
|
76
76
|
AuthenticationService_1.default.login(Enums_1.MovaAppType.GARAGE, "cto@movalib.com", "cto@MOVALIB.com")
|
|
77
77
|
.then(function (response) {
|
|
78
|
+
var _a, _b, _c;
|
|
78
79
|
if (response.success) {
|
|
79
80
|
Logger_1.default.info(response.data);
|
|
80
81
|
// Chargement des données du garage
|
|
81
|
-
GarageService_1.default.getAdministratedGarages()
|
|
82
|
+
GarageService_1.default.getAdministratedGarages({ garageId: (_c = (_b = (_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.garages) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.id })
|
|
82
83
|
.then(function (response) {
|
|
83
84
|
if (response.success) {
|
|
84
85
|
Logger_1.default.info(response.data);
|
|
85
|
-
setGarage(response.data ? response.data
|
|
86
|
+
setGarage(response.data ? response.data : undefined);
|
|
86
87
|
}
|
|
87
88
|
else {
|
|
88
89
|
Logger_1.default.error(response.error);
|
|
@@ -67,7 +67,7 @@ var VehiclePlateField = function (_a) {
|
|
|
67
67
|
break;
|
|
68
68
|
}
|
|
69
69
|
case Enums_1.VehiclePlateFormat.FRENCH_OLD: {
|
|
70
|
-
setHelperText((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: ["Format d\u00E9tect\u00E9 (ancien) : ", (0, jsx_runtime_1.jsx)("b", { children: "1111 AAAA 1111" })] }));
|
|
70
|
+
setHelperText((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: ["Format d\u00E9tect\u00E9 (ancien) : ", (0, jsx_runtime_1.jsx)("b", { children: "1111 AAAA 1111" }), (0, jsx_runtime_1.jsx)("br", {}), "Pour lancer la recherche, cliquez sur ", (0, jsx_runtime_1.jsx)(SearchRounded_1.default, {})] }));
|
|
71
71
|
handleChangeFrenchOld(inputValue);
|
|
72
72
|
break;
|
|
73
73
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Gender } from "../helpers/Enums";
|
|
2
2
|
import Address from './Address';
|
|
3
|
+
import Garage from "./Garage";
|
|
3
4
|
import Role from "./Role";
|
|
4
5
|
import Vehicle from "./Vehicle";
|
|
5
6
|
export default class User {
|
|
@@ -18,11 +19,13 @@ export default class User {
|
|
|
18
19
|
vehicles?: Vehicle[];
|
|
19
20
|
isActive?: Boolean;
|
|
20
21
|
hasPassword?: Boolean;
|
|
21
|
-
|
|
22
|
+
garages?: Garage[];
|
|
23
|
+
constructor(id: string, roles: Role[], firstname?: string, lastname?: string, avatar?: string, password?: string, created?: Date, email?: string, gender?: Gender, birthDate?: Date, addresses?: Address[], phoneNumber?: string, vehicles?: Vehicle[], isActive?: Boolean, hasPassword?: Boolean, garages?: Garage[]);
|
|
22
24
|
static getFirstLetter: (user: User) => string;
|
|
23
25
|
static isGarageCustomer: (user: User) => boolean;
|
|
24
26
|
static isGarageTechnician: (user: User) => boolean;
|
|
25
27
|
static isGarageAdmin: (user: User) => boolean;
|
|
26
28
|
static isSales: (user: User) => boolean;
|
|
29
|
+
static isCsM: (user: User) => boolean;
|
|
27
30
|
static isSuperAdmin: (user: User) => boolean;
|
|
28
31
|
}
|
package/dist/src/models/User.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
var Enums_1 = require("../helpers/Enums");
|
|
4
4
|
var User = /** @class */ (function () {
|
|
5
|
-
function User(id, roles, firstname, lastname, avatar, password, created, email, gender, birthDate, addresses, phoneNumber, vehicles, isActive, hasPassword) {
|
|
5
|
+
function User(id, roles, firstname, lastname, avatar, password, created, email, gender, birthDate, addresses, phoneNumber, vehicles, isActive, hasPassword, garages) {
|
|
6
6
|
if (firstname === void 0) { firstname = ''; }
|
|
7
7
|
if (lastname === void 0) { lastname = ''; }
|
|
8
8
|
if (avatar === void 0) { avatar = ''; }
|
|
@@ -23,6 +23,7 @@ var User = /** @class */ (function () {
|
|
|
23
23
|
this.vehicles = vehicles;
|
|
24
24
|
this.isActive = isActive;
|
|
25
25
|
this.hasPassword = hasPassword;
|
|
26
|
+
this.garages = garages;
|
|
26
27
|
}
|
|
27
28
|
User.getFirstLetter = function (user) {
|
|
28
29
|
var firstLetter = user.lastname[0].toUpperCase();
|
|
@@ -48,6 +49,11 @@ var User = /** @class */ (function () {
|
|
|
48
49
|
return false;
|
|
49
50
|
return Boolean(user.roles.find(function (r) { return r.name === Enums_1.RoleType.SALES; }));
|
|
50
51
|
};
|
|
52
|
+
User.isCsM = function (user) {
|
|
53
|
+
if (!user || !user.roles)
|
|
54
|
+
return false;
|
|
55
|
+
return Boolean(user.roles.find(function (r) { return r.name === Enums_1.RoleType.CSM; }));
|
|
56
|
+
};
|
|
51
57
|
User.isSuperAdmin = function (user) {
|
|
52
58
|
if (!user || !user.roles)
|
|
53
59
|
return false;
|
|
@@ -4,4 +4,7 @@ import User from "../models/User";
|
|
|
4
4
|
export default class AuthenticationService {
|
|
5
5
|
static forgotPassword(req: any): Promise<APIResponse<string>>;
|
|
6
6
|
static login(appType: MovaAppType, phoneEmail: string, password: string): Promise<APIResponse<User>>;
|
|
7
|
+
static ValidateSecurityCode(req: {
|
|
8
|
+
securityCode: string;
|
|
9
|
+
}): Promise<APIResponse<User>>;
|
|
7
10
|
}
|
|
@@ -96,6 +96,10 @@ var AuthenticationService = /** @class */ (function () {
|
|
|
96
96
|
case 1:
|
|
97
97
|
tokenResponse = _a.sent();
|
|
98
98
|
if (!tokenResponse.success) return [3 /*break*/, 3];
|
|
99
|
+
// CSM CASE
|
|
100
|
+
if (tokenResponse.data.accessToken === null && tokenResponse.data.role.includes('ROLE_CSM')) {
|
|
101
|
+
return [2 /*return*/, { success: true, data: tokenResponse.data }];
|
|
102
|
+
}
|
|
99
103
|
Logger_1.default.info(tokenResponse);
|
|
100
104
|
(0, CookieUtils_1.createCookie)(tokenCookie, tokenResponse.data.accessToken);
|
|
101
105
|
return [4 /*yield*/, UserService_1.default.getCurrentUser(appType)];
|
|
@@ -119,6 +123,45 @@ var AuthenticationService = /** @class */ (function () {
|
|
|
119
123
|
});
|
|
120
124
|
});
|
|
121
125
|
};
|
|
126
|
+
AuthenticationService.ValidateSecurityCode = function (req) {
|
|
127
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
128
|
+
var tokenResponse, tokenCookie, userResponse, errorMsg, error_2, errorMessage;
|
|
129
|
+
return __generator(this, function (_a) {
|
|
130
|
+
switch (_a.label) {
|
|
131
|
+
case 0:
|
|
132
|
+
_a.trys.push([0, 5, , 6]);
|
|
133
|
+
return [4 /*yield*/, (0, ApiHelper_1.request)({
|
|
134
|
+
url: "".concat(ApiHelper_1.API_BASE_URL, "/check-security-code"),
|
|
135
|
+
method: Enums_1.APIMethod.POST,
|
|
136
|
+
body: JSON.stringify(req)
|
|
137
|
+
})];
|
|
138
|
+
case 1:
|
|
139
|
+
tokenResponse = _a.sent();
|
|
140
|
+
tokenCookie = CookieUtils_1.COOKIE_PRO_TOKEN;
|
|
141
|
+
if (!tokenResponse.success) return [3 /*break*/, 3];
|
|
142
|
+
Logger_1.default.info(tokenResponse);
|
|
143
|
+
(0, CookieUtils_1.createCookie)(tokenCookie, tokenResponse.data.accessToken);
|
|
144
|
+
return [4 /*yield*/, UserService_1.default.getCurrentUser(Enums_1.MovaAppType.GARAGE)];
|
|
145
|
+
case 2:
|
|
146
|
+
userResponse = _a.sent();
|
|
147
|
+
if (!userResponse || !userResponse.success) {
|
|
148
|
+
errorMsg = 'Erreur au chargement de votre profil';
|
|
149
|
+
Logger_1.default.error(errorMsg);
|
|
150
|
+
return [2 /*return*/, { success: false, error: errorMsg }];
|
|
151
|
+
}
|
|
152
|
+
return [2 /*return*/, { success: true, data: userResponse.data }];
|
|
153
|
+
case 3: return [2 /*return*/, tokenResponse];
|
|
154
|
+
case 4: return [3 /*break*/, 6];
|
|
155
|
+
case 5:
|
|
156
|
+
error_2 = _a.sent();
|
|
157
|
+
Logger_1.default.error('Error occurred during login:', error_2);
|
|
158
|
+
errorMessage = error_2 instanceof Error ? error_2.message : 'Erreur inconnue';
|
|
159
|
+
return [2 /*return*/, { success: false, error: errorMessage }];
|
|
160
|
+
case 6: return [2 /*return*/];
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
};
|
|
122
165
|
return AuthenticationService;
|
|
123
166
|
}());
|
|
124
167
|
exports.default = AuthenticationService;
|
|
@@ -39,7 +39,9 @@ export default class GarageService {
|
|
|
39
39
|
static createGarageSupplier(garageId: string, req: any): Promise<APIResponse<string>>;
|
|
40
40
|
static updateGarageSupplier(garageId: string, supplierId: number, req: any): Promise<APIResponse<string>>;
|
|
41
41
|
static updateGarage(garageId: string, req: any): Promise<APIResponse<string>>;
|
|
42
|
-
static getAdministratedGarages(
|
|
42
|
+
static getAdministratedGarages({ garageId }: {
|
|
43
|
+
garageId: string;
|
|
44
|
+
}): Promise<APIResponse<Garage>>;
|
|
43
45
|
static sendGarageSupportRequest(garageId: string, req: {
|
|
44
46
|
message: string;
|
|
45
47
|
}): Promise<APIResponse<string>>;
|
|
@@ -61,4 +63,6 @@ export default class GarageService {
|
|
|
61
63
|
static getOneGarageVehicle(garageId: string, vehicleId: number): Promise<APIResponse<any>>;
|
|
62
64
|
static assignGarageVehicleEvent(garageId: string, eventId: string, vehicleId: number): Promise<APIResponse<string>>;
|
|
63
65
|
static deassignGarageVehicleEvent(garageId: string, eventId: string): Promise<APIResponse<string>>;
|
|
66
|
+
static getGaragesCsm(): Promise<APIResponse<Garage[]>>;
|
|
67
|
+
static getOneGarageCsm(garageId: string): Promise<APIResponse<Garage[]>>;
|
|
64
68
|
}
|
|
@@ -287,9 +287,10 @@ var GarageService = /** @class */ (function () {
|
|
|
287
287
|
body: JSON.stringify(req)
|
|
288
288
|
});
|
|
289
289
|
};
|
|
290
|
-
GarageService.getAdministratedGarages = function () {
|
|
290
|
+
GarageService.getAdministratedGarages = function (_a) {
|
|
291
|
+
var garageId = _a.garageId;
|
|
291
292
|
return (0, ApiHelper_1.request)({
|
|
292
|
-
url: "".concat(ApiHelper_1.API_BASE_URL, "/user/
|
|
293
|
+
url: "".concat(ApiHelper_1.API_BASE_URL, "/user/garage/").concat(garageId),
|
|
293
294
|
method: Enums_1.APIMethod.GET,
|
|
294
295
|
appType: Enums_1.MovaAppType.GARAGE
|
|
295
296
|
});
|
|
@@ -379,6 +380,21 @@ var GarageService = /** @class */ (function () {
|
|
|
379
380
|
appType: Enums_1.MovaAppType.GARAGE
|
|
380
381
|
});
|
|
381
382
|
};
|
|
383
|
+
// CSM
|
|
384
|
+
GarageService.getGaragesCsm = function () {
|
|
385
|
+
return (0, ApiHelper_1.request)({
|
|
386
|
+
url: "".concat(ApiHelper_1.API_BASE_URL, "/csm/garages/list"),
|
|
387
|
+
method: Enums_1.APIMethod.GET,
|
|
388
|
+
appType: Enums_1.MovaAppType.GARAGE
|
|
389
|
+
});
|
|
390
|
+
};
|
|
391
|
+
GarageService.getOneGarageCsm = function (garageId) {
|
|
392
|
+
return (0, ApiHelper_1.request)({
|
|
393
|
+
url: "".concat(ApiHelper_1.API_BASE_URL, "/csm/garage/").concat(garageId),
|
|
394
|
+
method: Enums_1.APIMethod.GET,
|
|
395
|
+
appType: Enums_1.MovaAppType.GARAGE
|
|
396
|
+
});
|
|
397
|
+
};
|
|
382
398
|
return GarageService;
|
|
383
399
|
}());
|
|
384
400
|
exports.default = GarageService;
|
package/package.json
CHANGED
|
@@ -63,7 +63,13 @@ const VehiclePlateField: FunctionComponent<VehiclePlateFieldProps> = ({ onValidV
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
case VehiclePlateFormat.FRENCH_OLD: {
|
|
66
|
-
setHelperText(
|
|
66
|
+
setHelperText(
|
|
67
|
+
<>
|
|
68
|
+
Format détecté (ancien) : <b>1111 AAAA 1111</b>
|
|
69
|
+
<br />
|
|
70
|
+
Pour lancer la recherche, cliquez sur <SearchIcon />
|
|
71
|
+
</>
|
|
72
|
+
);
|
|
67
73
|
handleChangeFrenchOld(inputValue);
|
|
68
74
|
break;
|
|
69
75
|
}
|
package/src/helpers/Enums.ts
CHANGED
package/src/models/User.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Gender, RoleType } from "../helpers/Enums";
|
|
2
2
|
import Address from './Address';
|
|
3
|
+
import Garage from "./Garage";
|
|
3
4
|
import Role from "./Role";
|
|
4
5
|
import Vehicle from "./Vehicle";
|
|
5
6
|
|
|
@@ -21,6 +22,7 @@ export default class User {
|
|
|
21
22
|
vehicles?: Vehicle[];
|
|
22
23
|
isActive?: Boolean;
|
|
23
24
|
hasPassword?: Boolean;
|
|
25
|
+
garages?: Garage[];
|
|
24
26
|
|
|
25
27
|
constructor(
|
|
26
28
|
id: string,
|
|
@@ -37,7 +39,8 @@ export default class User {
|
|
|
37
39
|
phoneNumber?: string ,
|
|
38
40
|
vehicles?: Vehicle[],
|
|
39
41
|
isActive?: Boolean,
|
|
40
|
-
hasPassword?: Boolean
|
|
42
|
+
hasPassword?: Boolean,
|
|
43
|
+
garages?: Garage[]
|
|
41
44
|
) {
|
|
42
45
|
this.id = id;
|
|
43
46
|
this.roles = roles;
|
|
@@ -54,6 +57,7 @@ export default class User {
|
|
|
54
57
|
this.vehicles = vehicles;
|
|
55
58
|
this.isActive = isActive;
|
|
56
59
|
this.hasPassword = hasPassword;
|
|
60
|
+
this.garages = garages;
|
|
57
61
|
}
|
|
58
62
|
|
|
59
63
|
static getFirstLetter = (user: User) : string => {
|
|
@@ -86,6 +90,12 @@ export default class User {
|
|
|
86
90
|
return Boolean(user.roles.find(r => r.name === RoleType.SALES));
|
|
87
91
|
}
|
|
88
92
|
|
|
93
|
+
static isCsM = (user: User) : boolean => {
|
|
94
|
+
if(!user || !user.roles) return false;
|
|
95
|
+
|
|
96
|
+
return Boolean(user.roles.find(r => r.name === RoleType.CSM));
|
|
97
|
+
}
|
|
98
|
+
|
|
89
99
|
static isSuperAdmin = (user: User) : boolean => {
|
|
90
100
|
if(!user || !user.roles) return false;
|
|
91
101
|
|
|
@@ -52,7 +52,10 @@ export default class AuthenticationService {
|
|
|
52
52
|
});
|
|
53
53
|
|
|
54
54
|
if(tokenResponse.success){
|
|
55
|
-
|
|
55
|
+
// CSM CASE
|
|
56
|
+
if (tokenResponse.data.accessToken === null && tokenResponse.data.role.includes('ROLE_CSM')) {
|
|
57
|
+
return { success: true, data: tokenResponse.data };
|
|
58
|
+
}
|
|
56
59
|
Logger.info(tokenResponse);
|
|
57
60
|
|
|
58
61
|
createCookie(tokenCookie, tokenResponse.data.accessToken);
|
|
@@ -80,4 +83,44 @@ export default class AuthenticationService {
|
|
|
80
83
|
return { success: false, error: errorMessage };
|
|
81
84
|
}
|
|
82
85
|
}
|
|
86
|
+
static async ValidateSecurityCode(req: { securityCode: string }): Promise<APIResponse<User>> {
|
|
87
|
+
try {
|
|
88
|
+
//For now it's only for CSM
|
|
89
|
+
const tokenResponse = await request({
|
|
90
|
+
url: `${API_BASE_URL}/check-security-code`,
|
|
91
|
+
method: APIMethod.POST,
|
|
92
|
+
body: JSON.stringify(req)
|
|
93
|
+
});
|
|
94
|
+
const tokenCookie = COOKIE_PRO_TOKEN;
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
if (tokenResponse.success) {
|
|
98
|
+
|
|
99
|
+
Logger.info(tokenResponse);
|
|
100
|
+
|
|
101
|
+
createCookie(tokenCookie, tokenResponse.data.accessToken);
|
|
102
|
+
|
|
103
|
+
// Si le login est un succès, on renvoie les infos de l'utilisateur connecté
|
|
104
|
+
let userResponse = await UserService.getCurrentUser(MovaAppType.GARAGE);
|
|
105
|
+
|
|
106
|
+
if (!userResponse || !userResponse.success) {
|
|
107
|
+
const errorMsg = 'Erreur au chargement de votre profil';
|
|
108
|
+
Logger.error(errorMsg);
|
|
109
|
+
return { success: false, error: errorMsg };
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return { success: true, data: userResponse.data };
|
|
113
|
+
|
|
114
|
+
} else {
|
|
115
|
+
|
|
116
|
+
return tokenResponse;
|
|
117
|
+
|
|
118
|
+
}
|
|
119
|
+
}catch (error: unknown) {
|
|
120
|
+
Logger.error('Error occurred during login:', error);
|
|
121
|
+
let errorMessage = error instanceof Error ? error.message : 'Erreur inconnue';
|
|
122
|
+
|
|
123
|
+
return { success: false, error: errorMessage };
|
|
124
|
+
}
|
|
125
|
+
}
|
|
83
126
|
}
|
|
@@ -316,9 +316,9 @@ export default class GarageService {
|
|
|
316
316
|
});
|
|
317
317
|
}
|
|
318
318
|
|
|
319
|
-
static getAdministratedGarages(): Promise<APIResponse<Garage
|
|
319
|
+
static getAdministratedGarages({garageId}: {garageId: string}): Promise<APIResponse<Garage>> {
|
|
320
320
|
return request({
|
|
321
|
-
url: `${API_BASE_URL}/user/
|
|
321
|
+
url: `${API_BASE_URL}/user/garage/${garageId}`,
|
|
322
322
|
method: APIMethod.GET,
|
|
323
323
|
appType: MovaAppType.GARAGE
|
|
324
324
|
});
|
|
@@ -415,4 +415,22 @@ export default class GarageService {
|
|
|
415
415
|
appType: MovaAppType.GARAGE
|
|
416
416
|
})
|
|
417
417
|
}
|
|
418
|
+
|
|
419
|
+
// CSM
|
|
420
|
+
static getGaragesCsm(): Promise<APIResponse<Garage[]>> {
|
|
421
|
+
return request({
|
|
422
|
+
url: `${API_BASE_URL}/csm/garages/list`,
|
|
423
|
+
method: APIMethod.GET,
|
|
424
|
+
appType: MovaAppType.GARAGE
|
|
425
|
+
});
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
static getOneGarageCsm(garageId: string): Promise<APIResponse<Garage[]>> {
|
|
429
|
+
return request({
|
|
430
|
+
url: `${API_BASE_URL}/csm/garage/${garageId}`,
|
|
431
|
+
method: APIMethod.GET,
|
|
432
|
+
appType: MovaAppType.GARAGE
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
|
|
418
436
|
}
|
|
Binary file
|