@movalib/movalib-commons 1.59.8 → 1.59.10
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/AccountValidation.js +8 -1
- package/dist/src/MovaSignUp.js +27 -2
- package/dist/src/VehiclePlateField.js +1 -1
- package/dist/src/components/singup/ActivateAccount.js +26 -17
- package/dist/src/helpers/ApiHelper.js +5 -5
- 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/dist/src/services/UserService.d.ts +1 -0
- package/dist/src/services/UserService.js +9 -1
- package/index.ts +1 -0
- package/package.json +1 -1
- package/src/AccountValidation.tsx +9 -2
- package/src/MovaSignUp.tsx +48 -20
- package/src/VehiclePlateField.tsx +7 -1
- package/src/components/singup/ActivateAccount.tsx +273 -0
- package/src/helpers/ApiHelper.ts +5 -5
- 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/src/services/UserService.ts +19 -1
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);
|
|
@@ -54,6 +54,7 @@ var AccountValidation = function (_a) {
|
|
|
54
54
|
var _j = (0, react_1.useState)(false), showPassword = _j[0], setShowPassword = _j[1];
|
|
55
55
|
var _k = (0, react_1.useState)(false), openPhoneNumberInput = _k[0], setOpenPhoneNumberInput = _k[1];
|
|
56
56
|
var isMobile = (0, material_1.useMediaQuery)(theme.breakpoints.down('sm'));
|
|
57
|
+
var _l = (0, react_1.useState)(false), loadingBtn = _l[0], setLoadingBtn = _l[1];
|
|
57
58
|
(0, react_1.useEffect)(function () {
|
|
58
59
|
var params = location !== undefined ? new URLSearchParams(location.search) : undefined;
|
|
59
60
|
if (params !== undefined) {
|
|
@@ -92,6 +93,7 @@ var AccountValidation = function (_a) {
|
|
|
92
93
|
}, [location]);
|
|
93
94
|
var resetUserPassword = function (req) {
|
|
94
95
|
if (req) {
|
|
96
|
+
setLoadingBtn(true);
|
|
95
97
|
UserService_1.default.reestPassword(req)
|
|
96
98
|
.then(function (response) {
|
|
97
99
|
var _a, _b;
|
|
@@ -111,11 +113,14 @@ var AccountValidation = function (_a) {
|
|
|
111
113
|
if (onSubmit) {
|
|
112
114
|
onSubmit(false, error);
|
|
113
115
|
}
|
|
116
|
+
}).finally(function () {
|
|
117
|
+
setLoadingBtn(false);
|
|
114
118
|
});
|
|
115
119
|
}
|
|
116
120
|
};
|
|
117
121
|
var activateUserAccount = function (req) {
|
|
118
122
|
if (req) {
|
|
123
|
+
setLoadingBtn(true);
|
|
119
124
|
UserService_1.default.validateAccount(req)
|
|
120
125
|
.then(function (response) {
|
|
121
126
|
var _a;
|
|
@@ -135,6 +140,8 @@ var AccountValidation = function (_a) {
|
|
|
135
140
|
if (onSubmit) {
|
|
136
141
|
onSubmit(false, error);
|
|
137
142
|
}
|
|
143
|
+
}).finally(function () {
|
|
144
|
+
setLoadingBtn(false);
|
|
138
145
|
});
|
|
139
146
|
}
|
|
140
147
|
};
|
|
@@ -255,7 +262,7 @@ var AccountValidation = function (_a) {
|
|
|
255
262
|
return ((0, jsx_runtime_1.jsxs)("div", { children: [(emptyPwd || smsValidation || resetPassword || true) &&
|
|
256
263
|
(0, jsx_runtime_1.jsx)(MovaDialog_1.default, __assign({ leafImageColor: 'pink', titleStyle: getTitleStyle(), fullScreen: isMobile, open: emptyPwd || smsValidation || resetPassword || true, closable: false, onClose: function () {
|
|
257
264
|
throw new Error('Function not implemented.');
|
|
258
|
-
}, actions: (0, jsx_runtime_1.jsx)(lab_1.LoadingButton, __assign({ type: "submit", onClick: handleValidateAccount, fullWidth: true, variant: "contained", sx: { mt: 4, mb: 0 } }, { children: resetPassword ? (0, jsx_runtime_1.jsx)("span", { children: "R\u00E9initialiser mon mot de passe" }) : (0, jsx_runtime_1.jsx)("span", { children: "Activer mon compte" }) })) }, { children: (0, jsx_runtime_1.jsxs)(material_1.Grid, __assign({ container: true }, { children: [(0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 12 }, { children: (0, jsx_runtime_1.jsxs)(material_1.Box, __assign({ sx: {
|
|
265
|
+
}, actions: (0, jsx_runtime_1.jsx)(lab_1.LoadingButton, __assign({ loading: loadingBtn, type: "submit", onClick: handleValidateAccount, fullWidth: true, variant: "contained", sx: { mt: 4, mb: 0 } }, { children: resetPassword ? (0, jsx_runtime_1.jsx)("span", { children: "R\u00E9initialiser mon mot de passe" }) : (0, jsx_runtime_1.jsx)("span", { children: "Activer mon compte" }) })) }, { children: (0, jsx_runtime_1.jsxs)(material_1.Grid, __assign({ container: true }, { children: [(0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 12 }, { children: (0, jsx_runtime_1.jsxs)(material_1.Box, __assign({ sx: {
|
|
259
266
|
display: 'flex',
|
|
260
267
|
flexDirection: 'column',
|
|
261
268
|
alignItems: 'center',
|
package/dist/src/MovaSignUp.js
CHANGED
|
@@ -69,6 +69,7 @@ var InputAdornment_1 = __importDefault(require("@mui/material/InputAdornment"));
|
|
|
69
69
|
var Visibility_1 = __importDefault(require("@mui/icons-material/Visibility"));
|
|
70
70
|
var VisibilityOff_1 = __importDefault(require("@mui/icons-material/VisibilityOff"));
|
|
71
71
|
var Info_1 = __importDefault(require("@mui/icons-material/Info"));
|
|
72
|
+
var UserService_1 = __importDefault(require("./services/UserService"));
|
|
72
73
|
// ATTENTION : s'assurer de la présence des documents suivants à la racine du composant porteur (dossier 'public')
|
|
73
74
|
var CGUPath = "/Movalib_CGU.pdf";
|
|
74
75
|
// Permet de centrer le contenu de l'application
|
|
@@ -100,6 +101,8 @@ var MovaSignUp = function (_a) {
|
|
|
100
101
|
var _r = (0, react_1.useState)(false), showPassword = _r[0], setShowPassword = _r[1];
|
|
101
102
|
var _s = (0, react_1.useState)(false), openEmailInfo = _s[0], setOpenEmailInfo = _s[1];
|
|
102
103
|
var _t = (0, react_1.useState)(false), openPhoneNumberInfo = _t[0], setOpenPhoneNumberInfo = _t[1];
|
|
104
|
+
var _u = (0, react_1.useState)(false), userExist = _u[0], setUserExist = _u[1];
|
|
105
|
+
var _v = (0, react_1.useState)(false), userIsAlreadyActive = _v[0], setUserIsAlreadyActive = _v[1];
|
|
103
106
|
var handleDateChange = function (name, date) {
|
|
104
107
|
var _a;
|
|
105
108
|
if (name && date) {
|
|
@@ -121,6 +124,28 @@ var MovaSignUp = function (_a) {
|
|
|
121
124
|
if (fieldValue.length > 10) {
|
|
122
125
|
fieldValue = fieldValue.substring(0, 10);
|
|
123
126
|
}
|
|
127
|
+
if (fieldValue.length === 10) {
|
|
128
|
+
UserService_1.default.existsByPhoneNumber(fieldValue).then(function (response) {
|
|
129
|
+
if (response && response.data) {
|
|
130
|
+
if (response.data.isActive === false) {
|
|
131
|
+
setUserExist(true);
|
|
132
|
+
setUserIsAlreadyActive(false);
|
|
133
|
+
}
|
|
134
|
+
else if (response.data.isActive === true) {
|
|
135
|
+
setUserIsAlreadyActive(true);
|
|
136
|
+
setUserExist(false);
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
setUserExist(false);
|
|
140
|
+
setUserIsAlreadyActive(false);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
setUserExist(false);
|
|
147
|
+
setUserIsAlreadyActive(false);
|
|
148
|
+
}
|
|
124
149
|
}
|
|
125
150
|
// Capitalisation automatique du prénom
|
|
126
151
|
if (fieldName == "firstname") {
|
|
@@ -230,8 +255,8 @@ var MovaSignUp = function (_a) {
|
|
|
230
255
|
borderColor: darkMode ? 'white' : 'default', // Couleur de la bordure
|
|
231
256
|
}
|
|
232
257
|
} }), usePhoneNumber && (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.TextField, { type: "tel", margin: "normal", required: true, fullWidth: true, id: "phoneNumber", label: "N\u00B0 de t\u00E9l\u00E9phone", name: "phoneNumber", autoComplete: "tel", disabled: userToEdit && userToEdit.phoneNumber ? true : false, onChange: function (e) { return handleInputChange(e); }, value: userForm.phoneNumber.value, error: Boolean(userForm.phoneNumber.error), helperText: userForm.phoneNumber.error, InputProps: {
|
|
233
|
-
endAdornment: ((0, jsx_runtime_1.jsx)(InputAdornment_1.default, __assign({ position: "end" }, { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, __assign({ edge: "end", onClick: function () { return setOpenPhoneNumberInfo(!openPhoneNumberInfo); } }, { children: (0, jsx_runtime_1.jsx)(Info_1.default, {}) })) }))),
|
|
234
|
-
} }), openPhoneNumberInfo && (0, jsx_runtime_1.jsx)(material_1.Alert, __assign({ severity: "info", variant: 'standard' }, { children: "Entrez le num\u00E9ro de t\u00E9l\u00E9phone que vous avez utilis\u00E9 pour r\u00E9server, afin de suivre facilement vos rendez-vous." }))] }), (0, jsx_runtime_1.jsx)(material_1.TextField, { margin: "normal", required: true, fullWidth: true, id: "email", label: "Adresse email", name: "email", autoComplete: "email", disabled: userToEdit && userToEdit.email ? true : false, onChange: function (e) { return handleInputChange(e); }, value: userForm.email.value, error: !userForm.email.isValid, helperText: userForm.email.error, sx: {
|
|
258
|
+
endAdornment: ((0, jsx_runtime_1.jsx)(InputAdornment_1.default, __assign({ position: "end" }, { children: !userExist && (0, jsx_runtime_1.jsx)(material_1.IconButton, __assign({ edge: "end", onClick: function () { return setOpenPhoneNumberInfo(!openPhoneNumberInfo); } }, { children: (0, jsx_runtime_1.jsx)(Info_1.default, {}) })) }))),
|
|
259
|
+
} }), openPhoneNumberInfo && !userExist && (0, jsx_runtime_1.jsx)(material_1.Alert, __assign({ severity: "info", variant: 'standard' }, { children: "Entrez le num\u00E9ro de t\u00E9l\u00E9phone que vous avez utilis\u00E9 pour r\u00E9server, afin de suivre facilement vos rendez-vous." })), userExist && (0, jsx_runtime_1.jsx)(material_1.Alert, __assign({ severity: "success", variant: 'standard' }, { children: "Rendez-vous trouv\u00E9(s) pour ce num\u00E9ro ! Vous pourrez le(s) consulter apr\u00E8s avoir cr\u00E9\u00E9 votre compte." })), userIsAlreadyActive && (0, jsx_runtime_1.jsx)(material_1.Alert, __assign({ severity: "error", sx: { marginTop: '5px' }, variant: 'standard' }, { children: "Il semble qu\u2019un compte existe d\u00E9j\u00E0 avec ce num\u00E9ro. Connectez-vous ou utilisez \"Mot de passe oubli\u00E9\" pour y acc\u00E9der facilement." }))] }), (0, jsx_runtime_1.jsx)(material_1.TextField, { margin: "normal", required: true, fullWidth: true, id: "email", label: "Adresse email", name: "email", autoComplete: "email", disabled: userToEdit && userToEdit.email ? true : false, onChange: function (e) { return handleInputChange(e); }, value: userForm.email.value, error: !userForm.email.isValid, helperText: userForm.email.error, sx: {
|
|
235
260
|
'& .MuiOutlinedInput-notchedOutline': {
|
|
236
261
|
borderColor: darkMode ? 'white' : 'default', // Couleur de la bordure
|
|
237
262
|
}
|
|
@@ -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
|
}
|
|
@@ -44,7 +44,6 @@ var ActivateAccount = function (_a) {
|
|
|
44
44
|
setUnknowCode(false);
|
|
45
45
|
var params = location !== undefined ? new URLSearchParams(location.search) : undefined;
|
|
46
46
|
var req = {
|
|
47
|
-
appType: Enums_1.MovaAppType.INDIVIDUAL,
|
|
48
47
|
token: !smsValidation ? params === null || params === void 0 ? void 0 : params.get('token') : null,
|
|
49
48
|
securityCode: smsValidation ? code : null,
|
|
50
49
|
demoGarage: Boolean(params === null || params === void 0 ? void 0 : params.get('demoGarage'))
|
|
@@ -58,7 +57,7 @@ var ActivateAccount = function (_a) {
|
|
|
58
57
|
if (data === null || data === void 0 ? void 0 : data.expiredCode) {
|
|
59
58
|
setExpiredCode(true);
|
|
60
59
|
}
|
|
61
|
-
if (data === null || data === void 0 ? void 0 : data.
|
|
60
|
+
if (data === null || data === void 0 ? void 0 : data.unknownCode) {
|
|
62
61
|
setUnknowCode(true);
|
|
63
62
|
}
|
|
64
63
|
}
|
|
@@ -86,7 +85,7 @@ var ActivateAccount = function (_a) {
|
|
|
86
85
|
//success or Error this is parent component responsability
|
|
87
86
|
Logger_1.default.info(response);
|
|
88
87
|
if (response.success) {
|
|
89
|
-
onSubmit(response.success, (_a = response.data) !== null && _a !== void 0 ? _a : 'Le compte a été mis à
|
|
88
|
+
onSubmit(response.success, (_a = response.data) !== null && _a !== void 0 ? _a : 'Le compte a été mis à jour et activé avec succès');
|
|
90
89
|
history.push('/login');
|
|
91
90
|
}
|
|
92
91
|
else {
|
|
@@ -143,7 +142,7 @@ var ActivateAccount = function (_a) {
|
|
|
143
142
|
var req = {
|
|
144
143
|
phoneNumber: (_a = validationForm.phoneNumber) === null || _a === void 0 ? void 0 : _a.value
|
|
145
144
|
};
|
|
146
|
-
UserService_1.default.
|
|
145
|
+
UserService_1.default.resendActivationAccount(req)
|
|
147
146
|
.then(function (response) {
|
|
148
147
|
var _a, _b;
|
|
149
148
|
Logger_1.default.info(response);
|
|
@@ -162,18 +161,28 @@ var ActivateAccount = function (_a) {
|
|
|
162
161
|
});
|
|
163
162
|
}
|
|
164
163
|
};
|
|
165
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [currentUser !== null && (0, jsx_runtime_1.jsx)(MovaSignUp_1.default, { movaAppType: movaAppType, onSubmit: updateActivateUseronSubmit, alertMessage: alertMessage, alertSeverity: alertSeverity, userToEdit: currentUser, loading: loading }), expiredCode && ((0, jsx_runtime_1.
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
164
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [currentUser !== null && (0, jsx_runtime_1.jsx)(MovaSignUp_1.default, { movaAppType: movaAppType, onSubmit: updateActivateUseronSubmit, alertMessage: alertMessage, alertSeverity: alertSeverity, userToEdit: currentUser, loading: loading }), expiredCode && ((0, jsx_runtime_1.jsx)(material_1.Box, __assign({ sx: { width: '99vw', height: '99vh', display: 'flex' } }, { children: (0, jsx_runtime_1.jsxs)(material_1.Box, __assign({ sx: {
|
|
165
|
+
display: 'block',
|
|
166
|
+
margin: 'auto',
|
|
167
|
+
textAlign: 'center',
|
|
168
|
+
padding: 3,
|
|
169
|
+
borderRadius: 2,
|
|
170
|
+
boxShadow: 3,
|
|
171
|
+
maxWidth: 400,
|
|
172
|
+
backgroundColor: 'white',
|
|
173
|
+
} }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "h6", color: "error", gutterBottom: true }, { children: "Code de validation expir\u00E9" })), (0, jsx_runtime_1.jsxs)(material_1.Typography, { children: [(0, jsx_runtime_1.jsx)("b", { children: "Indiquez nous votre num\u00E9ro de t\u00E9l\u00E9phone." }), (0, jsx_runtime_1.jsx)("br", {}), "Nous allons renvoyer un SMS d'activation de compte"] }), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 6 }, { children: (0, jsx_runtime_1.jsx)(material_1.TextField, { margin: "normal", fullWidth: true, required: true, id: "phoneNumber", label: "N\u00B0 de t\u00E9l\u00E9phone", name: "phoneNumber", autoComplete: "tel", onChange: function (e) { return handleInputChange(e); }, value: validationForm.phoneNumber.value, error: Boolean(validationForm.phoneNumber.error), helperText: validationForm.phoneNumber.error }) })), (0, jsx_runtime_1.jsx)(material_1.Button, __assign({ onClick: resendCode, sx: { cursor: 'pointer', textAlign: 'center', width: '100%', mt: 1 } }, { children: "Renvoyer le code" }))] })) }))), unknowCode && ((0, jsx_runtime_1.jsx)(material_1.Box, __assign({ sx: { width: '99vw', height: '99vh', display: 'flex' } }, { children: (0, jsx_runtime_1.jsxs)(material_1.Box, __assign({ sx: {
|
|
174
|
+
display: 'flex',
|
|
175
|
+
flexDirection: 'column',
|
|
176
|
+
alignItems: 'center',
|
|
177
|
+
justifyContent: 'center',
|
|
178
|
+
height: '100%',
|
|
179
|
+
width: '100%',
|
|
180
|
+
margin: 'auto',
|
|
181
|
+
textAlign: 'center',
|
|
182
|
+
padding: 3,
|
|
183
|
+
borderRadius: 2,
|
|
184
|
+
boxShadow: 3,
|
|
185
|
+
backgroundColor: 'white',
|
|
186
|
+
} }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "h6", color: "error", gutterBottom: true }, { children: "Code de validation invalide" })), (0, jsx_runtime_1.jsxs)(material_1.Typography, __assign({ variant: "body1", color: "textSecondary", gutterBottom: true }, { children: ["Le code de validation fourni ne correspond \u00E0 aucun utilisateur (ou votre compte a d\u00E9j\u00E0 \u00E9t\u00E9 activ\u00E9). ", (0, jsx_runtime_1.jsx)("br", {}), "Essayez de vous connecter avec votre num\u00E9ro de t\u00E9l\u00E9phone.", (0, jsx_runtime_1.jsx)("br", {}), "Si le probl\u00E8me persiste, veuillez nous contacter \u00E0", ' ', (0, jsx_runtime_1.jsx)("b", { children: "support@movalib.com" }), "."] })), (0, jsx_runtime_1.jsx)(material_1.Button, __assign({ variant: "contained", color: "primary", onClick: function (e) { return history.push('/login'); }, sx: { marginTop: 2 } }, { children: "Retour \u00E0 la connexion" }))] })) })))] }));
|
|
178
187
|
};
|
|
179
188
|
exports.default = ActivateAccount;
|
|
@@ -25,19 +25,19 @@ function handleResponse(response) {
|
|
|
25
25
|
var errorMsg = void 0;
|
|
26
26
|
switch (response.status) {
|
|
27
27
|
case 403:
|
|
28
|
-
errorMsg = 'Accès non autorisé
|
|
28
|
+
errorMsg = 'Accès non autorisé';
|
|
29
29
|
break;
|
|
30
30
|
case 404:
|
|
31
|
-
errorMsg = 'La ressource demandée est introuvable
|
|
31
|
+
errorMsg = (typeof data === 'string') ? data : 'La ressource demandée est introuvable';
|
|
32
32
|
break;
|
|
33
33
|
case 500:
|
|
34
|
-
errorMsg = 'Une erreur interne du serveur est survenue
|
|
34
|
+
errorMsg = 'Une erreur interne du serveur est survenue';
|
|
35
35
|
break;
|
|
36
36
|
default:
|
|
37
|
-
errorMsg = (typeof data === 'string') ? data : "Une erreur est survenue
|
|
37
|
+
errorMsg = (typeof data === 'string') ? data : "Une erreur est survenue";
|
|
38
38
|
break;
|
|
39
39
|
}
|
|
40
|
-
return { success: false, error: errorMsg };
|
|
40
|
+
return { success: false, error: errorMsg, data: data };
|
|
41
41
|
}
|
|
42
42
|
return { success: true, data: data };
|
|
43
43
|
});
|
|
@@ -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;
|
|
@@ -7,6 +7,7 @@ export default class UserService {
|
|
|
7
7
|
static existsByPhoneNumber(phoneNumber: string): Promise<APIResponse<User>>;
|
|
8
8
|
static reestPassword(req: any): Promise<APIResponse<string>>;
|
|
9
9
|
static resendSecurityCode(req: any): Promise<APIResponse<string>>;
|
|
10
|
+
static resendActivationAccount(req: any): Promise<APIResponse<string>>;
|
|
10
11
|
static getSalesGarages(salesId: string): Promise<APIResponse<Garage[]>>;
|
|
11
12
|
static validateAccount(req: any): Promise<APIResponse<User | {
|
|
12
13
|
expiredCode?: boolean;
|
|
@@ -73,6 +73,14 @@ var UserService = /** @class */ (function () {
|
|
|
73
73
|
body: JSON.stringify(req)
|
|
74
74
|
});
|
|
75
75
|
};
|
|
76
|
+
UserService.resendActivationAccount = function (req) {
|
|
77
|
+
return (0, ApiHelper_1.request)({
|
|
78
|
+
url: "".concat(ApiHelper_1.API_BASE_URL, "/user/resend-activation-link"),
|
|
79
|
+
method: Enums_1.APIMethod.POST,
|
|
80
|
+
appType: Enums_1.MovaAppType.INDIVIDUAL,
|
|
81
|
+
body: JSON.stringify(req)
|
|
82
|
+
});
|
|
83
|
+
};
|
|
76
84
|
UserService.getSalesGarages = function (salesId) {
|
|
77
85
|
return (0, ApiHelper_1.request)({
|
|
78
86
|
url: "".concat(ApiHelper_1.API_BASE_URL, "/sales/").concat(salesId, "/garages"),
|
|
@@ -90,7 +98,7 @@ var UserService = /** @class */ (function () {
|
|
|
90
98
|
};
|
|
91
99
|
UserService.editUser = function (req, userId) {
|
|
92
100
|
return (0, ApiHelper_1.request)({
|
|
93
|
-
url: "".concat(ApiHelper_1.API_BASE_URL, "/user/").concat(userId),
|
|
101
|
+
url: "".concat(ApiHelper_1.API_BASE_URL, "/user/").concat(userId, "/complete"),
|
|
94
102
|
method: Enums_1.APIMethod.PATCH,
|
|
95
103
|
appType: Enums_1.MovaAppType.INDIVIDUAL,
|
|
96
104
|
body: JSON.stringify(req)
|
package/index.ts
CHANGED
|
@@ -28,6 +28,7 @@ export { default as MovaCopyright } from './src/MovaCopyright';
|
|
|
28
28
|
export { default as MovaVehicleTireField } from './src/MovaVehicleTireField';
|
|
29
29
|
export { default as ConfirmationDialog } from './src/ConfirmationDialog';
|
|
30
30
|
export { default as GenderSelector } from './src/GenderSelector';
|
|
31
|
+
export { default as ActivateAccount } from './src/components/singup/ActivateAccount';
|
|
31
32
|
export { QrCodePLVContainer } from './src/components/QrCodePLVContainer/QrCodePLVContainer';
|
|
32
33
|
export { PLVComponent, PrintSize } from './src/components/QrCodePLVContainer/PLVComponent';
|
|
33
34
|
// Export des classes
|
package/package.json
CHANGED
|
@@ -48,6 +48,7 @@ const AccountValidation: FunctionComponent<AccountValidationProps> = ({ movaAppT
|
|
|
48
48
|
const [showPassword, setShowPassword] = useState(false);
|
|
49
49
|
const [openPhoneNumberInput, setOpenPhoneNumberInput] = useState<boolean>(false);
|
|
50
50
|
const isMobile = useMediaQuery(theme.breakpoints.down('sm'));
|
|
51
|
+
const [loadingBtn, setLoadingBtn] = useState<boolean>(false);
|
|
51
52
|
|
|
52
53
|
useEffect(() => {
|
|
53
54
|
|
|
@@ -99,6 +100,7 @@ const AccountValidation: FunctionComponent<AccountValidationProps> = ({ movaAppT
|
|
|
99
100
|
|
|
100
101
|
const resetUserPassword = (req: any) => {
|
|
101
102
|
if(req){
|
|
103
|
+
setLoadingBtn(true);
|
|
102
104
|
|
|
103
105
|
UserService.reestPassword(req)
|
|
104
106
|
.then(response => {
|
|
@@ -120,13 +122,15 @@ const AccountValidation: FunctionComponent<AccountValidationProps> = ({ movaAppT
|
|
|
120
122
|
if(onSubmit){
|
|
121
123
|
onSubmit(false, error);
|
|
122
124
|
}
|
|
125
|
+
}).finally(() => {
|
|
126
|
+
setLoadingBtn(false);
|
|
123
127
|
});
|
|
124
128
|
}
|
|
125
129
|
}
|
|
126
130
|
|
|
127
131
|
const activateUserAccount = (req: any) => {
|
|
128
132
|
if(req){
|
|
129
|
-
|
|
133
|
+
setLoadingBtn(true);
|
|
130
134
|
UserService.validateAccount(req)
|
|
131
135
|
.then(response => {
|
|
132
136
|
|
|
@@ -134,7 +138,7 @@ const AccountValidation: FunctionComponent<AccountValidationProps> = ({ movaAppT
|
|
|
134
138
|
|
|
135
139
|
if(response.success){
|
|
136
140
|
if(onSubmit){
|
|
137
|
-
onSubmit(response.success,
|
|
141
|
+
onSubmit(response.success, 'Le compte a été activé avec succès.');
|
|
138
142
|
}
|
|
139
143
|
}else{
|
|
140
144
|
if(onSubmit){
|
|
@@ -147,6 +151,8 @@ const AccountValidation: FunctionComponent<AccountValidationProps> = ({ movaAppT
|
|
|
147
151
|
if(onSubmit){
|
|
148
152
|
onSubmit(false, error);
|
|
149
153
|
}
|
|
154
|
+
}).finally(() => {
|
|
155
|
+
setLoadingBtn(false);
|
|
150
156
|
});
|
|
151
157
|
}
|
|
152
158
|
}
|
|
@@ -311,6 +317,7 @@ const AccountValidation: FunctionComponent<AccountValidationProps> = ({ movaAppT
|
|
|
311
317
|
}}
|
|
312
318
|
actions={
|
|
313
319
|
<LoadingButton
|
|
320
|
+
loading={loadingBtn}
|
|
314
321
|
type="submit"
|
|
315
322
|
onClick={handleValidateAccount}
|
|
316
323
|
fullWidth
|
package/src/MovaSignUp.tsx
CHANGED
|
@@ -22,6 +22,8 @@ import VisibilityOff from '@mui/icons-material/VisibilityOff';
|
|
|
22
22
|
import InfoIcon from '@mui/icons-material/Info';
|
|
23
23
|
import isValid from 'date-fns/isValid';
|
|
24
24
|
import Logger from "./helpers/Logger";
|
|
25
|
+
import User from "./models/User";
|
|
26
|
+
import UserService from "./services/UserService";
|
|
25
27
|
|
|
26
28
|
// ATTENTION : s'assurer de la présence des documents suivants à la racine du composant porteur (dossier 'public')
|
|
27
29
|
const CGUPath:string = "/Movalib_CGU.pdf";
|
|
@@ -33,17 +35,6 @@ const styles: CSSProperties = {
|
|
|
33
35
|
alignItems: 'center'
|
|
34
36
|
};
|
|
35
37
|
|
|
36
|
-
const initialUserFormState = {
|
|
37
|
-
firstname: { value: '', isValid: true },
|
|
38
|
-
lastname: { value: '', isValid: true },
|
|
39
|
-
email: { value: '', isValid: true },
|
|
40
|
-
phoneNumber: { value: '', isValid: true },
|
|
41
|
-
password: { value: '', isValid: true },
|
|
42
|
-
gender: { value: '', isValid: true },
|
|
43
|
-
birthDate: { value: null, isValid: true },
|
|
44
|
-
acceptsTerms: { value: false, isValid: true },
|
|
45
|
-
};
|
|
46
|
-
|
|
47
38
|
/**
|
|
48
39
|
* Propriétés du composant
|
|
49
40
|
* movaAppType : type d'application Movalib au sein de laquelle le composant est injectée
|
|
@@ -66,6 +57,7 @@ interface MovaSignUpProps {
|
|
|
66
57
|
showLoginButton?: boolean,
|
|
67
58
|
disableGutters?: boolean,
|
|
68
59
|
usePhoneNumber?: boolean
|
|
60
|
+
userToEdit?: User,
|
|
69
61
|
}
|
|
70
62
|
|
|
71
63
|
/**
|
|
@@ -73,16 +65,28 @@ interface MovaSignUpProps {
|
|
|
73
65
|
* ATTENTION : le lien de consultation des CGU doit pointer vers "/terms-and-conditions"
|
|
74
66
|
*/
|
|
75
67
|
const MovaSignUp: FunctionComponent<MovaSignUpProps> = ({ loading, movaAppType, onSubmit, darkMode = false, alertMessage, alertSeverity, headerText,
|
|
76
|
-
showHeaderLogo = true, showLeafs= true, showCopyright = true, showLoginButton = true, disableGutters = false, usePhoneNumber = true}) => {
|
|
77
|
-
|
|
78
|
-
const [userForm, setUserForm] = useState<MovaUserSignUpForm>(
|
|
68
|
+
showHeaderLogo = true, showLeafs= true, showCopyright = true, showLoginButton = true, disableGutters = false, usePhoneNumber = true, userToEdit = null}) => {
|
|
69
|
+
|
|
70
|
+
const [userForm, setUserForm] = useState<MovaUserSignUpForm>(
|
|
71
|
+
{
|
|
72
|
+
firstname: { value: userToEdit?.firstname ?? '', isValid: true },
|
|
73
|
+
lastname: { value: userToEdit?.lastname ?? '', isValid: true },
|
|
74
|
+
email: { value: userToEdit?.email ?? '', isValid: true },
|
|
75
|
+
phoneNumber: { value: userToEdit?.phoneNumber ?? '', isValid: true },
|
|
76
|
+
password: { value: '', isValid: true },
|
|
77
|
+
gender: { value: '', isValid: true },
|
|
78
|
+
birthDate: { value: null, isValid: true },
|
|
79
|
+
acceptsTerms: { value: false, isValid: true },
|
|
80
|
+
}
|
|
81
|
+
);
|
|
79
82
|
const history = useHistory();
|
|
80
83
|
const [message, setMessage] = useState<string>("");
|
|
81
84
|
const theme = useTheme();
|
|
82
85
|
const [showPassword, setShowPassword] = useState(false);
|
|
83
86
|
const [openEmailInfo, setOpenEmailInfo] = useState(false);
|
|
84
87
|
const [openPhoneNumberInfo, setOpenPhoneNumberInfo] = useState(false);
|
|
85
|
-
|
|
88
|
+
const [userExist, setUserExist] = useState<boolean>(false);
|
|
89
|
+
const [userIsAlreadyActive, setUserIsAlreadyActive] = useState<boolean>(false);
|
|
86
90
|
const handleDateChange = (name: string, date: Date | null) => {
|
|
87
91
|
|
|
88
92
|
if(name && date){
|
|
@@ -106,6 +110,25 @@ const MovaSignUp: FunctionComponent<MovaSignUpProps> = ({ loading, movaAppType,
|
|
|
106
110
|
if (fieldValue.length > 10) {
|
|
107
111
|
fieldValue = fieldValue.substring(0, 10);
|
|
108
112
|
}
|
|
113
|
+
if (fieldValue.length === 10){
|
|
114
|
+
UserService.existsByPhoneNumber(fieldValue).then((response) => {
|
|
115
|
+
if(response && response.data){
|
|
116
|
+
if(response.data.isActive === false){
|
|
117
|
+
setUserExist(true);
|
|
118
|
+
setUserIsAlreadyActive(false);
|
|
119
|
+
} else if (response.data.isActive === true){
|
|
120
|
+
setUserIsAlreadyActive(true);
|
|
121
|
+
setUserExist(false);
|
|
122
|
+
} else {
|
|
123
|
+
setUserExist(false);
|
|
124
|
+
setUserIsAlreadyActive(false);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
})
|
|
128
|
+
} else {
|
|
129
|
+
setUserExist(false);
|
|
130
|
+
setUserIsAlreadyActive(false);
|
|
131
|
+
}
|
|
109
132
|
}
|
|
110
133
|
|
|
111
134
|
// Capitalisation automatique du prénom
|
|
@@ -285,24 +308,28 @@ const MovaSignUp: FunctionComponent<MovaSignUpProps> = ({ loading, movaAppType,
|
|
|
285
308
|
id="phoneNumber"
|
|
286
309
|
label="N° de téléphone"
|
|
287
310
|
name="phoneNumber"
|
|
288
|
-
autoComplete="tel"
|
|
311
|
+
autoComplete="tel"
|
|
312
|
+
disabled={userToEdit && userToEdit.phoneNumber ? true : false}
|
|
289
313
|
onChange={e => handleInputChange(e)}
|
|
290
314
|
value={userForm.phoneNumber.value}
|
|
291
315
|
error={Boolean(userForm.phoneNumber.error)}
|
|
292
316
|
helperText={userForm.phoneNumber.error}
|
|
293
317
|
InputProps={{
|
|
294
318
|
endAdornment: (
|
|
295
|
-
|
|
296
|
-
|
|
319
|
+
<InputAdornment position="end">
|
|
320
|
+
{!userExist && <IconButton
|
|
297
321
|
edge="end"
|
|
298
322
|
onClick={() => setOpenPhoneNumberInfo(!openPhoneNumberInfo)}
|
|
299
323
|
><InfoIcon />
|
|
300
|
-
</IconButton>
|
|
324
|
+
</IconButton>}
|
|
301
325
|
</InputAdornment>
|
|
302
326
|
),
|
|
303
327
|
}}
|
|
304
328
|
/>
|
|
305
|
-
{openPhoneNumberInfo && <Alert severity="info" variant='standard'>Entrez le numéro de téléphone que vous avez utilisé pour réserver, afin de suivre facilement vos rendez-vous.</Alert>}
|
|
329
|
+
{openPhoneNumberInfo && !userExist && <Alert severity="info" variant='standard'>Entrez le numéro de téléphone que vous avez utilisé pour réserver, afin de suivre facilement vos rendez-vous.</Alert>}
|
|
330
|
+
{userExist && <Alert severity="success" variant='standard'>Rendez-vous trouvé(s) pour ce numéro ! Vous pourrez le(s) consulter après avoir créé votre compte.</Alert>}
|
|
331
|
+
{userIsAlreadyActive && <Alert severity="error" sx={{marginTop: '5px'}} variant='standard'>Il semble qu’un compte existe déjà avec ce numéro. Connectez-vous ou utilisez "Mot de passe oublié" pour y accéder facilement.</Alert>}
|
|
332
|
+
|
|
306
333
|
</>
|
|
307
334
|
}
|
|
308
335
|
<TextField
|
|
@@ -313,6 +340,7 @@ const MovaSignUp: FunctionComponent<MovaSignUpProps> = ({ loading, movaAppType,
|
|
|
313
340
|
label="Adresse email"
|
|
314
341
|
name="email"
|
|
315
342
|
autoComplete="email"
|
|
343
|
+
disabled={userToEdit && userToEdit.email ? true : false}
|
|
316
344
|
onChange={e => handleInputChange(e)}
|
|
317
345
|
value={userForm.email.value}
|
|
318
346
|
error={!userForm.email.isValid}
|
|
@@ -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
|
}
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
import { CSSProperties, FunctionComponent, useEffect, useState } from 'react';
|
|
2
|
+
import { useHistory, useLocation, useParams } from 'react-router-dom';
|
|
3
|
+
import UserService from '../../services/UserService';
|
|
4
|
+
import { AlertColor, Box, Button, Checkbox, CircularProgress, FormControl, FormControlLabel, FormHelperText, Grid, IconButton, Link, SelectChangeEvent, TextField, Typography, colors, darken, useMediaQuery, useTheme } from '@mui/material';
|
|
5
|
+
import Logger from '../../helpers/Logger';
|
|
6
|
+
import { MovaAppType } from '../../helpers/Enums';
|
|
7
|
+
import { MovaFormField, MovaUserSignUpForm, MovaValidationForm } from '../../helpers/Types';
|
|
8
|
+
import { flexStart, validateField } from '../../helpers/Tools';
|
|
9
|
+
import User from '../../models/User';
|
|
10
|
+
import { set } from 'date-fns';
|
|
11
|
+
import MovaSignUp from '../../MovaSignUp';
|
|
12
|
+
import { validatePhoneNumber } from '../../helpers/Validator';
|
|
13
|
+
|
|
14
|
+
interface RouteParams {
|
|
15
|
+
code: string; // Définissez ici les paramètres de route attendus
|
|
16
|
+
}
|
|
17
|
+
interface ActivateAccountProps {
|
|
18
|
+
movaAppType: MovaAppType,
|
|
19
|
+
smsValidation: boolean,
|
|
20
|
+
onSubmit: (success: boolean, message: string) => void,
|
|
21
|
+
onResendSecurityCode?: (success: boolean, message: string) => void,
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
const ActivateAccount: FunctionComponent<ActivateAccountProps> = ({ movaAppType, smsValidation, onSubmit, onResendSecurityCode }) => {
|
|
26
|
+
const { code } = useParams<RouteParams>();
|
|
27
|
+
const location = useLocation();
|
|
28
|
+
const theme = useTheme();
|
|
29
|
+
const [alertMessage, setAlertMessage] = useState<string>("");
|
|
30
|
+
// La sévérité est initialiée à "error" par défaut
|
|
31
|
+
const [alertSeverity, setAlertSeverity] = useState<AlertColor>('error');
|
|
32
|
+
const [loading, setLoading] = useState(false);
|
|
33
|
+
const [currentUser, setCurrentUser] = useState<User | null>(null);
|
|
34
|
+
const [expiredCode, setExpiredCode] = useState(false);
|
|
35
|
+
const [unknowCode, setUnknowCode] = useState(false);
|
|
36
|
+
const [validationForm, setValidationForm] = useState<any>({ phoneNumber: { value: '', isValid: true } });
|
|
37
|
+
|
|
38
|
+
const history = useHistory();
|
|
39
|
+
// ajout d'un load pour le chargement de la page
|
|
40
|
+
const getUserByTokenOrCode = () => {
|
|
41
|
+
setExpiredCode(false);
|
|
42
|
+
setUnknowCode(false);
|
|
43
|
+
const params = location !== undefined ? new URLSearchParams(location.search) : undefined;
|
|
44
|
+
let req = {
|
|
45
|
+
token: !smsValidation ? params?.get('token') : null,
|
|
46
|
+
securityCode: smsValidation ? code : null,
|
|
47
|
+
demoGarage: Boolean(params?.get('demoGarage'))
|
|
48
|
+
}
|
|
49
|
+
UserService.validateAccount(req).then(response => {
|
|
50
|
+
if (response.success) {
|
|
51
|
+
setCurrentUser(response.data as User);
|
|
52
|
+
} else {
|
|
53
|
+
const data = response.data as { expiredCode?: boolean, unknownCode?: boolean };
|
|
54
|
+
if (data?.expiredCode) {
|
|
55
|
+
setExpiredCode(true);
|
|
56
|
+
}
|
|
57
|
+
if (data?.unknownCode) {
|
|
58
|
+
setUnknowCode(true);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
})
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
useEffect(() => {
|
|
65
|
+
getUserByTokenOrCode();
|
|
66
|
+
}, []);
|
|
67
|
+
|
|
68
|
+
const updateActivateUseronSubmit = (form: MovaUserSignUpForm) => {
|
|
69
|
+
// appelle api pour mettre a jour l'utilisateur + auto activate en fonction du movaAPPType
|
|
70
|
+
if (movaAppType === MovaAppType.INDIVIDUAL && currentUser) {
|
|
71
|
+
setLoading(true);
|
|
72
|
+
try {
|
|
73
|
+
|
|
74
|
+
// On prépare la query
|
|
75
|
+
let query = {
|
|
76
|
+
code: code,
|
|
77
|
+
email: form.email.value,
|
|
78
|
+
password: form.password.value,
|
|
79
|
+
firstname: form.firstname.value,
|
|
80
|
+
lastname: form.lastname.value,
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
UserService.editUser(query, currentUser.id)
|
|
84
|
+
.then(response => {
|
|
85
|
+
//success or Error this is parent component responsability
|
|
86
|
+
Logger.info(response);
|
|
87
|
+
if (response.success) {
|
|
88
|
+
onSubmit(response.success, response.data ?? 'Le compte a été mis à jour et activé avec succès');
|
|
89
|
+
history.push('/login');
|
|
90
|
+
} else {
|
|
91
|
+
onSubmit(response.success, response.error ?? 'Erreur lors de la mise à jour du compte');
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
}).catch(error => {
|
|
95
|
+
onSubmit(false, 'Erreur lors de la mise à jour du compte');
|
|
96
|
+
Logger.error(error);
|
|
97
|
+
setAlertMessage(error);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
} catch (error) {
|
|
101
|
+
console.error('Error occurred during submission:', error);
|
|
102
|
+
} finally {
|
|
103
|
+
setLoading(false);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
}
|
|
109
|
+
const controlPhoneNumber = (): boolean => {
|
|
110
|
+
|
|
111
|
+
let newForm: MovaValidationForm = validationForm;
|
|
112
|
+
let newField: MovaFormField;
|
|
113
|
+
|
|
114
|
+
newForm.phoneNumber = validateField(validationForm.phoneNumber, value => !!value, 'Champ obligatoire');
|
|
115
|
+
|
|
116
|
+
// Validator 'phoneNumber'
|
|
117
|
+
if (newForm.phoneNumber?.value) {
|
|
118
|
+
if (newForm.phoneNumber?.value.length < 10) {
|
|
119
|
+
newField = { value: validationForm.phoneNumber?.value, error: "Le n° de téléphone est invalide." };
|
|
120
|
+
} else {
|
|
121
|
+
newField = { value: validationForm.phoneNumber?.value, error: '' };
|
|
122
|
+
}
|
|
123
|
+
newForm = { ...newForm, ...{ phoneNumber: newField } };
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
setValidationForm(newForm);
|
|
127
|
+
|
|
128
|
+
return !Boolean(newForm.phoneNumber?.error);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
const handleInputChange = (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement> | null): void => {
|
|
133
|
+
if (e) {
|
|
134
|
+
const fieldName: string = e.target.name;
|
|
135
|
+
const fieldValue: string = e.target.value;
|
|
136
|
+
const newField: MovaFormField = { [fieldName]: { value: fieldValue, isValid: true } };
|
|
137
|
+
|
|
138
|
+
if (fieldName == "phoneNumber") {
|
|
139
|
+
if (!validatePhoneNumber(fieldValue))
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
setValidationForm({ ...validationForm, ...newField });
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const resendCode = () => {
|
|
148
|
+
|
|
149
|
+
if (controlPhoneNumber() && onResendSecurityCode) {
|
|
150
|
+
|
|
151
|
+
let req = {
|
|
152
|
+
phoneNumber: validationForm.phoneNumber?.value
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
UserService.resendActivationAccount(req)
|
|
156
|
+
.then(response => {
|
|
157
|
+
|
|
158
|
+
Logger.info(response);
|
|
159
|
+
|
|
160
|
+
if (response.success) {
|
|
161
|
+
onResendSecurityCode(response.success, response.data ?? '');
|
|
162
|
+
} else {
|
|
163
|
+
onResendSecurityCode(response.success, response.error ?? '');
|
|
164
|
+
}
|
|
165
|
+
history.push('/login');
|
|
166
|
+
|
|
167
|
+
}).catch(error => {
|
|
168
|
+
Logger.error(error);
|
|
169
|
+
if (onSubmit) {
|
|
170
|
+
onSubmit(false, error);
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
return (
|
|
177
|
+
<>
|
|
178
|
+
{currentUser !== null && <MovaSignUp
|
|
179
|
+
movaAppType={movaAppType}
|
|
180
|
+
onSubmit={updateActivateUseronSubmit}
|
|
181
|
+
alertMessage={alertMessage}
|
|
182
|
+
alertSeverity={alertSeverity}
|
|
183
|
+
userToEdit={currentUser}
|
|
184
|
+
loading={loading} />}
|
|
185
|
+
{expiredCode && (
|
|
186
|
+
<Box sx={{ width: '99vw', height: '99vh', display: 'flex' }}>
|
|
187
|
+
<Box
|
|
188
|
+
sx={{
|
|
189
|
+
display: 'block',
|
|
190
|
+
margin: 'auto',
|
|
191
|
+
textAlign: 'center',
|
|
192
|
+
padding: 3,
|
|
193
|
+
borderRadius: 2,
|
|
194
|
+
boxShadow: 3,
|
|
195
|
+
maxWidth: 400,
|
|
196
|
+
backgroundColor: 'white',
|
|
197
|
+
}}
|
|
198
|
+
>
|
|
199
|
+
<Typography variant="h6" color="error" gutterBottom>
|
|
200
|
+
Code de validation expiré
|
|
201
|
+
</Typography>
|
|
202
|
+
<Typography><b>Indiquez nous votre numéro de téléphone.</b><br />Nous allons renvoyer un SMS d'activation de compte</Typography>
|
|
203
|
+
<Grid item xs={6}>
|
|
204
|
+
<TextField
|
|
205
|
+
margin="normal"
|
|
206
|
+
fullWidth
|
|
207
|
+
required
|
|
208
|
+
id="phoneNumber"
|
|
209
|
+
label="N° de téléphone"
|
|
210
|
+
name="phoneNumber"
|
|
211
|
+
autoComplete="tel"
|
|
212
|
+
onChange={e => handleInputChange(e)}
|
|
213
|
+
value={validationForm.phoneNumber.value}
|
|
214
|
+
error={Boolean(validationForm.phoneNumber.error)}
|
|
215
|
+
helperText={validationForm.phoneNumber.error}
|
|
216
|
+
/>
|
|
217
|
+
</Grid>
|
|
218
|
+
<Button
|
|
219
|
+
onClick={resendCode}
|
|
220
|
+
sx={{ cursor: 'pointer', textAlign: 'center', width: '100%', mt: 1 }}
|
|
221
|
+
>
|
|
222
|
+
Renvoyer le code
|
|
223
|
+
</Button>
|
|
224
|
+
</Box>
|
|
225
|
+
</Box>
|
|
226
|
+
)}
|
|
227
|
+
{unknowCode && (
|
|
228
|
+
<Box sx={{ width: '99vw', height: '99vh', display: 'flex' }}>
|
|
229
|
+
<Box
|
|
230
|
+
sx={{
|
|
231
|
+
display: 'flex',
|
|
232
|
+
flexDirection: 'column',
|
|
233
|
+
alignItems: 'center',
|
|
234
|
+
justifyContent: 'center',
|
|
235
|
+
height: '100%',
|
|
236
|
+
width: '100%',
|
|
237
|
+
margin: 'auto',
|
|
238
|
+
textAlign: 'center',
|
|
239
|
+
padding: 3,
|
|
240
|
+
borderRadius: 2,
|
|
241
|
+
boxShadow: 3,
|
|
242
|
+
backgroundColor: 'white',
|
|
243
|
+
}}
|
|
244
|
+
>
|
|
245
|
+
<Typography variant="h6" color="error" gutterBottom>
|
|
246
|
+
Code de validation invalide
|
|
247
|
+
</Typography>
|
|
248
|
+
<Typography variant="body1" color="textSecondary" gutterBottom>
|
|
249
|
+
Le code de validation fourni ne correspond à aucun utilisateur (ou votre compte a déjà été activé). <br />
|
|
250
|
+
Essayez de vous connecter avec votre numéro de téléphone.
|
|
251
|
+
<br />
|
|
252
|
+
Si le problème persiste, veuillez nous contacter à{' '}
|
|
253
|
+
<b>support@movalib.com</b>.
|
|
254
|
+
</Typography>
|
|
255
|
+
<Button
|
|
256
|
+
variant="contained"
|
|
257
|
+
color="primary"
|
|
258
|
+
onClick={(e) => history.push('/login')}
|
|
259
|
+
sx={{ marginTop: 2 }}
|
|
260
|
+
>
|
|
261
|
+
Retour à la connexion
|
|
262
|
+
</Button>
|
|
263
|
+
</Box>
|
|
264
|
+
</Box>
|
|
265
|
+
)}
|
|
266
|
+
|
|
267
|
+
</>
|
|
268
|
+
);
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
export default ActivateAccount;
|
|
272
|
+
|
|
273
|
+
|
package/src/helpers/ApiHelper.ts
CHANGED
|
@@ -55,16 +55,16 @@ function handleResponse(response: Response): Promise<APIResponse<any>> {
|
|
|
55
55
|
|
|
56
56
|
switch(response.status){
|
|
57
57
|
case 403:
|
|
58
|
-
errorMsg = 'Accès non autorisé
|
|
58
|
+
errorMsg = 'Accès non autorisé'; break;
|
|
59
59
|
case 404:
|
|
60
|
-
errorMsg = 'La ressource demandée est introuvable
|
|
60
|
+
errorMsg = (typeof data === 'string') ? data : 'La ressource demandée est introuvable'; break;
|
|
61
61
|
case 500:
|
|
62
|
-
errorMsg = 'Une erreur interne du serveur est survenue
|
|
62
|
+
errorMsg = 'Une erreur interne du serveur est survenue'; break;
|
|
63
63
|
default:
|
|
64
|
-
errorMsg = (typeof data === 'string') ? data : `Une erreur est survenue
|
|
64
|
+
errorMsg = (typeof data === 'string') ? data : `Une erreur est survenue`; break;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
return { success: false, error: errorMsg };
|
|
67
|
+
return { success: false, error: errorMsg, data: data };
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
return { success: true, data };
|
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
|
}
|
|
@@ -38,6 +38,15 @@ export default class UserService {
|
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
static resendActivationAccount(req: any): Promise<APIResponse<string>> {
|
|
42
|
+
return request({
|
|
43
|
+
url: `${API_BASE_URL}/user/resend-activation-link`,
|
|
44
|
+
method: APIMethod.POST,
|
|
45
|
+
appType: MovaAppType.INDIVIDUAL,
|
|
46
|
+
body: JSON.stringify(req)
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
41
50
|
static getSalesGarages(salesId: string,): Promise<APIResponse<Garage[]>> {
|
|
42
51
|
return request({
|
|
43
52
|
url: `${API_BASE_URL}/sales/${salesId}/garages`,
|
|
@@ -46,7 +55,7 @@ export default class UserService {
|
|
|
46
55
|
});
|
|
47
56
|
}
|
|
48
57
|
|
|
49
|
-
static validateAccount(req: any): Promise<APIResponse<
|
|
58
|
+
static validateAccount(req: any): Promise<APIResponse<User | {expiredCode?:boolean, unknowCode?: boolean}>> {
|
|
50
59
|
return request({
|
|
51
60
|
url: `${API_BASE_URL}/user/validate-account`,
|
|
52
61
|
method: APIMethod.POST,
|
|
@@ -55,6 +64,15 @@ export default class UserService {
|
|
|
55
64
|
});
|
|
56
65
|
}
|
|
57
66
|
|
|
67
|
+
static editUser(req: any, userId: string): Promise<APIResponse<string>> {
|
|
68
|
+
return request({
|
|
69
|
+
url: `${API_BASE_URL}/user/${userId}/complete`,
|
|
70
|
+
method: APIMethod.PATCH,
|
|
71
|
+
appType: MovaAppType.INDIVIDUAL,
|
|
72
|
+
body: JSON.stringify(req)
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
|
|
58
76
|
/**
|
|
59
77
|
* @param email
|
|
60
78
|
* @param password
|