@movalib/movalib-commons 1.59.6 → 1.59.8

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
@@ -13,7 +13,7 @@ export { default as MovaDigitalPassport } from './src/MovaDigitalPassport';
13
13
  export { default as Loader } from './src/Loader';
14
14
  export { default as MovaDialog } from './src/MovaDialog';
15
15
  export { default as QRCode } from './src/QRCode';
16
- export { default as VehiclePlateField } from './src/VehiclePlateField';
16
+ export { default as VehiclePlateField, regexPlate, oldRegexPlate } from './src/VehiclePlateField';
17
17
  export { default as TestButton } from './src/TestButton';
18
18
  export { default as MovaSnackbar } from './src/MovaSnackbar';
19
19
  export { default as MovaLogin } from './src/MovaLogin';
@@ -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';
@@ -39,6 +40,7 @@ export { default as Address } from './src/models/Address';
39
40
  export { default as Vehicle } from './src/models/Vehicle';
40
41
  export { default as Document } from './src/models/Document';
41
42
  export { default as Garage } from './src/models/Garage';
43
+ export { default as VehicleGarage } from './src/models/VehicleGarage';
42
44
  export { default as Schedule } from './src/models/Schedule';
43
45
  export { default as Event } from './src/models/Event';
44
46
  export { default as VehicleTire } from './src/models/VehicleTire';
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.formatVehicleTire = exports.validateField = exports.deleteCookie = exports.readCookie = exports.CategoryPrestation = exports.VehicleTire = exports.Event = exports.Schedule = 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.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 = 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; } });
@@ -40,6 +40,8 @@ var QRCode_1 = require("./src/QRCode");
40
40
  Object.defineProperty(exports, "QRCode", { enumerable: true, get: function () { return __importDefault(QRCode_1).default; } });
41
41
  var VehiclePlateField_1 = require("./src/VehiclePlateField");
42
42
  Object.defineProperty(exports, "VehiclePlateField", { enumerable: true, get: function () { return __importDefault(VehiclePlateField_1).default; } });
43
+ Object.defineProperty(exports, "regexPlate", { enumerable: true, get: function () { return VehiclePlateField_1.regexPlate; } });
44
+ Object.defineProperty(exports, "oldRegexPlate", { enumerable: true, get: function () { return VehiclePlateField_1.oldRegexPlate; } });
43
45
  var TestButton_1 = require("./src/TestButton");
44
46
  Object.defineProperty(exports, "TestButton", { enumerable: true, get: function () { return __importDefault(TestButton_1).default; } });
45
47
  var MovaSnackbar_1 = require("./src/MovaSnackbar");
@@ -56,6 +58,8 @@ var ConfirmationDialog_1 = require("./src/ConfirmationDialog");
56
58
  Object.defineProperty(exports, "ConfirmationDialog", { enumerable: true, get: function () { return __importDefault(ConfirmationDialog_1).default; } });
57
59
  var GenderSelector_1 = require("./src/GenderSelector");
58
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; } });
59
63
  var QrCodePLVContainer_1 = require("./src/components/QrCodePLVContainer/QrCodePLVContainer");
60
64
  Object.defineProperty(exports, "QrCodePLVContainer", { enumerable: true, get: function () { return QrCodePLVContainer_1.QrCodePLVContainer; } });
61
65
  var PLVComponent_1 = require("./src/components/QrCodePLVContainer/PLVComponent");
@@ -92,6 +96,8 @@ var Document_1 = require("./src/models/Document");
92
96
  Object.defineProperty(exports, "Document", { enumerable: true, get: function () { return __importDefault(Document_1).default; } });
93
97
  var Garage_1 = require("./src/models/Garage");
94
98
  Object.defineProperty(exports, "Garage", { enumerable: true, get: function () { return __importDefault(Garage_1).default; } });
99
+ var VehicleGarage_1 = require("./src/models/VehicleGarage");
100
+ Object.defineProperty(exports, "VehicleGarage", { enumerable: true, get: function () { return __importDefault(VehicleGarage_1).default; } });
95
101
  var Schedule_1 = require("./src/models/Schedule");
96
102
  Object.defineProperty(exports, "Schedule", { enumerable: true, get: function () { return __importDefault(Schedule_1).default; } });
97
103
  var Event_1 = require("./src/models/Event");
@@ -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, _b;
121
+ var _a;
122
122
  Logger_1.default.info(response);
123
123
  if (response.success) {
124
124
  if (onSubmit) {
125
- onSubmit(response.success, (_a = response.data) !== null && _a !== void 0 ? _a : '');
125
+ onSubmit(response.success, 'Le compte a été activé avec succès.');
126
126
  }
127
127
  }
128
128
  else {
129
129
  if (onSubmit) {
130
- onSubmit(response.success, (_b = response.error) !== null && _b !== void 0 ? _b : '');
130
+ onSubmit(response.success, (_a = response.error) !== null && _a !== void 0 ? _a : '');
131
131
  }
132
132
  }
133
133
  }).catch(function (error) {
@@ -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)
@@ -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
- };
90
80
  /**
91
81
  * Formulaire de création d'un compte Movalib (Garage / Utilisateur)
92
82
  * ATTENTION : le lien de consultation des CGU doit pointer vers "/terms-and-conditions"
93
83
  */
94
84
  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];
85
+ var _b, _c, _d, _e;
86
+ 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;
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];
97
97
  var history = (0, react_router_dom_1.useHistory)();
98
- var _k = (0, react_1.useState)(""), message = _k[0], setMessage = _k[1];
98
+ var _q = (0, react_1.useState)(""), message = _q[0], setMessage = _q[1];
99
99
  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];
100
+ var _r = (0, react_1.useState)(false), showPassword = _r[0], setShowPassword = _r[1];
101
+ var _s = (0, react_1.useState)(false), openEmailInfo = _s[0], setOpenEmailInfo = _s[1];
102
+ var _t = (0, react_1.useState)(false), openPhoneNumberInfo = _t[0], setOpenPhoneNumberInfo = _t[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", onChange: function (e) { return handleInputChange(e); }, value: userForm.phoneNumber.value, error: Boolean(userForm.phoneNumber.error), helperText: userForm.phoneNumber.error, InputProps: {
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", 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
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: {
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: {
235
235
  '& .MuiOutlinedInput-notchedOutline': {
236
236
  borderColor: darkMode ? 'white' : 'default', // Couleur de la bordure
237
237
  }
@@ -2,5 +2,7 @@ import { FunctionComponent } from 'react';
2
2
  interface VehiclePlateFieldProps {
3
3
  onValidVehiclePlate: (vehiclePlate: string) => void;
4
4
  }
5
+ export declare const regexPlate: RegExp;
6
+ export declare const oldRegexPlate: RegExp;
5
7
  declare const VehiclePlateField: FunctionComponent<VehiclePlateFieldProps>;
6
8
  export default VehiclePlateField;
@@ -14,6 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  return (mod && mod.__esModule) ? mod : { "default": mod };
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.oldRegexPlate = exports.regexPlate = void 0;
17
18
  var jsx_runtime_1 = require("react/jsx-runtime");
18
19
  var react_1 = require("react");
19
20
  var TextField_1 = __importDefault(require("@mui/material/TextField"));
@@ -22,9 +23,9 @@ var Logger_1 = __importDefault(require("./helpers/Logger"));
22
23
  var material_1 = require("@mui/material");
23
24
  var SearchRounded_1 = __importDefault(require("@mui/icons-material/SearchRounded"));
24
25
  // Regex pour une plaque d'immatriculation française (nouveau format SIV)
25
- var regex = /^[A-Z]{2}-\d{3}-[A-Z]{2}$/;
26
+ exports.regexPlate = /^[A-Z]{2}-\d{3}-[A-Z]{2}$/;
26
27
  // Regex pour une plaque d'immatriculation française (ancien format FNI)
27
- var oldRegex = /^\d{1,4}[ -]?[A-Z]{1,4}[ -]?\d{1,4}$/;
28
+ exports.oldRegexPlate = /^\d{1,4}[ -]?[A-Z]{1,4}[ -]?\d{1,4}$/;
28
29
  var VehiclePlateField = function (_a) {
29
30
  var onValidVehiclePlate = _a.onValidVehiclePlate;
30
31
  var _b = (0, react_1.useState)(''), value = _b[0], setValue = _b[1];
@@ -33,7 +34,7 @@ var VehiclePlateField = function (_a) {
33
34
  var _e = (0, react_1.useState)(''), helperText = _e[0], setHelperText = _e[1];
34
35
  // Hook de validation de la plaque
35
36
  (0, react_1.useEffect)(function () {
36
- if (!error && value !== '' && value.match(regex)) {
37
+ if (!error && value !== '' && value.match(exports.regexPlate)) {
37
38
  onValidVehiclePlate(value);
38
39
  }
39
40
  }, [error, value, onValidVehiclePlate]);
@@ -77,10 +78,10 @@ var VehiclePlateField = function (_a) {
77
78
  }
78
79
  };
79
80
  var validatePlate = function () {
80
- if (oldRegex.test(value)) {
81
+ if (exports.oldRegexPlate.test(value)) {
81
82
  onValidVehiclePlate(value);
82
83
  }
83
- setError(!oldRegex.test(value));
84
+ setError(!exports.oldRegexPlate.test(value));
84
85
  };
85
86
  var handleChangeFrenchOld = function (inputValue) {
86
87
  // ON bloque la saisie à 12 caractères max (limite des anciennes plaques)
@@ -104,7 +105,7 @@ var VehiclePlateField = function (_a) {
104
105
  setValue(inputValue);
105
106
  // On teste la plaque une fois la saisie terminée
106
107
  if (inputValue.length == 9) {
107
- setError(!regex.test(inputValue));
108
+ setError(!exports.regexPlate.test(inputValue));
108
109
  }
109
110
  else {
110
111
  setError(false);
@@ -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,179 @@
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;
@@ -60,6 +60,8 @@ export default class Event {
60
60
  repairOrderNumber?: number;
61
61
  orderComment?: string;
62
62
  vehicleReceived?: boolean;
63
- constructor(id: string, ownerId: number, type: EventType, title: string, garageName: string, garageId: number, color: string, state: EventState, garageAddress?: Address, start?: Date, end?: Date, prestations?: Prestation[], operations?: Operation[], products?: Product[], guestsId?: string[], vehicleId?: number, quoteId?: number, notes?: string, vehicleAvailableNotified?: boolean, editable?: boolean, resourceId?: number);
63
+ garageVehicleId?: number;
64
+ garageVehicleRequest?: boolean;
65
+ constructor(id: string, ownerId: number, type: EventType, title: string, garageName: string, garageId: number, color: string, state: EventState, garageAddress?: Address, start?: Date, end?: Date, prestations?: Prestation[], operations?: Operation[], products?: Product[], guestsId?: string[], vehicleId?: number, quoteId?: number, notes?: string, vehicleAvailableNotified?: boolean, editable?: boolean, resourceId?: number, garageVehicleId?: number, garageVehicleRequest?: boolean);
64
66
  static getPrestationsList(event: Event): string[];
65
67
  }
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  var Event = /** @class */ (function () {
4
- function Event(id, ownerId, type, title, garageName, garageId, color, state, garageAddress, start, end, prestations, operations, products, guestsId, vehicleId, quoteId, notes, vehicleAvailableNotified, editable, resourceId) {
4
+ function Event(id, ownerId, type, title, garageName, garageId, color, state, garageAddress, start, end, prestations, operations, products, guestsId, vehicleId, quoteId, notes, vehicleAvailableNotified, editable, resourceId, garageVehicleId, garageVehicleRequest) {
5
5
  this.id = id;
6
6
  this.notes = notes;
7
7
  this.ownerId = ownerId;
@@ -23,6 +23,8 @@ var Event = /** @class */ (function () {
23
23
  this.editable = editable;
24
24
  this.resourceId = resourceId;
25
25
  this.color = color;
26
+ this.garageVehicleId = garageVehicleId;
27
+ this.garageVehicleRequest = garageVehicleRequest;
26
28
  }
27
29
  Event.getPrestationsList = function (event) {
28
30
  if (event && event.prestations) {
@@ -8,6 +8,7 @@ import User from "./User";
8
8
  import Subscription from "./Subscription";
9
9
  import Employee from "./Employee";
10
10
  import CategoryPrestation from "./CategoryPrestation";
11
+ import VehicleGarage from "./VehicleGarage";
11
12
  export default class Garage {
12
13
  id: string;
13
14
  adminId: string;
@@ -18,6 +19,7 @@ export default class Garage {
18
19
  prestationCategories: CategoryPrestation[];
19
20
  prestations: Prestation[];
20
21
  schedules: Schedule[];
22
+ vehicles?: VehicleGarage[];
21
23
  countryCode?: string;
22
24
  contactEmail?: string;
23
25
  admin?: User;
@@ -43,5 +45,7 @@ export default class Garage {
43
45
  operatorsActive?: boolean;
44
46
  employees?: Employee[];
45
47
  defaultView?: string;
46
- constructor(id: string, adminId: string, name: string, address: Address, workforce: number, prestations: Prestation[], schedules: Schedule[], contactPhone: string, prestationCategories: CategoryPrestation[], contactEmail?: string, logo?: string, suppliers?: Supplier[], documents?: Document[], subscriptions?: Subscription[]);
48
+ loanerVehicleActive?: boolean;
49
+ 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);
47
51
  }
@@ -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, contactEmail, logo, suppliers, documents, subscriptions) {
4
+ function Garage(id, adminId, name, address, workforce, prestations, schedules, contactPhone, prestationCategories, vehicles, contactEmail, logo, suppliers, documents, subscriptions, loanerVehicleActive, loanerVehicleRequestActive) {
5
5
  this.id = id;
6
6
  this.adminId = adminId;
7
7
  this.name = name;
@@ -16,6 +16,9 @@ var Garage = /** @class */ (function () {
16
16
  this.suppliers = suppliers;
17
17
  this.documents = documents;
18
18
  this.subscriptions = subscriptions;
19
+ this.vehicles = vehicles;
20
+ this.loanerVehicleActive = loanerVehicleActive;
21
+ this.loanerVehicleRequestActive = loanerVehicleRequestActive;
19
22
  }
20
23
  return Garage;
21
24
  }());
@@ -0,0 +1,9 @@
1
+ import Vehicle from "./Vehicle";
2
+ export default class VehicleGarage {
3
+ id: number;
4
+ index: number;
5
+ color: string;
6
+ type: string;
7
+ vehicle: Vehicle;
8
+ constructor(id: number, index: number, color: string, type: string, vehicle: Vehicle);
9
+ }
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var VehicleGarage = /** @class */ (function () {
4
+ function VehicleGarage(id, index, color, type, vehicle) {
5
+ this.id = id;
6
+ this.index = index;
7
+ this.color = color;
8
+ this.type = type;
9
+ this.vehicle = vehicle;
10
+ }
11
+ return VehicleGarage;
12
+ }());
13
+ exports.default = VehicleGarage;
@@ -45,4 +45,20 @@ export default class GarageService {
45
45
  }): Promise<APIResponse<string>>;
46
46
  static addCustomerVehicle({ garageId, customerId, ...payload }: AddCustomerVehicleParams): Promise<APIResponse<string>>;
47
47
  static deleteCustomerVehicle({ garageId, customerId, vehicleId }: DeleteCustomerVehicleParams): Promise<APIResponse<string>>;
48
+ static toogleGarageLoanerVehicleRequest(garageId: string, req: any): Promise<APIResponse<string>>;
49
+ static toogleGarageLoanerVehicle(garageId: string): Promise<APIResponse<string>>;
50
+ static addGarageVehicle({ garageId, req }: {
51
+ garageId: string;
52
+ req: {
53
+ plate: string;
54
+ };
55
+ }): Promise<APIResponse<string>>;
56
+ static deleteGarageVehicle({ garageId, vehicleId }: {
57
+ garageId: string;
58
+ vehicleId: number;
59
+ }): Promise<APIResponse<string>>;
60
+ static getAllGarageVehicles(garageId: string): Promise<APIResponse<any>>;
61
+ static getOneGarageVehicle(garageId: string, vehicleId: number): Promise<APIResponse<any>>;
62
+ static assignGarageVehicleEvent(garageId: string, eventId: string, vehicleId: number): Promise<APIResponse<string>>;
63
+ static deassignGarageVehicleEvent(garageId: string, eventId: string): Promise<APIResponse<string>>;
48
64
  }
@@ -319,6 +319,66 @@ var GarageService = /** @class */ (function () {
319
319
  appType: Enums_1.MovaAppType.GARAGE,
320
320
  });
321
321
  };
322
+ GarageService.toogleGarageLoanerVehicleRequest = function (garageId, req) {
323
+ return (0, ApiHelper_1.request)({
324
+ url: "".concat(ApiHelper_1.API_BASE_URL, "/garage/").concat(garageId, "/settings/loaner-vehicle-request"),
325
+ method: Enums_1.APIMethod.PATCH,
326
+ appType: Enums_1.MovaAppType.GARAGE,
327
+ body: JSON.stringify(req)
328
+ });
329
+ };
330
+ GarageService.toogleGarageLoanerVehicle = function (garageId) {
331
+ return (0, ApiHelper_1.request)({
332
+ url: "".concat(ApiHelper_1.API_BASE_URL, "/garage/").concat(garageId, "/settings/loaner-vehicle"),
333
+ method: Enums_1.APIMethod.PATCH,
334
+ appType: Enums_1.MovaAppType.GARAGE,
335
+ });
336
+ };
337
+ GarageService.addGarageVehicle = function (_a) {
338
+ var garageId = _a.garageId, req = _a.req;
339
+ return (0, ApiHelper_1.request)({
340
+ url: "".concat(ApiHelper_1.API_BASE_URL, "/garage/").concat(garageId, "/vehicle"),
341
+ method: Enums_1.APIMethod.POST,
342
+ appType: Enums_1.MovaAppType.GARAGE,
343
+ body: JSON.stringify(req)
344
+ });
345
+ };
346
+ GarageService.deleteGarageVehicle = function (_a) {
347
+ var garageId = _a.garageId, vehicleId = _a.vehicleId;
348
+ return (0, ApiHelper_1.request)({
349
+ url: "".concat(ApiHelper_1.API_BASE_URL, "/garage/").concat(garageId, "/vehicle/").concat(vehicleId),
350
+ method: Enums_1.APIMethod.DELETE,
351
+ appType: Enums_1.MovaAppType.GARAGE
352
+ });
353
+ };
354
+ GarageService.getAllGarageVehicles = function (garageId) {
355
+ return (0, ApiHelper_1.request)({
356
+ url: "".concat(ApiHelper_1.API_BASE_URL, "/garage/").concat(garageId, "/vehicles"),
357
+ method: Enums_1.APIMethod.GET,
358
+ appType: Enums_1.MovaAppType.GARAGE
359
+ });
360
+ };
361
+ GarageService.getOneGarageVehicle = function (garageId, vehicleId) {
362
+ return (0, ApiHelper_1.request)({
363
+ url: "".concat(ApiHelper_1.API_BASE_URL, "/garage/").concat(garageId, "/vehicle/").concat(vehicleId),
364
+ method: Enums_1.APIMethod.GET,
365
+ appType: Enums_1.MovaAppType.GARAGE
366
+ });
367
+ };
368
+ GarageService.assignGarageVehicleEvent = function (garageId, eventId, vehicleId) {
369
+ return (0, ApiHelper_1.request)({
370
+ url: "".concat(ApiHelper_1.API_BASE_URL, "/garage/").concat(garageId, "/event/").concat(eventId, "/vehicles/").concat(vehicleId),
371
+ method: Enums_1.APIMethod.PATCH,
372
+ appType: Enums_1.MovaAppType.GARAGE
373
+ });
374
+ };
375
+ GarageService.deassignGarageVehicleEvent = function (garageId, eventId) {
376
+ return (0, ApiHelper_1.request)({
377
+ url: "".concat(ApiHelper_1.API_BASE_URL, "/garage/").concat(garageId, "/event/").concat(eventId, "/vehicles"),
378
+ method: Enums_1.APIMethod.DELETE,
379
+ appType: Enums_1.MovaAppType.GARAGE
380
+ });
381
+ };
322
382
  return GarageService;
323
383
  }());
324
384
  exports.default = GarageService;
@@ -8,7 +8,11 @@ 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<string>>;
11
+ static validateAccount(req: any): Promise<APIResponse<User | {
12
+ expiredCode?: boolean;
13
+ unknowCode?: boolean;
14
+ }>>;
15
+ static editUser(req: any, userId: string): Promise<APIResponse<string>>;
12
16
  /**
13
17
  * @param email
14
18
  * @param password
@@ -88,6 +88,14 @@ 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
+ };
91
99
  /**
92
100
  * @param email
93
101
  * @param password
package/index.ts CHANGED
@@ -19,7 +19,7 @@ export { default as MovaDigitalPassport } from './src/MovaDigitalPassport';
19
19
  export { default as Loader } from './src/Loader';
20
20
  export { default as MovaDialog } from './src/MovaDialog';
21
21
  export { default as QRCode } from './src/QRCode';
22
- export { default as VehiclePlateField } from './src/VehiclePlateField';
22
+ export { default as VehiclePlateField, regexPlate, oldRegexPlate } from './src/VehiclePlateField';
23
23
  export { default as TestButton } from './src/TestButton';
24
24
  export { default as MovaSnackbar } from './src/MovaSnackbar';
25
25
  export { default as MovaLogin } from './src/MovaLogin';
@@ -46,6 +46,7 @@ export { default as Address } from './src/models/Address';
46
46
  export { default as Vehicle } from './src/models/Vehicle';
47
47
  export { default as Document } from './src/models/Document';
48
48
  export { default as Garage } from './src/models/Garage';
49
+ export { default as VehicleGarage } from './src/models/VehicleGarage';
49
50
  export { default as Schedule } from './src/models/Schedule';
50
51
  export { default as Event } from './src/models/Event';
51
52
  export { default as VehicleTire } from './src/models/VehicleTire';
package/package.json CHANGED
@@ -1,57 +1,55 @@
1
1
  {
2
- "name": "@movalib/movalib-commons",
3
- "version": "1.59.6",
4
- "description": "Bibliothèque d'objets communs à l'ensemble des projets React de Movalib",
5
- "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
7
- "private": false,
8
- "scripts": {
9
- "start": "webpack-dev-server --entry ./devIndex.tsx --open --https",
10
- "build": "rm -rf dist && tsc && npm run copy-assets",
11
- "copy-assets": "cp -r src/assets/ dist/src/assets/ && cp -r src/style/ dist/src/style/",
12
- "test": "echo \"Error: no test specified\" && exit 1",
13
- "clean": "rm -rf dist node_modules package-lock.json"
14
- },
15
- "keywords": [],
16
- "author": "",
17
- "license": "ISC",
18
- "dependencies": {
19
- "@emotion/react": "^11.11.1",
20
- "@emotion/styled": "^11.11.0",
21
- "@mui/icons-material": "^5.11.17",
22
- "@mui/lab": "^5.0.0-alpha.134",
23
- "@mui/material": "^5.13.5",
24
- "@mui/x-date-pickers": "^6.9.1",
25
- "@types/react": "^18.2.22",
26
- "@types/react-dom": "^18.2.7",
27
- "@types/react-router-dom": "^5.3.0",
28
- "date-fns": "^2.29.3",
29
- "date-fns-tz": "^2.0.0",
30
- "file-loader": "^6.2.0",
31
- "html2canvas": "^1.4.1",
32
- "js-cookie": "^3.0.5",
33
- "pdf-lib": "^1.17.1",
34
- "pdfjs-dist": "^4.6.82",
35
- "qr-code-styling": "^1.4.4",
36
- "react": "^18.2.0",
37
- "react-dom": "^18.2.0",
38
- "react-input-mask": "^2.0.4",
39
- "react-router-dom": "^5.1.2",
40
- "react-scripts": "5.0.1",
41
- "react-to-print": "^2.14.15",
42
- "typescript": "^4.9.5"
43
- },
44
- "eslintConfig": {
45
- "extends": [
46
- "react-app"
47
- ]
48
- },
49
- "devDependencies": {
50
- "@types/js-cookie": "^3.0.4",
51
- "@types/pdfjs-dist": "^2.10.377",
52
- "@types/react-input-mask": "^3.0.5",
53
- "html-webpack-plugin": "^5.5.3",
54
- "ts-loader": "^9.4.4",
55
- "webpack-cli": "^5.1.4"
56
- }
2
+ "name": "@movalib/movalib-commons",
3
+ "version": "1.59.8",
4
+ "description": "Bibliothèque d'objets communs à l'ensemble des projets React de Movalib",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "private": false,
8
+ "scripts": {
9
+ "start": "webpack-dev-server --entry ./devIndex.tsx --open --https",
10
+ "build": "rm -rf dist && tsc && npm run copy-assets",
11
+ "copy-assets": "cp -r src/assets/ dist/src/assets/ && cp -r src/style/ dist/src/style/",
12
+ "test": "echo \"Error: no test specified\" && exit 1",
13
+ "clean": "rm -rf dist node_modules package-lock.json"
14
+ },
15
+ "keywords": [],
16
+ "author": "",
17
+ "license": "ISC",
18
+ "dependencies": {
19
+ "@emotion/react": "^11.11.1",
20
+ "@emotion/styled": "^11.11.0",
21
+ "@mui/icons-material": "^5.11.17",
22
+ "@mui/lab": "^5.0.0-alpha.134",
23
+ "@mui/material": "^5.13.5",
24
+ "@mui/x-date-pickers": "^6.9.1",
25
+ "@types/react": "^18.2.22",
26
+ "@types/react-dom": "^18.2.7",
27
+ "@types/react-router-dom": "^5.3.0",
28
+ "date-fns": "^2.29.3",
29
+ "date-fns-tz": "^2.0.0",
30
+ "file-loader": "^6.2.0",
31
+ "html2canvas": "^1.4.1",
32
+ "js-cookie": "^3.0.5",
33
+ "pdf-lib": "^1.17.1",
34
+ "pdfjs-dist": "^4.6.82",
35
+ "qr-code-styling": "^1.4.4",
36
+ "react": "^18.2.0",
37
+ "react-dom": "^18.2.0",
38
+ "react-input-mask": "^2.0.4",
39
+ "react-router-dom": "^5.1.2",
40
+ "react-scripts": "5.0.1",
41
+ "react-to-print": "^2.14.15",
42
+ "typescript": "^4.9.5"
43
+ },
44
+ "eslintConfig": {
45
+ "extends": ["react-app"]
46
+ },
47
+ "devDependencies": {
48
+ "@types/js-cookie": "^3.0.4",
49
+ "@types/pdfjs-dist": "^2.10.377",
50
+ "@types/react-input-mask": "^3.0.5",
51
+ "html-webpack-plugin": "^5.5.3",
52
+ "ts-loader": "^9.4.4",
53
+ "webpack-cli": "^5.1.4"
54
+ }
57
55
  }
@@ -10,9 +10,9 @@ interface VehiclePlateFieldProps {
10
10
  }
11
11
 
12
12
  // Regex pour une plaque d'immatriculation française (nouveau format SIV)
13
- const regex = /^[A-Z]{2}-\d{3}-[A-Z]{2}$/;
13
+ export const regexPlate = /^[A-Z]{2}-\d{3}-[A-Z]{2}$/;
14
14
  // Regex pour une plaque d'immatriculation française (ancien format FNI)
15
- const oldRegex = /^\d{1,4}[ -]?[A-Z]{1,4}[ -]?\d{1,4}$/;
15
+ export const oldRegexPlate = /^\d{1,4}[ -]?[A-Z]{1,4}[ -]?\d{1,4}$/;
16
16
 
17
17
 
18
18
  const VehiclePlateField: FunctionComponent<VehiclePlateFieldProps> = ({ onValidVehiclePlate }) => {
@@ -24,7 +24,7 @@ const VehiclePlateField: FunctionComponent<VehiclePlateFieldProps> = ({ onValidV
24
24
 
25
25
  // Hook de validation de la plaque
26
26
  useEffect(() => {
27
- if (!error && value !== '' && value.match(regex)) {
27
+ if (!error && value !== '' && value.match(regexPlate)) {
28
28
  onValidVehiclePlate(value);
29
29
  }
30
30
 
@@ -78,11 +78,11 @@ const VehiclePlateField: FunctionComponent<VehiclePlateFieldProps> = ({ onValidV
78
78
 
79
79
  const validatePlate = () => {
80
80
 
81
- if(oldRegex.test(value)){
81
+ if(oldRegexPlate.test(value)){
82
82
  onValidVehiclePlate(value);
83
83
  }
84
84
 
85
- setError(!oldRegex.test(value));
85
+ setError(!oldRegexPlate.test(value));
86
86
  }
87
87
 
88
88
  const handleChangeFrenchOld = (inputValue: string) => {
@@ -116,7 +116,7 @@ const VehiclePlateField: FunctionComponent<VehiclePlateFieldProps> = ({ onValidV
116
116
 
117
117
  // On teste la plaque une fois la saisie terminée
118
118
  if(inputValue.length == 9){
119
- setError(!regex.test(inputValue));
119
+ setError(!regexPlate.test(inputValue));
120
120
  } else {
121
121
  setError(false);
122
122
  }
@@ -67,10 +67,13 @@ export default class Event {
67
67
  repairOrderNumber?: number;
68
68
  orderComment?: string;
69
69
  vehicleReceived?: boolean;
70
+ garageVehicleId?: number;
71
+ garageVehicleRequest?: boolean;
70
72
 
71
73
  constructor(id: string, ownerId: number, type : EventType, title: string, garageName: string, garageId: number,color: string,
72
74
  state: EventState, garageAddress?: Address, start?: Date, end?: Date, prestations?: Prestation[], operations?: Operation[], products?: Product[],
73
- guestsId?: string[], vehicleId?: number, quoteId?: number, notes?: string, vehicleAvailableNotified?: boolean, editable?: boolean, resourceId?: number)
75
+ guestsId?: string[], vehicleId?: number, quoteId?: number, notes?: string, vehicleAvailableNotified?: boolean, editable?: boolean,
76
+ resourceId?: number, garageVehicleId?: number, garageVehicleRequest?: boolean)
74
77
  {
75
78
  this.id = id;
76
79
  this.notes = notes;
@@ -93,6 +96,8 @@ export default class Event {
93
96
  this.editable = editable;
94
97
  this.resourceId = resourceId;
95
98
  this.color = color;
99
+ this.garageVehicleId = garageVehicleId;
100
+ this.garageVehicleRequest = garageVehicleRequest;
96
101
  }
97
102
 
98
103
  static getPrestationsList(event: Event) : string[] {
@@ -8,6 +8,7 @@ import User from "./User";
8
8
  import Subscription from "./Subscription";
9
9
  import Employee from "./Employee";
10
10
  import CategoryPrestation from "./CategoryPrestation";
11
+ import VehicleGarage from "./VehicleGarage";
11
12
 
12
13
  export default class Garage {
13
14
 
@@ -20,6 +21,7 @@ export default class Garage {
20
21
  prestationCategories: CategoryPrestation[];
21
22
  prestations: Prestation[];
22
23
  schedules: Schedule[];
24
+ vehicles?: VehicleGarage[];
23
25
  countryCode?: string;
24
26
  contactEmail?: string;
25
27
  admin?: User;
@@ -45,6 +47,8 @@ export default class Garage {
45
47
  operatorsActive?: boolean;
46
48
  employees?: Employee[];
47
49
  defaultView?: string;
50
+ loanerVehicleActive?: boolean;
51
+ loanerVehicleRequestActive?: boolean;
48
52
 
49
53
  constructor(
50
54
  id:string,
@@ -56,11 +60,14 @@ export default class Garage {
56
60
  schedules: Schedule[],
57
61
  contactPhone: string,
58
62
  prestationCategories: CategoryPrestation[],
63
+ vehicles?: VehicleGarage[],
59
64
  contactEmail?: string,
60
65
  logo?:string,
61
66
  suppliers?: Supplier[],
62
67
  documents?: Document[],
63
- subscriptions?: Subscription[]
68
+ subscriptions?: Subscription[],
69
+ loanerVehicleActive?: boolean,
70
+ loanerVehicleRequestActive?: boolean
64
71
  ) {
65
72
  this.id = id;
66
73
  this.adminId = adminId;
@@ -76,5 +83,8 @@ export default class Garage {
76
83
  this.suppliers = suppliers;
77
84
  this.documents = documents;
78
85
  this.subscriptions = subscriptions;
86
+ this.vehicles = vehicles;
87
+ this.loanerVehicleActive = loanerVehicleActive;
88
+ this.loanerVehicleRequestActive = loanerVehicleRequestActive;
79
89
  }
80
90
  }
@@ -0,0 +1,20 @@
1
+ import { DigitalPassportIndex } from "../helpers/Enums";
2
+ import Vehicle from "./Vehicle";
3
+ import VehicleTire from "./VehicleTire";
4
+ import Document from './Document';
5
+
6
+ export default class VehicleGarage {
7
+ id: number;
8
+ index: number;
9
+ color: string;
10
+ type: string;
11
+ vehicle: Vehicle
12
+
13
+ constructor( id: number,index: number, color: string, type: string, vehicle: Vehicle) {
14
+ this.id = id;
15
+ this.index = index;
16
+ this.color = color;
17
+ this.type = type;
18
+ this.vehicle = vehicle;
19
+ }
20
+ }
@@ -350,4 +350,69 @@ export default class GarageService {
350
350
  })
351
351
  }
352
352
 
353
+ static toogleGarageLoanerVehicleRequest(garageId: string, req: any): Promise<APIResponse<string>> {
354
+ return request({
355
+ url: `${API_BASE_URL}/garage/${garageId}/settings/loaner-vehicle-request`,
356
+ method: APIMethod.PATCH,
357
+ appType: MovaAppType.GARAGE,
358
+ body: JSON.stringify(req)
359
+ });
360
+ }
361
+
362
+ static toogleGarageLoanerVehicle(garageId: string): Promise<APIResponse<string>> {
363
+ return request({
364
+ url: `${API_BASE_URL}/garage/${garageId}/settings/loaner-vehicle`,
365
+ method: APIMethod.PATCH,
366
+ appType: MovaAppType.GARAGE,
367
+ });
368
+ }
369
+
370
+ static addGarageVehicle({garageId, req} :{garageId: string, req: {plate: string}}): Promise<APIResponse<string>> {
371
+ return request({
372
+ url: `${API_BASE_URL}/garage/${garageId}/vehicle`,
373
+ method: APIMethod.POST,
374
+ appType: MovaAppType.GARAGE,
375
+ body: JSON.stringify(req)
376
+ });
377
+ }
378
+
379
+ static deleteGarageVehicle({garageId, vehicleId}:{garageId: string, vehicleId: number}): Promise<APIResponse<string>> {
380
+ return request({
381
+ url: `${API_BASE_URL}/garage/${garageId}/vehicle/${vehicleId}`,
382
+ method: APIMethod.DELETE,
383
+ appType: MovaAppType.GARAGE
384
+ });
385
+ }
386
+
387
+ static getAllGarageVehicles(garageId: string): Promise<APIResponse<any>> {
388
+ return request({
389
+ url: `${API_BASE_URL}/garage/${garageId}/vehicles`,
390
+ method: APIMethod.GET,
391
+ appType: MovaAppType.GARAGE
392
+ })
393
+ }
394
+
395
+ static getOneGarageVehicle(garageId: string, vehicleId: number): Promise<APIResponse<any>> {
396
+ return request({
397
+ url: `${API_BASE_URL}/garage/${garageId}/vehicle/${vehicleId}`,
398
+ method: APIMethod.GET,
399
+ appType: MovaAppType.GARAGE
400
+ })
401
+ }
402
+
403
+ static assignGarageVehicleEvent(garageId: string, eventId: string, vehicleId: number): Promise<APIResponse<string>> {
404
+ return request({
405
+ url: `${API_BASE_URL}/garage/${garageId}/event/${eventId}/vehicles/${vehicleId}`,
406
+ method: APIMethod.PATCH,
407
+ appType: MovaAppType.GARAGE
408
+ })
409
+ }
410
+
411
+ static deassignGarageVehicleEvent(garageId: string, eventId: string): Promise<APIResponse<string>> {
412
+ return request({
413
+ url: `${API_BASE_URL}/garage/${garageId}/event/${eventId}/vehicles`,
414
+ method: APIMethod.DELETE,
415
+ appType: MovaAppType.GARAGE
416
+ })
417
+ }
353
418
  }