@movalib/movalib-commons 1.59.9 → 1.59.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -22,6 +22,7 @@ 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';
25
26
  export { QrCodePLVContainer } from './src/components/QrCodePLVContainer/QrCodePLVContainer';
26
27
  export { PLVComponent, PrintSize } from './src/components/QrCodePLVContainer/PLVComponent';
27
28
  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.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;
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.ActivateAccount = 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 = exports.readCookie = 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,6 +58,8 @@ 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; } });
61
63
  var QrCodePLVContainer_1 = require("./src/components/QrCodePLVContainer/QrCodePLVContainer");
62
64
  Object.defineProperty(exports, "QrCodePLVContainer", { enumerable: true, get: function () { return QrCodePLVContainer_1.QrCodePLVContainer; } });
63
65
  var PLVComponent_1 = require("./src/components/QrCodePLVContainer/PLVComponent");
@@ -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,23 +113,26 @@ 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
- var _a, _b;
126
+ var _a;
122
127
  Logger_1.default.info(response);
123
128
  if (response.success) {
124
129
  if (onSubmit) {
125
- onSubmit(response.success, (_a = response.data) !== null && _a !== void 0 ? _a : '');
130
+ onSubmit(response.success, 'Le compte a été activé avec succès.');
126
131
  }
127
132
  }
128
133
  else {
129
134
  if (onSubmit) {
130
- onSubmit(response.success, (_b = response.error) !== null && _b !== void 0 ? _b : '');
135
+ onSubmit(response.success, (_a = response.error) !== null && _a !== void 0 ? _a : '');
131
136
  }
132
137
  }
133
138
  }).catch(function (error) {
@@ -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',
@@ -2,6 +2,7 @@ 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";
5
6
  /**
6
7
  * Propriétés du composant
7
8
  * movaAppType : type d'application Movalib au sein de laquelle le composant est injectée
@@ -24,6 +25,7 @@ interface MovaSignUpProps {
24
25
  showLoginButton?: boolean;
25
26
  disableGutters?: boolean;
26
27
  usePhoneNumber?: boolean;
28
+ userToEdit?: User;
27
29
  }
28
30
  /**
29
31
  * Formulaire de création d'un compte Movalib (Garage / Utilisateur)
@@ -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
@@ -77,29 +78,31 @@ var styles = {
77
78
  justifyContent: 'center',
78
79
  alignItems: 'center'
79
80
  };
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
- };
90
81
  /**
91
82
  * Formulaire de création d'un compte Movalib (Garage / Utilisateur)
92
83
  * ATTENTION : le lien de consultation des CGU doit pointer vers "/terms-and-conditions"
93
84
  */
94
85
  var MovaSignUp = function (_a) {
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];
86
+ var _b, _c, _d, _e;
87
+ var loading = _a.loading, movaAppType = _a.movaAppType, onSubmit = _a.onSubmit, _f = _a.darkMode, darkMode = _f === void 0 ? false : _f, alertMessage = _a.alertMessage, alertSeverity = _a.alertSeverity, headerText = _a.headerText, _g = _a.showHeaderLogo, showHeaderLogo = _g === void 0 ? true : _g, _h = _a.showLeafs, showLeafs = _h === void 0 ? true : _h, _j = _a.showCopyright, showCopyright = _j === void 0 ? true : _j, _k = _a.showLoginButton, showLoginButton = _k === void 0 ? true : _k, _l = _a.disableGutters, disableGutters = _l === void 0 ? false : _l, _m = _a.usePhoneNumber, usePhoneNumber = _m === void 0 ? true : _m, _o = _a.userToEdit, userToEdit = _o === void 0 ? null : _o;
88
+ var _p = (0, react_1.useState)({
89
+ firstname: { value: (_b = userToEdit === null || userToEdit === void 0 ? void 0 : userToEdit.firstname) !== null && _b !== void 0 ? _b : '', isValid: true },
90
+ lastname: { value: (_c = userToEdit === null || userToEdit === void 0 ? void 0 : userToEdit.lastname) !== null && _c !== void 0 ? _c : '', isValid: true },
91
+ email: { value: (_d = userToEdit === null || userToEdit === void 0 ? void 0 : userToEdit.email) !== null && _d !== void 0 ? _d : '', isValid: true },
92
+ phoneNumber: { value: (_e = userToEdit === null || userToEdit === void 0 ? void 0 : userToEdit.phoneNumber) !== null && _e !== void 0 ? _e : '', isValid: true },
93
+ password: { value: '', isValid: true },
94
+ gender: { value: '', isValid: true },
95
+ birthDate: { value: null, isValid: true },
96
+ acceptsTerms: { value: false, isValid: true },
97
+ }), userForm = _p[0], setUserForm = _p[1];
97
98
  var history = (0, react_router_dom_1.useHistory)();
98
- var _k = (0, react_1.useState)(""), message = _k[0], setMessage = _k[1];
99
+ var _q = (0, react_1.useState)(""), message = _q[0], setMessage = _q[1];
99
100
  var theme = (0, material_1.useTheme)();
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];
101
+ var _r = (0, react_1.useState)(false), showPassword = _r[0], setShowPassword = _r[1];
102
+ var _s = (0, react_1.useState)(false), openEmailInfo = _s[0], setOpenEmailInfo = _s[1];
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") {
@@ -229,9 +254,9 @@ var MovaSignUp = function (_a) {
229
254
  '& .MuiOutlinedInput-notchedOutline': {
230
255
  borderColor: darkMode ? 'white' : 'default', // Couleur de la bordure
231
256
  }
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
- 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", onChange: function (e) { return handleInputChange(e); }, value: userForm.email.value, error: !userForm.email.isValid, helperText: userForm.email.error, sx: {
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: {
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
  }
@@ -0,0 +1,10 @@
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;
@@ -0,0 +1,188 @@
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
+ token: !smsValidation ? params === null || params === void 0 ? void 0 : params.get('token') : null,
48
+ securityCode: smsValidation ? code : null,
49
+ demoGarage: Boolean(params === null || params === void 0 ? void 0 : params.get('demoGarage'))
50
+ };
51
+ UserService_1.default.validateAccount(req).then(function (response) {
52
+ if (response.success) {
53
+ setCurrentUser(response.data);
54
+ }
55
+ else {
56
+ var data = response.data;
57
+ if (data === null || data === void 0 ? void 0 : data.expiredCode) {
58
+ setExpiredCode(true);
59
+ }
60
+ if (data === null || data === void 0 ? void 0 : data.unknownCode) {
61
+ setUnknowCode(true);
62
+ }
63
+ }
64
+ });
65
+ };
66
+ (0, react_1.useEffect)(function () {
67
+ getUserByTokenOrCode();
68
+ }, []);
69
+ var updateActivateUseronSubmit = function (form) {
70
+ // appelle api pour mettre a jour l'utilisateur + auto activate en fonction du movaAPPType
71
+ if (movaAppType === Enums_1.MovaAppType.INDIVIDUAL && currentUser) {
72
+ setLoading(true);
73
+ try {
74
+ // On prépare la query
75
+ var 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
+ UserService_1.default.editUser(query, currentUser.id)
83
+ .then(function (response) {
84
+ var _a, _b;
85
+ //success or Error this is parent component responsability
86
+ Logger_1.default.info(response);
87
+ if (response.success) {
88
+ onSubmit(response.success, (_a = response.data) !== null && _a !== void 0 ? _a : 'Le compte a été mis à jour et activé avec succès');
89
+ history.push('/login');
90
+ }
91
+ else {
92
+ onSubmit(response.success, (_b = response.error) !== null && _b !== void 0 ? _b : 'Erreur lors de la mise à jour du compte');
93
+ }
94
+ }).catch(function (error) {
95
+ onSubmit(false, 'Erreur lors de la mise à jour du compte');
96
+ Logger_1.default.error(error);
97
+ setAlertMessage(error);
98
+ });
99
+ }
100
+ catch (error) {
101
+ console.error('Error occurred during submission:', error);
102
+ }
103
+ finally {
104
+ setLoading(false);
105
+ }
106
+ }
107
+ };
108
+ var controlPhoneNumber = function () {
109
+ var _a, _b, _c, _d, _e;
110
+ var newForm = validationForm;
111
+ var newField;
112
+ newForm.phoneNumber = (0, Tools_1.validateField)(validationForm.phoneNumber, function (value) { return !!value; }, 'Champ obligatoire');
113
+ // Validator 'phoneNumber'
114
+ if ((_a = newForm.phoneNumber) === null || _a === void 0 ? void 0 : _a.value) {
115
+ if (((_b = newForm.phoneNumber) === null || _b === void 0 ? void 0 : _b.value.length) < 10) {
116
+ newField = { value: (_c = validationForm.phoneNumber) === null || _c === void 0 ? void 0 : _c.value, error: "Le n° de téléphone est invalide." };
117
+ }
118
+ else {
119
+ newField = { value: (_d = validationForm.phoneNumber) === null || _d === void 0 ? void 0 : _d.value, error: '' };
120
+ }
121
+ newForm = __assign(__assign({}, newForm), { phoneNumber: newField });
122
+ }
123
+ setValidationForm(newForm);
124
+ return !Boolean((_e = newForm.phoneNumber) === null || _e === void 0 ? void 0 : _e.error);
125
+ };
126
+ var handleInputChange = function (e) {
127
+ var _a;
128
+ if (e) {
129
+ var fieldName = e.target.name;
130
+ var fieldValue = e.target.value;
131
+ var newField = (_a = {}, _a[fieldName] = { value: fieldValue, isValid: true }, _a);
132
+ if (fieldName == "phoneNumber") {
133
+ if (!(0, Validator_1.validatePhoneNumber)(fieldValue))
134
+ return;
135
+ }
136
+ setValidationForm(__assign(__assign({}, validationForm), newField));
137
+ }
138
+ };
139
+ var resendCode = function () {
140
+ var _a;
141
+ if (controlPhoneNumber() && onResendSecurityCode) {
142
+ var req = {
143
+ phoneNumber: (_a = validationForm.phoneNumber) === null || _a === void 0 ? void 0 : _a.value
144
+ };
145
+ UserService_1.default.resendActivationAccount(req)
146
+ .then(function (response) {
147
+ var _a, _b;
148
+ Logger_1.default.info(response);
149
+ if (response.success) {
150
+ onResendSecurityCode(response.success, (_a = response.data) !== null && _a !== void 0 ? _a : '');
151
+ }
152
+ else {
153
+ onResendSecurityCode(response.success, (_b = response.error) !== null && _b !== void 0 ? _b : '');
154
+ }
155
+ history.push('/login');
156
+ }).catch(function (error) {
157
+ Logger_1.default.error(error);
158
+ if (onSubmit) {
159
+ onSubmit(false, error);
160
+ }
161
+ });
162
+ }
163
+ };
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" }))] })) })))] }));
187
+ };
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é (403)';
28
+ errorMsg = 'Accès non autorisé';
29
29
  break;
30
30
  case 404:
31
- errorMsg = 'La ressource demandée est introuvable (404)';
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 (500)';
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 (".concat(response.status, ")");
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
  });
@@ -15,6 +15,7 @@ export default class Garage {
15
15
  name: string;
16
16
  address: Address;
17
17
  workforce: number;
18
+ partialWorkforce?: number;
18
19
  contactPhone: string;
19
20
  prestationCategories: CategoryPrestation[];
20
21
  prestations: Prestation[];
@@ -41,11 +42,12 @@ export default class Garage {
41
42
  teamManagementActive?: boolean;
42
43
  documents?: Document[];
43
44
  subscriptions?: Subscription[];
45
+ subscription?: Subscription;
44
46
  supportPhoneNumber?: string;
45
47
  operatorsActive?: boolean;
46
48
  employees?: Employee[];
47
49
  defaultView?: string;
48
50
  loanerVehicleActive?: boolean;
49
51
  loanerVehicleRequestActive?: boolean;
50
- constructor(id: string, adminId: string, name: string, address: Address, workforce: number, prestations: Prestation[], schedules: Schedule[], contactPhone: string, prestationCategories: CategoryPrestation[], vehicles?: VehicleGarage[], contactEmail?: string, logo?: string, suppliers?: Supplier[], documents?: Document[], subscriptions?: Subscription[], loanerVehicleActive?: boolean, loanerVehicleRequestActive?: boolean);
52
+ constructor(id: string, adminId: string, name: string, address: Address, workforce: number, prestations: Prestation[], schedules: Schedule[], contactPhone: string, prestationCategories: CategoryPrestation[], vehicles?: VehicleGarage[], contactEmail?: string, logo?: string, suppliers?: Supplier[], documents?: Document[], subscriptions?: Subscription[], loanerVehicleActive?: boolean, loanerVehicleRequestActive?: boolean, subscription?: Subscription, partialWorkforce?: number);
51
53
  }
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  var Garage = /** @class */ (function () {
4
- function Garage(id, adminId, name, address, workforce, prestations, schedules, contactPhone, prestationCategories, vehicles, contactEmail, logo, suppliers, documents, subscriptions, loanerVehicleActive, loanerVehicleRequestActive) {
4
+ function Garage(id, adminId, name, address, workforce, prestations, schedules, contactPhone, prestationCategories, vehicles, contactEmail, logo, suppliers, documents, subscriptions, loanerVehicleActive, loanerVehicleRequestActive, subscription, partialWorkforce) {
5
5
  this.id = id;
6
6
  this.adminId = adminId;
7
7
  this.name = name;
@@ -19,6 +19,8 @@ var Garage = /** @class */ (function () {
19
19
  this.vehicles = vehicles;
20
20
  this.loanerVehicleActive = loanerVehicleActive;
21
21
  this.loanerVehicleRequestActive = loanerVehicleRequestActive;
22
+ this.subscription = subscription;
23
+ this.partialWorkforce = partialWorkforce;
22
24
  }
23
25
  return Garage;
24
26
  }());
@@ -1,4 +1,19 @@
1
1
  import { SubscriptionPaymentInterval, SubscriptionState, SubscriptionType } from "../helpers/Enums";
2
+ interface roiInterface {
3
+ period: string;
4
+ turnover: number;
5
+ nbInvoice: number;
6
+ nbQuote: number;
7
+ nbNoShow: number;
8
+ nbLostQuote: number;
9
+ moRateOne: number;
10
+ moRateTwo: number;
11
+ moRateThree: number;
12
+ moOne: number;
13
+ moTwo: number;
14
+ moThree: number;
15
+ comment: string;
16
+ }
2
17
  export default class Subscription {
3
18
  id: string;
4
19
  garageId: string;
@@ -14,5 +29,14 @@ export default class Subscription {
14
29
  cancellationDate: Date;
15
30
  paymentInterval: SubscriptionPaymentInterval;
16
31
  paymentIban: string;
17
- constructor(id: string, garageId: string, type: SubscriptionType, state: SubscriptionState, companyName: string, companyEmail: string, companySiren: string, companyLegalForm: string, trialDays: number, startDate: Date, activationDate: Date, cancellationDate: Date, paymentInterval: SubscriptionPaymentInterval, paymentIban: string);
32
+ roi: roiInterface;
33
+ additionalFormationQuantity: number;
34
+ additionalFormationFree: boolean;
35
+ webPage: boolean;
36
+ plvQuantity: number;
37
+ plvFree: boolean;
38
+ trainingOptionalOne: Date;
39
+ trainingOptionalTwo: Date;
40
+ constructor(id: string, garageId: string, type: SubscriptionType, state: SubscriptionState, companyName: string, companyEmail: string, companySiren: string, companyLegalForm: string, trialDays: number, startDate: Date, activationDate: Date, cancellationDate: Date, paymentInterval: SubscriptionPaymentInterval, paymentIban: string, roi: roiInterface, additionalFormationQuantity: number, additionalFormationFree: boolean, webPage: boolean, plvQuantity: number, plvFree: boolean, trainingOptionalOne: Date, trainingOptionalTwo: Date);
18
41
  }
42
+ export {};
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  var Subscription = /** @class */ (function () {
4
- function Subscription(id, garageId, type, state, companyName, companyEmail, companySiren, companyLegalForm, trialDays, startDate, activationDate, cancellationDate, paymentInterval, paymentIban) {
4
+ function Subscription(id, garageId, type, state, companyName, companyEmail, companySiren, companyLegalForm, trialDays, startDate, activationDate, cancellationDate, paymentInterval, paymentIban, roi, additionalFormationQuantity, additionalFormationFree, webPage, plvQuantity, plvFree, trainingOptionalOne, trainingOptionalTwo) {
5
5
  this.id = id;
6
6
  this.garageId = garageId;
7
7
  this.type = type;
@@ -16,6 +16,14 @@ var Subscription = /** @class */ (function () {
16
16
  this.cancellationDate = cancellationDate;
17
17
  this.paymentInterval = paymentInterval;
18
18
  this.paymentIban = paymentIban;
19
+ this.roi = roi;
20
+ this.webPage = webPage;
21
+ this.additionalFormationQuantity = additionalFormationQuantity;
22
+ this.additionalFormationFree = additionalFormationFree;
23
+ this.plvQuantity = plvQuantity;
24
+ this.plvFree = plvFree;
25
+ this.trainingOptionalOne = trainingOptionalOne;
26
+ this.trainingOptionalTwo = trainingOptionalTwo;
19
27
  }
20
28
  return Subscription;
21
29
  }());
@@ -7,8 +7,13 @@ 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
- static validateAccount(req: any): Promise<APIResponse<string>>;
12
+ static validateAccount(req: any): Promise<APIResponse<User | {
13
+ expiredCode?: boolean;
14
+ unknowCode?: boolean;
15
+ }>>;
16
+ static editUser(req: any, userId: string): Promise<APIResponse<string>>;
12
17
  /**
13
18
  * @param email
14
19
  * @param password
@@ -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"),
@@ -88,6 +96,14 @@ var UserService = /** @class */ (function () {
88
96
  body: JSON.stringify(req)
89
97
  });
90
98
  };
99
+ UserService.editUser = function (req, userId) {
100
+ return (0, ApiHelper_1.request)({
101
+ url: "".concat(ApiHelper_1.API_BASE_URL, "/user/").concat(userId, "/complete"),
102
+ method: Enums_1.APIMethod.PATCH,
103
+ appType: Enums_1.MovaAppType.INDIVIDUAL,
104
+ body: JSON.stringify(req)
105
+ });
106
+ };
91
107
  /**
92
108
  * @param email
93
109
  * @param password
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@movalib/movalib-commons",
3
- "version": "1.59.9",
3
+ "version": "1.59.11",
4
4
  "description": "Bibliothèque d'objets communs à l'ensemble des projets React de Movalib",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",