@movalib/movalib-commons 1.59.8 → 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/index.d.ts +0 -1
- package/dist/index.js +2 -4
- package/dist/src/AccountValidation.js +3 -3
- package/dist/src/MovaSignUp.d.ts +0 -2
- package/dist/src/MovaSignUp.js +18 -18
- 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/dist/src/services/UserService.d.ts +1 -5
- package/dist/src/services/UserService.js +0 -8
- 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/dist/src/components/singup/ActivateAccount.d.ts +0 -10
- package/dist/src/components/singup/ActivateAccount.js +0 -179
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);
|
package/dist/index.d.ts
CHANGED
|
@@ -22,7 +22,6 @@ export { default as MovaCopyright } from './src/MovaCopyright';
|
|
|
22
22
|
export { default as MovaVehicleTireField } from './src/MovaVehicleTireField';
|
|
23
23
|
export { default as ConfirmationDialog } from './src/ConfirmationDialog';
|
|
24
24
|
export { default as GenderSelector } from './src/GenderSelector';
|
|
25
|
-
export { default as ActivateAccount } from './src/components/singup/ActivateAccount';
|
|
26
25
|
export { QrCodePLVContainer } from './src/components/QrCodePLVContainer/QrCodePLVContainer';
|
|
27
26
|
export { PLVComponent, PrintSize } from './src/components/QrCodePLVContainer/PLVComponent';
|
|
28
27
|
export { default as Subscription } from './src/models/Subscription';
|
package/dist/index.js
CHANGED
|
@@ -4,8 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
5
|
};
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.CategoryPrestation = exports.VehicleTire = exports.Event = exports.Schedule = exports.VehicleGarage = exports.Garage = exports.Document = exports.Vehicle = exports.Address = exports.Role = exports.User = exports.Customer = exports.Logger = exports.Operation = exports.Prestation = exports.Product = exports.Supplier = exports.Employee = exports.Absence = exports.Subscription = exports.PrintSize = exports.PLVComponent = exports.QrCodePLVContainer = exports.
|
|
8
|
-
exports.openDialogPrint = exports.APIMethod = exports.SubscriptionType = exports.SubscriptionState = exports.CountryCode = exports.PrestationState = exports.PrestationType = exports.RegistrationState = exports.SubscriptionPaymentInterval = exports.VehiclePlateType = exports.SlotAlgorithm = exports.OrderState = exports.OrderPreference = exports.ProductType = exports.PartsApplicationType = exports.DateFormatTypes = exports.Gender = exports.DocumentState = exports.DigitalPassportIndex = exports.DocumentType = exports.EventType = exports.EventState = exports.DayOfWeek = exports.MovaAppType = exports.RoleType = exports.CustomerType = exports.API_BASE_URL = exports.request = exports.getLongFormattedDateTime = exports.formatDateByCountryCode = exports.validateEmail = exports.validateText = exports.validatePhoneNumber = exports.getApplicationsShortLabels = exports.isSafariOniOS = exports.getDayOfWeekLabel = exports.findScheduleByDayOfWeek = exports.getFormattedIntervals = exports.getFormattedSchedule = exports.formatPhoneNumber = exports.flexLeftRow = exports.capitalizeFirstLetter = exports.getApplicationShortLabel = exports.isEmpty = exports.formatFrenchVehiclePlate = exports.formatVehicleTire = exports.validateField = exports.deleteCookie =
|
|
7
|
+
exports.readCookie = exports.CategoryPrestation = exports.VehicleTire = exports.Event = exports.Schedule = exports.VehicleGarage = exports.Garage = exports.Document = exports.Vehicle = exports.Address = exports.Role = exports.User = exports.Customer = exports.Logger = exports.Operation = exports.Prestation = exports.Product = exports.Supplier = exports.Employee = exports.Absence = exports.Subscription = exports.PrintSize = exports.PLVComponent = exports.QrCodePLVContainer = exports.GenderSelector = exports.ConfirmationDialog = exports.MovaVehicleTireField = exports.MovaCopyright = exports.MovaSignUp = exports.MovaLogin = exports.MovaSnackbar = exports.TestButton = exports.oldRegexPlate = exports.regexPlate = exports.VehiclePlateField = exports.QRCode = exports.MovaDialog = exports.Loader = exports.MovaDigitalPassport = exports.VehicleFullCard = exports.ScheduleFields = exports.AddressFields = exports.AccountValidation = exports.GaragePLV = exports.IbanInput = exports.DialogForgotPassword = exports.UserService = exports.GarageService = exports.AuthenticationService = exports.VehicleService = void 0;
|
|
8
|
+
exports.openDialogPrint = exports.APIMethod = exports.SubscriptionType = exports.SubscriptionState = exports.CountryCode = exports.PrestationState = exports.PrestationType = exports.RegistrationState = exports.SubscriptionPaymentInterval = exports.VehiclePlateType = exports.SlotAlgorithm = exports.OrderState = exports.OrderPreference = exports.ProductType = exports.PartsApplicationType = exports.DateFormatTypes = exports.Gender = exports.DocumentState = exports.DigitalPassportIndex = exports.DocumentType = exports.EventType = exports.EventState = exports.DayOfWeek = exports.MovaAppType = exports.RoleType = exports.CustomerType = exports.API_BASE_URL = exports.request = exports.getLongFormattedDateTime = exports.formatDateByCountryCode = exports.validateEmail = exports.validateText = exports.validatePhoneNumber = exports.getApplicationsShortLabels = exports.isSafariOniOS = exports.getDayOfWeekLabel = exports.findScheduleByDayOfWeek = exports.getFormattedIntervals = exports.getFormattedSchedule = exports.formatPhoneNumber = exports.flexLeftRow = exports.capitalizeFirstLetter = exports.getApplicationShortLabel = exports.isEmpty = exports.formatFrenchVehiclePlate = exports.formatVehicleTire = exports.validateField = exports.deleteCookie = void 0;
|
|
9
9
|
// Export des services
|
|
10
10
|
var VehicleService_1 = require("./src/services/VehicleService");
|
|
11
11
|
Object.defineProperty(exports, "VehicleService", { enumerable: true, get: function () { return __importDefault(VehicleService_1).default; } });
|
|
@@ -58,8 +58,6 @@ var ConfirmationDialog_1 = require("./src/ConfirmationDialog");
|
|
|
58
58
|
Object.defineProperty(exports, "ConfirmationDialog", { enumerable: true, get: function () { return __importDefault(ConfirmationDialog_1).default; } });
|
|
59
59
|
var GenderSelector_1 = require("./src/GenderSelector");
|
|
60
60
|
Object.defineProperty(exports, "GenderSelector", { enumerable: true, get: function () { return __importDefault(GenderSelector_1).default; } });
|
|
61
|
-
var ActivateAccount_1 = require("./src/components/singup/ActivateAccount");
|
|
62
|
-
Object.defineProperty(exports, "ActivateAccount", { enumerable: true, get: function () { return __importDefault(ActivateAccount_1).default; } });
|
|
63
61
|
var QrCodePLVContainer_1 = require("./src/components/QrCodePLVContainer/QrCodePLVContainer");
|
|
64
62
|
Object.defineProperty(exports, "QrCodePLVContainer", { enumerable: true, get: function () { return QrCodePLVContainer_1.QrCodePLVContainer; } });
|
|
65
63
|
var PLVComponent_1 = require("./src/components/QrCodePLVContainer/PLVComponent");
|
|
@@ -118,16 +118,16 @@ var AccountValidation = function (_a) {
|
|
|
118
118
|
if (req) {
|
|
119
119
|
UserService_1.default.validateAccount(req)
|
|
120
120
|
.then(function (response) {
|
|
121
|
-
var _a;
|
|
121
|
+
var _a, _b;
|
|
122
122
|
Logger_1.default.info(response);
|
|
123
123
|
if (response.success) {
|
|
124
124
|
if (onSubmit) {
|
|
125
|
-
onSubmit(response.success,
|
|
125
|
+
onSubmit(response.success, (_a = response.data) !== null && _a !== void 0 ? _a : '');
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
128
|
else {
|
|
129
129
|
if (onSubmit) {
|
|
130
|
-
onSubmit(response.success, (
|
|
130
|
+
onSubmit(response.success, (_b = response.error) !== null && _b !== void 0 ? _b : '');
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
133
|
}).catch(function (error) {
|
package/dist/src/MovaSignUp.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ import { FunctionComponent, ReactNode } from "react";
|
|
|
2
2
|
import { AlertColor } from "@mui/material";
|
|
3
3
|
import { MovaUserSignUpForm } from "./helpers/Types";
|
|
4
4
|
import { MovaAppType } from "./helpers/Enums";
|
|
5
|
-
import User from "./models/User";
|
|
6
5
|
/**
|
|
7
6
|
* Propriétés du composant
|
|
8
7
|
* movaAppType : type d'application Movalib au sein de laquelle le composant est injectée
|
|
@@ -25,7 +24,6 @@ interface MovaSignUpProps {
|
|
|
25
24
|
showLoginButton?: boolean;
|
|
26
25
|
disableGutters?: boolean;
|
|
27
26
|
usePhoneNumber?: boolean;
|
|
28
|
-
userToEdit?: User;
|
|
29
27
|
}
|
|
30
28
|
/**
|
|
31
29
|
* Formulaire de création d'un compte Movalib (Garage / Utilisateur)
|
package/dist/src/MovaSignUp.js
CHANGED
|
@@ -77,29 +77,29 @@ var styles = {
|
|
|
77
77
|
justifyContent: 'center',
|
|
78
78
|
alignItems: 'center'
|
|
79
79
|
};
|
|
80
|
+
var initialUserFormState = {
|
|
81
|
+
firstname: { value: '', isValid: true },
|
|
82
|
+
lastname: { value: '', isValid: true },
|
|
83
|
+
email: { value: '', isValid: true },
|
|
84
|
+
phoneNumber: { value: '', isValid: true },
|
|
85
|
+
password: { value: '', isValid: true },
|
|
86
|
+
gender: { value: '', isValid: true },
|
|
87
|
+
birthDate: { value: null, isValid: true },
|
|
88
|
+
acceptsTerms: { value: false, isValid: true },
|
|
89
|
+
};
|
|
80
90
|
/**
|
|
81
91
|
* Formulaire de création d'un compte Movalib (Garage / Utilisateur)
|
|
82
92
|
* ATTENTION : le lien de consultation des CGU doit pointer vers "/terms-and-conditions"
|
|
83
93
|
*/
|
|
84
94
|
var MovaSignUp = function (_a) {
|
|
85
|
-
var _b, _c, _d, _e;
|
|
86
|
-
var
|
|
87
|
-
var _p = (0, react_1.useState)({
|
|
88
|
-
firstname: { value: (_b = userToEdit === null || userToEdit === void 0 ? void 0 : userToEdit.firstname) !== null && _b !== void 0 ? _b : '', isValid: true },
|
|
89
|
-
lastname: { value: (_c = userToEdit === null || userToEdit === void 0 ? void 0 : userToEdit.lastname) !== null && _c !== void 0 ? _c : '', isValid: true },
|
|
90
|
-
email: { value: (_d = userToEdit === null || userToEdit === void 0 ? void 0 : userToEdit.email) !== null && _d !== void 0 ? _d : '', isValid: true },
|
|
91
|
-
phoneNumber: { value: (_e = userToEdit === null || userToEdit === void 0 ? void 0 : userToEdit.phoneNumber) !== null && _e !== void 0 ? _e : '', isValid: true },
|
|
92
|
-
password: { value: '', isValid: true },
|
|
93
|
-
gender: { value: '', isValid: true },
|
|
94
|
-
birthDate: { value: null, isValid: true },
|
|
95
|
-
acceptsTerms: { value: false, isValid: true },
|
|
96
|
-
}), userForm = _p[0], setUserForm = _p[1];
|
|
95
|
+
var loading = _a.loading, movaAppType = _a.movaAppType, onSubmit = _a.onSubmit, _b = _a.darkMode, darkMode = _b === void 0 ? false : _b, alertMessage = _a.alertMessage, alertSeverity = _a.alertSeverity, headerText = _a.headerText, _c = _a.showHeaderLogo, showHeaderLogo = _c === void 0 ? true : _c, _d = _a.showLeafs, showLeafs = _d === void 0 ? true : _d, _e = _a.showCopyright, showCopyright = _e === void 0 ? true : _e, _f = _a.showLoginButton, showLoginButton = _f === void 0 ? true : _f, _g = _a.disableGutters, disableGutters = _g === void 0 ? false : _g, _h = _a.usePhoneNumber, usePhoneNumber = _h === void 0 ? true : _h;
|
|
96
|
+
var _j = (0, react_1.useState)(initialUserFormState), userForm = _j[0], setUserForm = _j[1];
|
|
97
97
|
var history = (0, react_router_dom_1.useHistory)();
|
|
98
|
-
var
|
|
98
|
+
var _k = (0, react_1.useState)(""), message = _k[0], setMessage = _k[1];
|
|
99
99
|
var theme = (0, material_1.useTheme)();
|
|
100
|
-
var
|
|
101
|
-
var
|
|
102
|
-
var
|
|
100
|
+
var _l = (0, react_1.useState)(false), showPassword = _l[0], setShowPassword = _l[1];
|
|
101
|
+
var _m = (0, react_1.useState)(false), openEmailInfo = _m[0], setOpenEmailInfo = _m[1];
|
|
102
|
+
var _o = (0, react_1.useState)(false), openPhoneNumberInfo = _o[0], setOpenPhoneNumberInfo = _o[1];
|
|
103
103
|
var handleDateChange = function (name, date) {
|
|
104
104
|
var _a;
|
|
105
105
|
if (name && date) {
|
|
@@ -229,9 +229,9 @@ var MovaSignUp = function (_a) {
|
|
|
229
229
|
'& .MuiOutlinedInput-notchedOutline': {
|
|
230
230
|
borderColor: darkMode ? 'white' : 'default', // Couleur de la bordure
|
|
231
231
|
}
|
|
232
|
-
} }), 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",
|
|
232
|
+
} }), 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", onChange: function (e) { return handleInputChange(e); }, value: userForm.phoneNumber.value, error: Boolean(userForm.phoneNumber.error), helperText: userForm.phoneNumber.error, InputProps: {
|
|
233
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",
|
|
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", onChange: function (e) { return handleInputChange(e); }, value: userForm.email.value, error: !userForm.email.isValid, helperText: userForm.email.error, sx: {
|
|
235
235
|
'& .MuiOutlinedInput-notchedOutline': {
|
|
236
236
|
borderColor: darkMode ? 'white' : 'default', // Couleur de la bordure
|
|
237
237
|
}
|
|
@@ -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;
|
|
@@ -8,11 +8,7 @@ export default class UserService {
|
|
|
8
8
|
static reestPassword(req: any): Promise<APIResponse<string>>;
|
|
9
9
|
static resendSecurityCode(req: any): Promise<APIResponse<string>>;
|
|
10
10
|
static getSalesGarages(salesId: string): Promise<APIResponse<Garage[]>>;
|
|
11
|
-
static validateAccount(req: any): Promise<APIResponse<
|
|
12
|
-
expiredCode?: boolean;
|
|
13
|
-
unknowCode?: boolean;
|
|
14
|
-
}>>;
|
|
15
|
-
static editUser(req: any, userId: string): Promise<APIResponse<string>>;
|
|
11
|
+
static validateAccount(req: any): Promise<APIResponse<string>>;
|
|
16
12
|
/**
|
|
17
13
|
* @param email
|
|
18
14
|
* @param password
|
|
@@ -88,14 +88,6 @@ var UserService = /** @class */ (function () {
|
|
|
88
88
|
body: JSON.stringify(req)
|
|
89
89
|
});
|
|
90
90
|
};
|
|
91
|
-
UserService.editUser = function (req, userId) {
|
|
92
|
-
return (0, ApiHelper_1.request)({
|
|
93
|
-
url: "".concat(ApiHelper_1.API_BASE_URL, "/user/").concat(userId),
|
|
94
|
-
method: Enums_1.APIMethod.PATCH,
|
|
95
|
-
appType: Enums_1.MovaAppType.INDIVIDUAL,
|
|
96
|
-
body: JSON.stringify(req)
|
|
97
|
-
});
|
|
98
|
-
};
|
|
99
91
|
/**
|
|
100
92
|
* @param email
|
|
101
93
|
* @param password
|
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
|
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { FunctionComponent } from 'react';
|
|
2
|
-
import { MovaAppType } from '../../helpers/Enums';
|
|
3
|
-
interface ActivateAccountProps {
|
|
4
|
-
movaAppType: MovaAppType;
|
|
5
|
-
smsValidation: boolean;
|
|
6
|
-
onSubmit: (success: boolean, message: string) => void;
|
|
7
|
-
onResendSecurityCode?: (success: boolean, message: string) => void;
|
|
8
|
-
}
|
|
9
|
-
declare const ActivateAccount: FunctionComponent<ActivateAccountProps>;
|
|
10
|
-
export default ActivateAccount;
|
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
18
|
-
var react_1 = require("react");
|
|
19
|
-
var react_router_dom_1 = require("react-router-dom");
|
|
20
|
-
var UserService_1 = __importDefault(require("../../services/UserService"));
|
|
21
|
-
var material_1 = require("@mui/material");
|
|
22
|
-
var Logger_1 = __importDefault(require("../../helpers/Logger"));
|
|
23
|
-
var Enums_1 = require("../../helpers/Enums");
|
|
24
|
-
var Tools_1 = require("../../helpers/Tools");
|
|
25
|
-
var MovaSignUp_1 = __importDefault(require("../../MovaSignUp"));
|
|
26
|
-
var Validator_1 = require("../../helpers/Validator");
|
|
27
|
-
var ActivateAccount = function (_a) {
|
|
28
|
-
var movaAppType = _a.movaAppType, smsValidation = _a.smsValidation, onSubmit = _a.onSubmit, onResendSecurityCode = _a.onResendSecurityCode;
|
|
29
|
-
var code = (0, react_router_dom_1.useParams)().code;
|
|
30
|
-
var location = (0, react_router_dom_1.useLocation)();
|
|
31
|
-
var theme = (0, material_1.useTheme)();
|
|
32
|
-
var _b = (0, react_1.useState)(""), alertMessage = _b[0], setAlertMessage = _b[1];
|
|
33
|
-
// La sévérité est initialiée à "error" par défaut
|
|
34
|
-
var _c = (0, react_1.useState)('error'), alertSeverity = _c[0], setAlertSeverity = _c[1];
|
|
35
|
-
var _d = (0, react_1.useState)(false), loading = _d[0], setLoading = _d[1];
|
|
36
|
-
var _e = (0, react_1.useState)(null), currentUser = _e[0], setCurrentUser = _e[1];
|
|
37
|
-
var _f = (0, react_1.useState)(false), expiredCode = _f[0], setExpiredCode = _f[1];
|
|
38
|
-
var _g = (0, react_1.useState)(false), unknowCode = _g[0], setUnknowCode = _g[1];
|
|
39
|
-
var _h = (0, react_1.useState)({ phoneNumber: { value: '', isValid: true } }), validationForm = _h[0], setValidationForm = _h[1];
|
|
40
|
-
var history = (0, react_router_dom_1.useHistory)();
|
|
41
|
-
// ajout d'un load pour le chargement de la page
|
|
42
|
-
var getUserByTokenOrCode = function () {
|
|
43
|
-
setExpiredCode(false);
|
|
44
|
-
setUnknowCode(false);
|
|
45
|
-
var params = location !== undefined ? new URLSearchParams(location.search) : undefined;
|
|
46
|
-
var req = {
|
|
47
|
-
appType: Enums_1.MovaAppType.INDIVIDUAL,
|
|
48
|
-
token: !smsValidation ? params === null || params === void 0 ? void 0 : params.get('token') : null,
|
|
49
|
-
securityCode: smsValidation ? code : null,
|
|
50
|
-
demoGarage: Boolean(params === null || params === void 0 ? void 0 : params.get('demoGarage'))
|
|
51
|
-
};
|
|
52
|
-
UserService_1.default.validateAccount(req).then(function (response) {
|
|
53
|
-
if (response.success) {
|
|
54
|
-
setCurrentUser(response.data);
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
var data = response.data;
|
|
58
|
-
if (data === null || data === void 0 ? void 0 : data.expiredCode) {
|
|
59
|
-
setExpiredCode(true);
|
|
60
|
-
}
|
|
61
|
-
if (data === null || data === void 0 ? void 0 : data.unknowCode) {
|
|
62
|
-
setUnknowCode(true);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
};
|
|
67
|
-
(0, react_1.useEffect)(function () {
|
|
68
|
-
getUserByTokenOrCode();
|
|
69
|
-
}, []);
|
|
70
|
-
var updateActivateUseronSubmit = function (form) {
|
|
71
|
-
// appelle api pour mettre a jour l'utilisateur + auto activate en fonction du movaAPPType
|
|
72
|
-
if (movaAppType === Enums_1.MovaAppType.INDIVIDUAL && currentUser) {
|
|
73
|
-
setLoading(true);
|
|
74
|
-
try {
|
|
75
|
-
// On prépare la query
|
|
76
|
-
var query = {
|
|
77
|
-
code: code,
|
|
78
|
-
email: form.email.value,
|
|
79
|
-
password: form.password.value,
|
|
80
|
-
firstname: form.firstname.value,
|
|
81
|
-
lastname: form.lastname.value,
|
|
82
|
-
};
|
|
83
|
-
UserService_1.default.editUser(query, currentUser.id)
|
|
84
|
-
.then(function (response) {
|
|
85
|
-
var _a, _b;
|
|
86
|
-
//success or Error this is parent component responsability
|
|
87
|
-
Logger_1.default.info(response);
|
|
88
|
-
if (response.success) {
|
|
89
|
-
onSubmit(response.success, (_a = response.data) !== null && _a !== void 0 ? _a : 'Le compte a été mis à jout et activé avec succès');
|
|
90
|
-
history.push('/login');
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
onSubmit(response.success, (_b = response.error) !== null && _b !== void 0 ? _b : 'Erreur lors de la mise à jour du compte');
|
|
94
|
-
}
|
|
95
|
-
}).catch(function (error) {
|
|
96
|
-
onSubmit(false, 'Erreur lors de la mise à jour du compte');
|
|
97
|
-
Logger_1.default.error(error);
|
|
98
|
-
setAlertMessage(error);
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
catch (error) {
|
|
102
|
-
console.error('Error occurred during submission:', error);
|
|
103
|
-
}
|
|
104
|
-
finally {
|
|
105
|
-
setLoading(false);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
};
|
|
109
|
-
var controlPhoneNumber = function () {
|
|
110
|
-
var _a, _b, _c, _d, _e;
|
|
111
|
-
var newForm = validationForm;
|
|
112
|
-
var newField;
|
|
113
|
-
newForm.phoneNumber = (0, Tools_1.validateField)(validationForm.phoneNumber, function (value) { return !!value; }, 'Champ obligatoire');
|
|
114
|
-
// Validator 'phoneNumber'
|
|
115
|
-
if ((_a = newForm.phoneNumber) === null || _a === void 0 ? void 0 : _a.value) {
|
|
116
|
-
if (((_b = newForm.phoneNumber) === null || _b === void 0 ? void 0 : _b.value.length) < 10) {
|
|
117
|
-
newField = { value: (_c = validationForm.phoneNumber) === null || _c === void 0 ? void 0 : _c.value, error: "Le n° de téléphone est invalide." };
|
|
118
|
-
}
|
|
119
|
-
else {
|
|
120
|
-
newField = { value: (_d = validationForm.phoneNumber) === null || _d === void 0 ? void 0 : _d.value, error: '' };
|
|
121
|
-
}
|
|
122
|
-
newForm = __assign(__assign({}, newForm), { phoneNumber: newField });
|
|
123
|
-
}
|
|
124
|
-
setValidationForm(newForm);
|
|
125
|
-
return !Boolean((_e = newForm.phoneNumber) === null || _e === void 0 ? void 0 : _e.error);
|
|
126
|
-
};
|
|
127
|
-
var handleInputChange = function (e) {
|
|
128
|
-
var _a;
|
|
129
|
-
if (e) {
|
|
130
|
-
var fieldName = e.target.name;
|
|
131
|
-
var fieldValue = e.target.value;
|
|
132
|
-
var newField = (_a = {}, _a[fieldName] = { value: fieldValue, isValid: true }, _a);
|
|
133
|
-
if (fieldName == "phoneNumber") {
|
|
134
|
-
if (!(0, Validator_1.validatePhoneNumber)(fieldValue))
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
setValidationForm(__assign(__assign({}, validationForm), newField));
|
|
138
|
-
}
|
|
139
|
-
};
|
|
140
|
-
var resendCode = function () {
|
|
141
|
-
var _a;
|
|
142
|
-
if (controlPhoneNumber() && onResendSecurityCode) {
|
|
143
|
-
var req = {
|
|
144
|
-
phoneNumber: (_a = validationForm.phoneNumber) === null || _a === void 0 ? void 0 : _a.value
|
|
145
|
-
};
|
|
146
|
-
UserService_1.default.resendSecurityCode(req)
|
|
147
|
-
.then(function (response) {
|
|
148
|
-
var _a, _b;
|
|
149
|
-
Logger_1.default.info(response);
|
|
150
|
-
if (response.success) {
|
|
151
|
-
onResendSecurityCode(response.success, (_a = response.data) !== null && _a !== void 0 ? _a : '');
|
|
152
|
-
}
|
|
153
|
-
else {
|
|
154
|
-
onResendSecurityCode(response.success, (_b = response.error) !== null && _b !== void 0 ? _b : '');
|
|
155
|
-
}
|
|
156
|
-
history.push('/login');
|
|
157
|
-
}).catch(function (error) {
|
|
158
|
-
Logger_1.default.error(error);
|
|
159
|
-
if (onSubmit) {
|
|
160
|
-
onSubmit(false, error);
|
|
161
|
-
}
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
};
|
|
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.jsxs)(jsx_runtime_1.Fragment, { children: [(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", {})] }), (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.jsxs)(material_1.Box, __assign({ sx: {
|
|
166
|
-
display: 'flex',
|
|
167
|
-
flexDirection: 'column',
|
|
168
|
-
alignItems: 'center',
|
|
169
|
-
justifyContent: 'center',
|
|
170
|
-
textAlign: 'center',
|
|
171
|
-
padding: 3,
|
|
172
|
-
borderRadius: 2,
|
|
173
|
-
boxShadow: 3,
|
|
174
|
-
maxWidth: 400,
|
|
175
|
-
margin: 'auto',
|
|
176
|
-
backgroundColor: 'white',
|
|
177
|
-
} }, { 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.", (0, jsx_runtime_1.jsx)("br", {}), "Si le probl\u00E8me persiste, veuillez nous contacter \u00E0", ' ', (0, jsx_runtime_1.jsx)("b", { children: "contact@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
|
-
};
|
|
179
|
-
exports.default = ActivateAccount;
|