@movalib/movalib-commons 1.59.15 → 1.59.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/devIndex.tsx CHANGED
@@ -19,7 +19,7 @@ import Logger from './src/helpers/Logger';
19
19
  import Garage from './src/models/Garage';
20
20
  import ScheduleFields, { DaySchedule } from './src/ScheduleFields';
21
21
  import Schedule from './src/models/Schedule';
22
- import { flexCenter } from './src/helpers/Tools';
22
+ import { flexCenter, formatVehicleTire } from './src/helpers/Tools';
23
23
  import AccountValidation from './src/AccountValidation';
24
24
  import VehiclePlateField from './src/components/vehicle/VehiclePlateField';
25
25
  import GaragePLV from './src/GaragePLV';
@@ -127,7 +127,7 @@ const App = () => {
127
127
  </Container>
128
128
  <Container style={flexCenter} sx={{ width: '400px', mt: 2}}>
129
129
  <MovaVehicleTireField onChangeVehicleTire={(vehicleTire) => {
130
- console.log(vehicleTire);
130
+ console.log('formatVehicleTire', formatVehicleTire(vehicleTire));
131
131
  }}/>
132
132
  </Container>
133
133
 
package/dist/devIndex.js CHANGED
@@ -133,7 +133,7 @@ var App = function () {
133
133
  } }), (0, jsx_runtime_1.jsx)(material_1.Container, __assign({ style: Tools_1.flexCenter, sx: { width: '400px', mt: 2 } }, { children: (0, jsx_runtime_1.jsx)(VehiclePlateField_1.default, { onValidVehiclePlate: function (vehiclePlate) {
134
134
  alert('plaque valide');
135
135
  } }) })), (0, jsx_runtime_1.jsx)(material_1.Container, __assign({ style: Tools_1.flexCenter, sx: { width: '400px', mt: 2 } }, { children: (0, jsx_runtime_1.jsx)(MovaVehicleTireField_1.default, { onChangeVehicleTire: function (vehicleTire) {
136
- console.log(vehicleTire);
136
+ console.log('formatVehicleTire', (0, Tools_1.formatVehicleTire)(vehicleTire));
137
137
  } }) })), (0, jsx_runtime_1.jsx)(MovaLogin_1.default, { darkMode: false, movaAppType: Enums_1.MovaAppType.INDIVIDUAL, version: "0.1.3", onSubmit: function (form) {
138
138
  alert('Form Submitted !');
139
139
  }, onSubmitForgotPassword: function (email) {
package/dist/index.d.ts CHANGED
@@ -2,7 +2,6 @@ export { default as VehicleService } from './src/services/VehicleService';
2
2
  export { default as AuthenticationService } from './src/services/AuthenticationService';
3
3
  export { default as GarageService } from './src/services/GarageService';
4
4
  export { default as UserService } from './src/services/UserService';
5
- export { default as UserConnected } from './src/services/UserConnected';
6
5
  export { default as DialogForgotPassword } from './src/DialogForgotPassword';
7
6
  export { default as IbanInput } from './src/IbanInput';
8
7
  export { default as GaragePLV } from './src/GaragePLV';
@@ -51,7 +50,7 @@ export type { APIRequest, APIResponse } from './src/helpers/ApiHelper';
51
50
  export type { DaySchedule, DayInterval } from './src/ScheduleFields';
52
51
  export type { MovaFormField, MovaLoginForm, MovaUserSignUpForm, MovaInterval, MovaVehicleForm, AddressFieldName, } from './src/helpers/Types';
53
52
  export { readCookie, deleteCookie } from './src/helpers/CookieUtils';
54
- export { validateField, formatVehicleTire, formatFrenchVehiclePlate, isEmpty, getApplicationShortLabel, capitalizeFirstLetter, flexLeftRow, formatPhoneNumber, getFormattedSchedule, getFormattedIntervals, findScheduleByDayOfWeek, getDayOfWeekLabel, isSafariOniOS, iAmOwner, getApplicationsShortLabels, } from './src/helpers/Tools';
53
+ export { validateField, formatVehicleTire, formatFrenchVehiclePlate, isEmpty, getApplicationShortLabel, capitalizeFirstLetter, flexLeftRow, formatPhoneNumber, getFormattedSchedule, getFormattedIntervals, findScheduleByDayOfWeek, getDayOfWeekLabel, isSafariOniOS, getApplicationsShortLabels, } from './src/helpers/Tools';
55
54
  export { validatePhoneNumber, validateText, validateEmail } from './src/helpers/Validator';
56
55
  export { formatDateByCountryCode, getLongFormattedDateTime } from './src/helpers/DateUtils';
57
56
  export { request, API_BASE_URL } from './src/helpers/ApiHelper';
package/dist/index.js CHANGED
@@ -4,9 +4,9 @@ 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.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.LinkedDocumentDialog = 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.UserConnected = exports.UserService = exports.GarageService = exports.AuthenticationService = exports.VehicleService = void 0;
8
- 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.iAmOwner = 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 = exports.CategoryPrestation = exports.VehicleTire = void 0;
9
- exports.StyledToggleButtonGroup = exports.StyledToggleButton = exports.openDialogPrint = exports.APIMethod = void 0;
7
+ 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.LinkedDocumentDialog = 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 = exports.CategoryPrestation = void 0;
9
+ exports.StyledToggleButtonGroup = exports.StyledToggleButton = void 0;
10
10
  // Export des services
11
11
  var VehicleService_1 = require("./src/services/VehicleService");
12
12
  Object.defineProperty(exports, "VehicleService", { enumerable: true, get: function () { return __importDefault(VehicleService_1).default; } });
@@ -16,8 +16,6 @@ var GarageService_1 = require("./src/services/GarageService");
16
16
  Object.defineProperty(exports, "GarageService", { enumerable: true, get: function () { return __importDefault(GarageService_1).default; } });
17
17
  var UserService_1 = require("./src/services/UserService");
18
18
  Object.defineProperty(exports, "UserService", { enumerable: true, get: function () { return __importDefault(UserService_1).default; } });
19
- var UserConnected_1 = require("./src/services/UserConnected");
20
- Object.defineProperty(exports, "UserConnected", { enumerable: true, get: function () { return __importDefault(UserConnected_1).default; } });
21
19
  // Export des composants
22
20
  var DialogForgotPassword_1 = require("./src/DialogForgotPassword");
23
21
  Object.defineProperty(exports, "DialogForgotPassword", { enumerable: true, get: function () { return __importDefault(DialogForgotPassword_1).default; } });
@@ -129,7 +127,6 @@ Object.defineProperty(exports, "getFormattedIntervals", { enumerable: true, get:
129
127
  Object.defineProperty(exports, "findScheduleByDayOfWeek", { enumerable: true, get: function () { return Tools_1.findScheduleByDayOfWeek; } });
130
128
  Object.defineProperty(exports, "getDayOfWeekLabel", { enumerable: true, get: function () { return Tools_1.getDayOfWeekLabel; } });
131
129
  Object.defineProperty(exports, "isSafariOniOS", { enumerable: true, get: function () { return Tools_1.isSafariOniOS; } });
132
- Object.defineProperty(exports, "iAmOwner", { enumerable: true, get: function () { return Tools_1.iAmOwner; } });
133
130
  Object.defineProperty(exports, "getApplicationsShortLabels", { enumerable: true, get: function () { return Tools_1.getApplicationsShortLabels; } });
134
131
  var Validator_1 = require("./src/helpers/Validator");
135
132
  Object.defineProperty(exports, "validatePhoneNumber", { enumerable: true, get: function () { return Validator_1.validatePhoneNumber; } });
@@ -9,7 +9,7 @@ var react_1 = require("react");
9
9
  var VehicleTire_1 = __importDefault(require("./models/VehicleTire"));
10
10
  var Tools_1 = require("./helpers/Tools");
11
11
  // Regex pour une taille de pneumatique Française
12
- var regex = /^\d{9,10}[A-Za-z]$/;
12
+ var regex = /^[A-Za-z0-9]{7}/;
13
13
  var MovaVehicleTireField = function (_a) {
14
14
  var vehicleTire = _a.vehicleTire, onChangeVehicleTire = _a.onChangeVehicleTire;
15
15
  var _b = (0, react_1.useState)(''), tireInfo = _b[0], setTireInfo = _b[1];
@@ -25,12 +25,13 @@ var MovaVehicleTireField = function (_a) {
25
25
  var rawValue = e.target.value;
26
26
  // Cette expression régulière supprimera tous les caractères qui ne sont pas des chiffres ou des lettres alphabétiques, à l'exception de "R" et "r".
27
27
  // On ne peut saisir que 10 caractères maximum (ex : 245551791V)
28
- var value = rawValue.toUpperCase().replace(/[^0-9A-QS-Za-qs-z]/g, '').slice(0, 11);
28
+ var value = rawValue.toUpperCase().replace(/[^0-9A-QS-Za-qs-z]/g, '').slice(0, 15);
29
29
  // On valide la saisie (le champ n'est pas obligatoire)
30
30
  var isValid = value.length == 0 || (value.length > 0 && regex.test(value));
31
31
  setError(!regex.test(value));
32
32
  // Vérifier si l'utilisateur est en train de supprimer un caractère
33
- var isDeleting = value.length < lastLength;
33
+ var isDeleting = rawValue.length < lastLength;
34
+ console.log(isDeleting);
34
35
  // Ajout du " / "
35
36
  if (value.length >= 3 && !(rawValue.length == 5 && isDeleting)) {
36
37
  value = "".concat(value.substring(0, 3), " / ").concat(value.substring(3));
@@ -39,19 +40,46 @@ var MovaVehicleTireField = function (_a) {
39
40
  if (value.length >= 8 && !(rawValue.length == 9 && isDeleting)) {
40
41
  value = "".concat(value.substring(0, 8), " R").concat(value.substring(8));
41
42
  }
43
+ var additonalChar = false;
44
+ if (value[12] && /^[A-Z]$/.test(value[12])) {
45
+ if (rawValue.length === 14 && isDeleting) {
46
+ value = "".concat(value.substring(0, 12));
47
+ }
48
+ else {
49
+ additonalChar = true;
50
+ value = "".concat(value.substring(0, 13), " ").concat(value.substring(13));
51
+ }
52
+ }
42
53
  // Ajout d'un espace après la saisie du diamètre des pneus
43
54
  if (value.length >= 12 && !(rawValue.length <= 12 && isDeleting)) {
44
55
  value = "".concat(value.substring(0, 12), " ").concat(value.substring(12));
45
56
  }
46
- setTireInfo(value);
57
+ //console.log('2 valeu',JSON.stringify(value));
58
+ if (additonalChar) {
59
+ var endString = rawValue.substring(15);
60
+ value = value.substring(0, 15) + (endString !== undefined ? endString : '');
61
+ console.log(rawValue.split(' ')[5]);
62
+ }
63
+ else {
64
+ var endString = rawValue.substring(12);
65
+ if (endString && endString.length > 1) {
66
+ value = value.substring(0, 13) + endString.trimStart();
67
+ }
68
+ }
47
69
  var parts = value.split(" ");
48
- if (value.length >= 16 && !(rawValue.length == 18 && isDeleting) && parts.length === 5) {
70
+ setTireInfo(value);
71
+ console.log(parts);
72
+ if (value.length >= 16) {
49
73
  var width = parts[0], _separator = parts[1], height = parts[2], diameter = parts[3], speedIndex = parts[4];
74
+ speedIndex = value.substring(13);
75
+ console.log('YYY', width, height, diameter, speedIndex, _separator);
50
76
  var vehicleTire_1 = new VehicleTire_1.default(width, height, diameter, speedIndex);
51
77
  onChangeVehicleTire(vehicleTire_1, isValid);
52
78
  }
53
79
  else {
54
80
  var width = parts[0], _separator = parts[1], height = parts[2], diameter = parts[3], speedIndex = parts[4];
81
+ speedIndex = value.substring(13);
82
+ console.log('XXX', width, height, diameter, speedIndex, _separator);
55
83
  var vehicleTire_2 = new VehicleTire_1.default(width !== null && width !== void 0 ? width : '', height !== null && height !== void 0 ? height : '', diameter !== null && diameter !== void 0 ? diameter : '', speedIndex !== null && speedIndex !== void 0 ? speedIndex : '');
56
84
  onChangeVehicleTire(vehicleTire_2, isValid);
57
85
  }
@@ -2,7 +2,9 @@ import { type FC } from 'react';
2
2
  import { MovaVehicleForm } from '../../helpers/Types';
3
3
  import Vehicle from '../../models/Vehicle';
4
4
  import { MovaAppType } from '../../helpers/Enums';
5
+ import User from '../../models/User';
5
6
  interface VehicleFullCardProps {
7
+ currentUser: User;
6
8
  vehicle: Vehicle;
7
9
  onError: (message: string) => void;
8
10
  onUploadDocument: (data: FormData) => void;
@@ -41,7 +41,7 @@ var initialUserFormState = {
41
41
  };
42
42
  var VehicleFullCard = function (_a) {
43
43
  var _b;
44
- var vehicle = _a.vehicle, fullwidth = _a.fullwidth, onError = _a.onError, onUploadDocument = _a.onUploadDocument, onDeleteDocument = _a.onDeleteDocument, appType = _a.appType, _c = _a.editMode, editMode = _c === void 0 ? false : _c, _d = _a.focused, focused = _d === void 0 ? false : _d, onUpdate = _a.onUpdate, onDelete = _a.onDelete, currentUpload = _a.currentUpload;
44
+ var vehicle = _a.vehicle, fullwidth = _a.fullwidth, onError = _a.onError, onUploadDocument = _a.onUploadDocument, onDeleteDocument = _a.onDeleteDocument, appType = _a.appType, _c = _a.editMode, editMode = _c === void 0 ? false : _c, _d = _a.focused, focused = _d === void 0 ? false : _d, onUpdate = _a.onUpdate, onDelete = _a.onDelete, currentUpload = _a.currentUpload, currentUser = _a.currentUser;
45
45
  var theme = (0, material_1.useTheme)();
46
46
  var _e = (0, react_1.useState)(editMode), localEditMode = _e[0], setLocalEditMode = _e[1];
47
47
  var _f = (0, react_1.useState)(false), openConfirmDocumentDelete = _f[0], setOpenConfirmDocumentDelete = _f[1];
@@ -239,7 +239,7 @@ var VehicleFullCard = function (_a) {
239
239
  '& input': { textTransform: 'uppercase' } // CSS pour forcer les majuscules dans l'input
240
240
  }, helperText: Boolean(form.currentMileage.error && form.currentMileage.value > 0)
241
241
  ? form.currentMileage.error : "Sur votre tableau de bord 😉" }) })), !localEditMode && (0, jsx_runtime_1.jsxs)(material_1.Grid, __assign({ container: true, textAlign: 'justify', sx: { pt: 2 } }, { children: [(0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 8 }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "body1", color: "text.secondary" }, { children: "Km moyen annuel :" })) })), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 4, sx: { textAlign: 'right' } }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "body1", color: "text.secondary" }, { children: (0, jsx_runtime_1.jsxs)("b", { children: [vehicle.averageMileagePerYear, " km"] }) })) }))] })), localEditMode && (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 12 }, { children: (0, jsx_runtime_1.jsxs)(material_1.FormControl, __assign({ fullWidth: true, margin: "normal", error: Boolean(form.averageMileagePerYear.error) }, { children: [(0, jsx_runtime_1.jsx)(material_1.InputLabel, __assign({ id: "averageMileagePerYear-label" }, { children: "Kilom\u00E9trage moyen annuel" })), (0, jsx_runtime_1.jsxs)(material_1.Select, __assign({ labelId: "averageMileagePerYear-label", id: "averageMileagePerYear", name: "averageMileagePerYear", value: form.averageMileagePerYear.value ?
242
- String(form.averageMileagePerYear.value) : '', onChange: function (e) { return handleSelectChange(e); }, label: "Kilom\u00E9trage moyen annuel" }, { children: [(0, jsx_runtime_1.jsx)(material_1.MenuItem, __assign({ value: 5000 }, { children: "5 000" })), (0, jsx_runtime_1.jsx)(material_1.MenuItem, __assign({ value: 10000 }, { children: "10 000" })), (0, jsx_runtime_1.jsx)(material_1.MenuItem, __assign({ value: 15000 }, { children: "15 000" })), (0, jsx_runtime_1.jsx)(material_1.MenuItem, __assign({ value: 20000 }, { children: "20 000" })), (0, jsx_runtime_1.jsx)(material_1.MenuItem, __assign({ value: 25000 }, { children: "25 000" })), (0, jsx_runtime_1.jsx)(material_1.MenuItem, __assign({ value: 30000 }, { children: "30 000" })), (0, jsx_runtime_1.jsx)(material_1.MenuItem, __assign({ value: 50000 }, { children: "50 000" })), (0, jsx_runtime_1.jsx)(material_1.MenuItem, __assign({ value: 75000 }, { children: "75 000" })), (0, jsx_runtime_1.jsx)(material_1.MenuItem, __assign({ value: 100000 }, { children: "100 000" })), (0, jsx_runtime_1.jsx)(material_1.MenuItem, __assign({ value: 999999 }, { children: "+100 000" }))] })), (0, jsx_runtime_1.jsx)(material_1.FormHelperText, { children: form.averageMileagePerYear.error })] })) })), !localEditMode && (0, jsx_runtime_1.jsxs)(material_1.Grid, __assign({ container: true, textAlign: 'justify', sx: { pt: 2 } }, { children: [(0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 6 }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "body1", color: "text.secondary" }, { children: "Pneumatiques :" })) })), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 6, sx: { textAlign: 'right' } }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "body1", color: "text.secondary" }, { children: isVehicleTireSizeDefined(vehicle) ? (0, jsx_runtime_1.jsx)("b", { children: (0, Tools_1.formatVehicleTire)(vehicle.tireSize) }) : '-' })) }))] })), localEditMode && (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 12, sx: { mt: 1 } }, { children: (0, jsx_runtime_1.jsx)(MovaVehicleTireField_1.default, { vehicleTire: form.tireSize.value, onChangeVehicleTire: handleOnChangeVehicleTire }) }))] })), !localEditMode && (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 12 }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "h6", component: "div", align: "center", sx: { mt: 3, mb: 1 }, color: (0, material_1.darken)(theme.palette.primary.main, 0.2) }, { children: "CARNET DU V\u00C9HICULE" })) })), vehicle.documents && ((_b = vehicle.documents) === null || _b === void 0 ? void 0 : _b.map(function (invoice, index) { return ((0, jsx_runtime_1.jsxs)(material_1.Grid, __assign({ container: true, sx: { justifyContent: 'space-between', alignItems: 'center' } }, { children: [(0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 11, sx: { textAlign: 'left' } }, { children: (0, jsx_runtime_1.jsx)(material_1.Tooltip, __assign({ title: invoice.originalFileName }, { children: (0, jsx_runtime_1.jsx)(material_1.Link, __assign({ color: (0, material_1.darken)('#F29ABA', 0.2), href: invoice.fileSignedUrl, target: "_blank", rel: "noopener" }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "body1" }, { children: invoice.fileName + ' ' + (0, DateUtils_1.formatDateByCountryCode)(invoice.creationDate, 'fr', Enums_1.DateFormatTypes.SHORT_FORMAT_DATE) })) })) })) }), (index + 1) * 50), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 1, sx: { textAlign: 'right' } }, { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, __assign({ disabled: !(0, Tools_1.iAmOwner)(invoice === null || invoice === void 0 ? void 0 : invoice.ownerId), onClick: function (e) { return handleDeleteDocument(e, invoice === null || invoice === void 0 ? void 0 : invoice.id); } }, { children: (0, jsx_runtime_1.jsx)(CloseRounded_2.default, {}) })) }), (index + 1) * 100)] }), index + 1)); })), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ container: true }, { children: (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 12, sx: { mt: 2, textAlign: 'center' } }, { children: (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("input", { accept: "image/*, application/pdf", type: "file", style: { display: 'none' }, ref: invoiceInputRef, id: "raised-button-invoice", onChange: function (e) { return handleFileChange(e, docTypeCurrent.current); } }), (0, jsx_runtime_1.jsx)(material_1.Button, __assign({ size: 'large', disabled: currentUpload, onClick: function () { return setShowLinkedDocument(true); }, component: "span", variant: "outlined", startIcon: (0, jsx_runtime_1.jsx)(icons_material_1.AttachFile, {}), sx: { alignItems: 'center', width: '90%', mt: 2, mb: 1, height: '50px', p: 1, color: (0, material_1.darken)(theme.palette.primary.main, 0.2) } }, { children: "Ajouter un document" })), currentUpload && (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: 'body2', sx: { animation: 'blink 1.5s infinite' } }, { children: "Document en cours d'importation..." })), sizeLimit && (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: 'body1', sx: { animation: 'blink 1.5s infinite' }, color: theme.palette.warning.dark }, { children: "Echec de l'importation car la taille du fichier d\u00E9passe 10Mo" })), !sizeLimit && (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: 'body2' }, { children: "Taille maximale du fichier : 10Mo" }))] }) })) }))] })] })), (0, jsx_runtime_1.jsxs)(material_1.CardActions, __assign({ sx: { mt: 3, justifyContent: localEditMode ? 'center' : 'end' } }, { children: [!localEditMode &&
242
+ String(form.averageMileagePerYear.value) : '', onChange: function (e) { return handleSelectChange(e); }, label: "Kilom\u00E9trage moyen annuel" }, { children: [(0, jsx_runtime_1.jsx)(material_1.MenuItem, __assign({ value: 5000 }, { children: "5 000" })), (0, jsx_runtime_1.jsx)(material_1.MenuItem, __assign({ value: 10000 }, { children: "10 000" })), (0, jsx_runtime_1.jsx)(material_1.MenuItem, __assign({ value: 15000 }, { children: "15 000" })), (0, jsx_runtime_1.jsx)(material_1.MenuItem, __assign({ value: 20000 }, { children: "20 000" })), (0, jsx_runtime_1.jsx)(material_1.MenuItem, __assign({ value: 25000 }, { children: "25 000" })), (0, jsx_runtime_1.jsx)(material_1.MenuItem, __assign({ value: 30000 }, { children: "30 000" })), (0, jsx_runtime_1.jsx)(material_1.MenuItem, __assign({ value: 50000 }, { children: "50 000" })), (0, jsx_runtime_1.jsx)(material_1.MenuItem, __assign({ value: 75000 }, { children: "75 000" })), (0, jsx_runtime_1.jsx)(material_1.MenuItem, __assign({ value: 100000 }, { children: "100 000" })), (0, jsx_runtime_1.jsx)(material_1.MenuItem, __assign({ value: 999999 }, { children: "+100 000" }))] })), (0, jsx_runtime_1.jsx)(material_1.FormHelperText, { children: form.averageMileagePerYear.error })] })) })), !localEditMode && (0, jsx_runtime_1.jsxs)(material_1.Grid, __assign({ container: true, textAlign: 'justify', sx: { pt: 2 } }, { children: [(0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 6 }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "body1", color: "text.secondary" }, { children: "Pneumatiques :" })) })), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 6, sx: { textAlign: 'right' } }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "body1", color: "text.secondary" }, { children: isVehicleTireSizeDefined(vehicle) ? (0, jsx_runtime_1.jsx)("b", { children: (0, Tools_1.formatVehicleTire)(vehicle.tireSize) }) : '-' })) }))] })), localEditMode && (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 12, sx: { mt: 1 } }, { children: (0, jsx_runtime_1.jsx)(MovaVehicleTireField_1.default, { vehicleTire: form.tireSize.value, onChangeVehicleTire: handleOnChangeVehicleTire }) }))] })), !localEditMode && (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 12 }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "h6", component: "div", align: "center", sx: { mt: 3, mb: 1 }, color: (0, material_1.darken)(theme.palette.primary.main, 0.2) }, { children: "CARNET DU V\u00C9HICULE" })) })), vehicle.documents && ((_b = vehicle.documents) === null || _b === void 0 ? void 0 : _b.map(function (invoice, index) { return ((0, jsx_runtime_1.jsxs)(material_1.Grid, __assign({ container: true, sx: { justifyContent: 'space-between', alignItems: 'center' } }, { children: [(0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 11, sx: { textAlign: 'left' } }, { children: (0, jsx_runtime_1.jsx)(material_1.Tooltip, __assign({ title: invoice.originalFileName }, { children: (0, jsx_runtime_1.jsx)(material_1.Link, __assign({ color: (0, material_1.darken)('#F29ABA', 0.2), href: invoice.fileSignedUrl, target: "_blank", rel: "noopener" }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "body1" }, { children: invoice.fileName + ' ' + (0, DateUtils_1.formatDateByCountryCode)(invoice.creationDate, 'fr', Enums_1.DateFormatTypes.SHORT_FORMAT_DATE) })) })) })) }), (index + 1) * 50), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 1, sx: { textAlign: 'right' } }, { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, __assign({ disabled: !(invoice.ownerId.toString() == currentUser.id), onClick: function (e) { return handleDeleteDocument(e, invoice === null || invoice === void 0 ? void 0 : invoice.id); } }, { children: (0, jsx_runtime_1.jsx)(CloseRounded_2.default, {}) })) }), (index + 1) * 100)] }), index + 1)); })), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ container: true }, { children: (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 12, sx: { mt: 2, textAlign: 'center' } }, { children: (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("input", { accept: "image/*, application/pdf", type: "file", style: { display: 'none' }, ref: invoiceInputRef, id: "raised-button-invoice", onChange: function (e) { return handleFileChange(e, docTypeCurrent.current); } }), (0, jsx_runtime_1.jsx)(material_1.Button, __assign({ size: 'large', disabled: currentUpload, onClick: function () { return setShowLinkedDocument(true); }, component: "span", variant: "outlined", startIcon: (0, jsx_runtime_1.jsx)(icons_material_1.AttachFile, {}), sx: { alignItems: 'center', width: '90%', mt: 2, mb: 1, height: '50px', p: 1, color: (0, material_1.darken)(theme.palette.primary.main, 0.2) } }, { children: "Ajouter un document" })), currentUpload && (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: 'body2', sx: { animation: 'blink 1.5s infinite' } }, { children: "Document en cours d'importation..." })), sizeLimit && (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: 'body1', sx: { animation: 'blink 1.5s infinite' }, color: theme.palette.warning.dark }, { children: "Echec de l'importation car la taille du fichier d\u00E9passe 10Mo" })), !sizeLimit && (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: 'body2' }, { children: "Taille maximale du fichier : 10Mo" }))] }) })) }))] })] })), (0, jsx_runtime_1.jsxs)(material_1.CardActions, __assign({ sx: { mt: 3, justifyContent: localEditMode ? 'center' : 'end' } }, { children: [!localEditMode &&
243
243
  (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsxs)(material_1.Button, __assign({ onClick: handleOnClickEdit, color: "inherit", sx: { width: '45%' }, variant: 'text' }, { children: [(0, jsx_runtime_1.jsx)(EditRounded_1.default, { sx: { mr: 1 } }), "MODIFIER"] })) }), localEditMode &&
244
244
  (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(material_1.Button, __assign({ onClick: handleOnClickCancel, sx: { width: '45%', color: theme.palette.text.secondary }, variant: 'text' }, { children: [(0, jsx_runtime_1.jsx)(CloseRounded_1.default, { sx: { mr: 1 } }), "ANNULER"] })), (0, jsx_runtime_1.jsxs)(material_1.Button, __assign({ onClick: handleOnClickValidate, sx: { width: '45%', color: (0, material_1.darken)(theme.palette.primary.main, 0.2) }, variant: 'text' }, { children: [(0, jsx_runtime_1.jsx)(EditRounded_1.default, { sx: { mr: 1 } }), "VALIDER"] }))] })] }))] })), isShowLinkedDocument && (0, jsx_runtime_1.jsx)(LinkedDocumentDialog_1.LinkedDocumentDialog, { isVehicle: true, isShowLinkedDocument: isShowLinkedDocument, appType: appType, toggleShowLinkedDocument: toggleShowLinkedDocument, message: messageRGPD }), localEditMode && onDelete &&
245
245
  (0, jsx_runtime_1.jsx)(material_1.Button, __assign({ onClick: function (e) { return handleOnClickDeleteVehicle(e); }, sx: {
@@ -9,7 +9,6 @@ export declare const isSafariOniOS: () => boolean;
9
9
  export declare const FR_WEEK_DAYS: string[];
10
10
  export declare const getDayOfWeekLabel: (day: DayOfWeek) => string | undefined;
11
11
  export declare const getDayOfWeekIndex: (day: DayOfWeek) => number;
12
- export declare const iAmOwner: (ownreId: number) => boolean;
13
12
  export declare const formatPhoneNumber: (phoneNumber: string) => string;
14
13
  export declare const getFormattedSchedule: (schedule: Schedule | null, dayIndex: number) => string;
15
14
  export declare const getFormattedIntervals: (intervals: MovaInterval[]) => string | undefined;
@@ -1,11 +1,7 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.validateField = exports.formatVehicleTireStr = exports.formatVehicleTire = exports.formatFrenchVehiclePlate = exports.isEmpty = exports.flexCenter = exports.flexEnd = exports.getApplicationShortLabel = exports.capitalizeFirstLetter = exports.flexLeftRow = exports.getFrenchDayLabel = exports.getDayOfWeek = exports.findScheduleByDayOfWeek = exports.formatTime = exports.getFormattedIntervals = exports.getFormattedSchedule = exports.formatPhoneNumber = exports.iAmOwner = exports.getDayOfWeekIndex = exports.getDayOfWeekLabel = exports.FR_WEEK_DAYS = exports.isSafariOniOS = exports.flexStart = exports.getApplicationsShortLabels = void 0;
3
+ exports.validateField = exports.formatVehicleTireStr = exports.formatVehicleTire = exports.formatFrenchVehiclePlate = exports.isEmpty = exports.flexCenter = exports.flexEnd = exports.getApplicationShortLabel = exports.capitalizeFirstLetter = exports.flexLeftRow = exports.getFrenchDayLabel = exports.getDayOfWeek = exports.findScheduleByDayOfWeek = exports.formatTime = exports.getFormattedIntervals = exports.getFormattedSchedule = exports.formatPhoneNumber = exports.getDayOfWeekIndex = exports.getDayOfWeekLabel = exports.FR_WEEK_DAYS = exports.isSafariOniOS = exports.flexStart = exports.getApplicationsShortLabels = void 0;
7
4
  var Enums_1 = require("./Enums");
8
- var UserConnected_1 = __importDefault(require("../services/UserConnected"));
9
5
  var getApplicationsShortLabels = function (applications) {
10
6
  if (!applications) {
11
7
  return '';
@@ -42,11 +38,6 @@ var getDayOfWeekIndex = function (day) {
42
38
  return -1;
43
39
  };
44
40
  exports.getDayOfWeekIndex = getDayOfWeekIndex;
45
- var iAmOwner = function (ownreId) {
46
- var _a;
47
- return ownreId === ((_a = UserConnected_1.default.getInstance().me) === null || _a === void 0 ? void 0 : _a.id);
48
- };
49
- exports.iAmOwner = iAmOwner;
50
41
  var formatPhoneNumber = function (phoneNumber) {
51
42
  var formattedNumber = "";
52
43
  if (phoneNumber) {
@@ -227,20 +218,18 @@ var formatVehicleTire = function (vehicleTire) {
227
218
  };
228
219
  exports.formatVehicleTire = formatVehicleTire;
229
220
  var formatVehicleTireStr = function (input) {
230
- var formatted = input.toUpperCase().replace(/[^0-9A-QS-Za-qs-z]/g, '').slice(0, 10);
231
- if (formatted.length >= 3) {
221
+ var formatted = input.toUpperCase().replace(/[^0-9A-QS-Za-qs-z]/g, '').slice(0, 7);
222
+ if (formatted.length > 3) {
232
223
  formatted = "".concat(formatted.substring(0, 3), " / ").concat(formatted.substring(3));
233
224
  }
234
- var indexOfR = formatted.indexOf(" R");
235
- if (formatted.length >= 8 && indexOfR === -1) {
236
- formatted = "".concat(formatted.substring(0, 8), " R").concat(formatted.substring(8));
237
- if (formatted.length >= 12 && indexOfR === -1)
238
- formatted = "".concat(formatted.substring(0, 12), " ").concat(formatted.substring(12));
225
+ var indexOfRraw = input.indexOf("R");
226
+ var toAdd = indexOfRraw !== -1 ? input.substring(indexOfRraw + 3) : '';
227
+ if (toAdd.length > 0) {
228
+ toAdd = ' ' + toAdd;
239
229
  }
240
- else if (indexOfR !== -1 && formatted.length > indexOfR + 2) {
241
- formatted = "".concat(formatted.substring(0, indexOfR + 2), " ").concat(formatted.substring(indexOfR + 2));
230
+ if (formatted.length > 8) {
231
+ formatted = "".concat(formatted.substring(0, 8), " R").concat(formatted.substring(8)).concat(toAdd);
242
232
  }
243
- console.log(formatted);
244
233
  return formatted;
245
234
  };
246
235
  exports.formatVehicleTireStr = formatVehicleTireStr;
@@ -43,7 +43,6 @@ var ApiHelper_1 = require("../helpers/ApiHelper");
43
43
  var CookieUtils_1 = require("../helpers/CookieUtils");
44
44
  var Enums_1 = require("../helpers/Enums");
45
45
  var Logger_1 = __importDefault(require("../helpers/Logger"));
46
- var UserConnected_1 = __importDefault(require("./UserConnected"));
47
46
  var UserService_1 = __importDefault(require("./UserService"));
48
47
  var AuthenticationService = /** @class */ (function () {
49
48
  function AuthenticationService() {
@@ -111,7 +110,6 @@ var AuthenticationService = /** @class */ (function () {
111
110
  Logger_1.default.error(errorMsg);
112
111
  return [2 /*return*/, { success: false, error: errorMsg }];
113
112
  }
114
- UserConnected_1.default.getInstance().me = userResponse.data;
115
113
  return [2 /*return*/, { success: true, data: userResponse.data }];
116
114
  case 3: return [2 /*return*/, tokenResponse];
117
115
  case 4: return [3 /*break*/, 6];
package/index.ts CHANGED
@@ -6,7 +6,6 @@ export { default as VehicleService } from './src/services/VehicleService';
6
6
  export { default as AuthenticationService } from './src/services/AuthenticationService';
7
7
  export { default as GarageService } from './src/services/GarageService';
8
8
  export { default as UserService } from './src/services/UserService';
9
- export { default as UserConnected } from './src/services/UserConnected';
10
9
  // Export des composants
11
10
  export { default as DialogForgotPassword } from './src/DialogForgotPassword';
12
11
  export { default as IbanInput } from './src/IbanInput';
@@ -81,7 +80,6 @@ export {
81
80
  findScheduleByDayOfWeek,
82
81
  getDayOfWeekLabel,
83
82
  isSafariOniOS,
84
- iAmOwner,
85
83
  getApplicationsShortLabels,
86
84
  } from './src/helpers/Tools';
87
85
  export { validatePhoneNumber, validateText, validateEmail } from './src/helpers/Validator';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@movalib/movalib-commons",
3
- "version": "1.59.15",
3
+ "version": "1.59.17",
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",
@@ -9,7 +9,7 @@ interface MovaVehicleTireFieldProps {
9
9
  }
10
10
 
11
11
  // Regex pour une taille de pneumatique Française
12
- const regex = /^\d{9,10}[A-Za-z]$/;
12
+ const regex = /^[A-Za-z0-9]{7}/;
13
13
 
14
14
  const MovaVehicleTireField: FC<MovaVehicleTireFieldProps> = ({ vehicleTire, onChangeVehicleTire }) => {
15
15
 
@@ -27,46 +27,67 @@ const MovaVehicleTireField: FC<MovaVehicleTireFieldProps> = ({ vehicleTire, onCh
27
27
  const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
28
28
  e.preventDefault();
29
29
  const rawValue = e.target.value;
30
-
31
30
  // Cette expression régulière supprimera tous les caractères qui ne sont pas des chiffres ou des lettres alphabétiques, à l'exception de "R" et "r".
32
31
  // On ne peut saisir que 10 caractères maximum (ex : 245551791V)
33
- let value = rawValue.toUpperCase().replace(/[^0-9A-QS-Za-qs-z]/g, '').slice(0, 11);
32
+ let value = rawValue.toUpperCase().replace(/[^0-9A-QS-Za-qs-z]/g, '').slice(0, 15);
34
33
 
35
34
  // On valide la saisie (le champ n'est pas obligatoire)
36
35
  let isValid = value.length == 0 || (value.length > 0 && regex.test(value));
37
36
  setError(!regex.test(value));
38
37
 
39
38
  // Vérifier si l'utilisateur est en train de supprimer un caractère
40
- const isDeleting = value.length < lastLength;
41
-
39
+ const isDeleting = rawValue.length < lastLength;
42
40
  // Ajout du " / "
43
41
  if (value.length >= 3 && !(rawValue.length == 5 && isDeleting)) {
44
42
  value = `${value.substring(0, 3)} / ${value.substring(3)}`;
45
43
  }
46
-
44
+
47
45
  // Ajout du " R"
48
46
  if (value.length >= 8 && !(rawValue.length == 9 && isDeleting)) {
49
47
  value = `${value.substring(0, 8)} R${value.substring(8)}`;
50
48
  }
51
49
 
50
+ let additonalChar = false;
51
+
52
+ if (value[12] && /^[A-Z]$/.test(value[12])) {
53
+ if(rawValue.length === 14 && isDeleting) {
54
+ value = `${value.substring(0, 12)}`;
55
+ } else {
56
+ additonalChar = true;
57
+ value = `${value.substring(0, 13)} ${value.substring(13)}`;
58
+ }
59
+ }
60
+
52
61
 
53
62
  // Ajout d'un espace après la saisie du diamètre des pneus
54
63
  if (value.length >= 12 && !(rawValue.length <= 12 && isDeleting)) {
55
64
  value = `${value.substring(0, 12)} ${value.substring(12)}`;
56
65
  }
66
+ //console.log('2 valeu',JSON.stringify(value));
67
+ if (additonalChar) {
68
+ let endString = rawValue.substring(15);
69
+ value = value.substring(0,15) + (endString !== undefined ? endString :'');
70
+ console.log(rawValue.split(' ')[5]);
71
+ } else {
72
+ let endString = rawValue.substring(12);
73
+ if(endString && endString.length > 1) {
74
+ value = value.substring(0,13) + endString.trimStart();
75
+ }
76
+ }
57
77
 
58
- setTireInfo(value);
59
78
 
60
79
  const parts = value.split(" ");
61
80
 
62
- if (value.length >= 16 && !(rawValue.length == 18 && isDeleting) && parts.length === 5) {
63
- const [width, _separator, height, diameter, speedIndex] = parts;
81
+ setTireInfo(value);
82
+ if (value.length >= 16) {
83
+ let [width, _separator, height, diameter, speedIndex] = parts;
84
+ speedIndex = value.substring(13);
64
85
  const vehicleTire = new VehicleTire(width, height, diameter, speedIndex);
65
86
  onChangeVehicleTire(vehicleTire, isValid);
66
87
  } else {
67
- const [width, _separator, height, diameter, speedIndex] = parts;
88
+ let [width, _separator, height, diameter, speedIndex] = parts;
89
+ speedIndex = value.substring(13);
68
90
  const vehicleTire = new VehicleTire(width ?? '', height ?? '', diameter ?? '', speedIndex ?? '');
69
-
70
91
  onChangeVehicleTire(vehicleTire, isValid);
71
92
  }
72
93
 
@@ -11,7 +11,7 @@ import VehicleTire from '../../models/VehicleTire';
11
11
  import MovaVehicleTireField from '../../MovaVehicleTireField';
12
12
  import ConfirmationDialog from '../../ConfirmationDialog';
13
13
  import { DocumentType, DateFormatTypes, MovaAppType } from '../../helpers/Enums';
14
- import { validateField, formatVehicleTire, formatFrenchVehiclePlate, iAmOwner } from '../../helpers/Tools';
14
+ import { validateField, formatVehicleTire, formatFrenchVehiclePlate } from '../../helpers/Tools';
15
15
  import MovaDigitalPassport from '../../MovaDigitalPassport';
16
16
  import Loader from '../../Loader';
17
17
  import { formatDateByCountryCode } from '../../helpers/DateUtils';
@@ -21,8 +21,10 @@ import CloseIcon from '@mui/icons-material/CloseRounded';
21
21
  import Logger from '../../helpers/Logger';
22
22
  import { AttachFile } from '@mui/icons-material';
23
23
  import { LinkedDocumentDialog } from '../LinkedDocumentDialog';
24
+ import User from '../../models/User';
24
25
 
25
26
  interface VehicleFullCardProps {
27
+ currentUser: User,
26
28
  vehicle: Vehicle,
27
29
  onError: (message: string) => void,
28
30
  onUploadDocument: (data: FormData) => void,
@@ -46,7 +48,7 @@ const initialUserFormState = {
46
48
  tireSpeedIndex: { value: '', isValid: true }
47
49
  }
48
50
 
49
- const VehicleFullCard: FC<VehicleFullCardProps> = ({ vehicle, fullwidth, onError, onUploadDocument, onDeleteDocument, appType, editMode = false, focused = false, onUpdate, onDelete, currentUpload }) => {
51
+ const VehicleFullCard: FC<VehicleFullCardProps> = ({ vehicle, fullwidth, onError, onUploadDocument, onDeleteDocument, appType, editMode = false, focused = false, onUpdate, onDelete, currentUpload, currentUser }) => {
50
52
 
51
53
  const theme = useTheme();
52
54
  const [localEditMode, setLocalEditMode] = useState(editMode);
@@ -408,7 +410,7 @@ const VehicleFullCard: FC<VehicleFullCardProps> = ({ vehicle, fullwidth, onError
408
410
  </Tooltip>
409
411
  </Grid>
410
412
  <Grid item xs={1} key={(index + 1) * 100} sx={{ textAlign: 'right' }}>
411
- <IconButton disabled={!iAmOwner(invoice?.ownerId)} onClick={(e) => handleDeleteDocument(e, invoice?.id)}>
413
+ <IconButton disabled={!(invoice.ownerId.toString() == currentUser.id)} onClick={(e) => handleDeleteDocument(e, invoice?.id)}>
412
414
  <CloseIcon />
413
415
  </IconButton>
414
416
  </Grid>
@@ -4,7 +4,6 @@ import { MovaFormField, MovaInterval } from "./Types";
4
4
  import { CSSProperties } from "react";
5
5
  import { DayOfWeek, PartsApplicationType, VehiclePlateFormat } from "./Enums";
6
6
  import Schedule from "../models/Schedule";
7
- import UserConnected from "../services/UserConnected";
8
7
 
9
8
  export const getApplicationsShortLabels = (applications: PartsApplicationType[] | undefined): string => {
10
9
  if(!applications) {
@@ -47,9 +46,6 @@ export const getDayOfWeekIndex = (day: DayOfWeek) => {
47
46
  return -1;
48
47
  }
49
48
 
50
- export const iAmOwner = (ownreId: number): boolean => {
51
- return ownreId === UserConnected.getInstance().me?.id;
52
- }
53
49
 
54
50
  export const formatPhoneNumber = (phoneNumber: string): string => {
55
51
  let formattedNumber = "";
@@ -243,26 +239,18 @@ export const formatVehicleTire = (vehicleTire: VehicleTire) => {
243
239
  }
244
240
 
245
241
  export const formatVehicleTireStr = (input: string) => {
246
-
247
- let formatted = input.toUpperCase().replace(/[^0-9A-QS-Za-qs-z]/g, '').slice(0, 10);
248
-
249
- if (formatted.length >= 3) {
242
+ let formatted = input.toUpperCase().replace(/[^0-9A-QS-Za-qs-z]/g, '').slice(0, 7);
243
+ if (formatted.length > 3) {
250
244
  formatted = `${formatted.substring(0, 3)} / ${formatted.substring(3)}`;
251
245
  }
252
-
253
- const indexOfR = formatted.indexOf(" R");
254
-
255
- if (formatted.length >= 8 && indexOfR === -1) {
256
- formatted = `${formatted.substring(0, 8)} R${formatted.substring(8)}`;
257
-
258
- if (formatted.length >= 12 && indexOfR === -1)
259
- formatted = `${formatted.substring(0, 12)} ${formatted.substring(12)}`;
260
-
261
- } else if (indexOfR !== -1 && formatted.length > indexOfR + 2) {
262
- formatted = `${formatted.substring(0, indexOfR + 2)} ${formatted.substring(indexOfR + 2)}`;
246
+ const indexOfRraw = input.indexOf("R");
247
+ let toAdd = indexOfRraw !== -1 ? input.substring(indexOfRraw + 3) : '';
248
+ if(toAdd.length > 0) {
249
+ toAdd = ' ' + toAdd;
250
+ }
251
+ if(formatted.length > 8) {
252
+ formatted = `${formatted.substring(0, 8)} R${formatted.substring(8)}${toAdd}`;
263
253
  }
264
-
265
- console.log(formatted);
266
254
  return formatted;
267
255
  };
268
256
 
@@ -3,7 +3,6 @@ import { COOKIE_PRO_TOKEN, COOKIE_INDIVIDUAL_TOKEN, createCookie } from "../help
3
3
  import { APIMethod, MovaAppType } from "../helpers/Enums";
4
4
  import Logger from "../helpers/Logger";
5
5
  import User from "../models/User";
6
- import UserConnected from "./UserConnected";
7
6
  import UserService from "./UserService";
8
7
 
9
8
  export default class AuthenticationService {
@@ -69,7 +68,6 @@ export default class AuthenticationService {
69
68
  Logger.error(errorMsg);
70
69
  return { success: false, error: errorMsg };
71
70
  }
72
- UserConnected.getInstance().me = userResponse.data;
73
71
  return { success: true, data: userResponse.data };
74
72
 
75
73
  } else {
@@ -1,9 +0,0 @@
1
- export default class UserConnected {
2
- private static instance;
3
- private _me;
4
- private constructor();
5
- static getInstance(): UserConnected;
6
- get me(): any;
7
- set me(user: any);
8
- clearUser(): void;
9
- }
@@ -1,59 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- var UserService_1 = __importDefault(require("./UserService"));
7
- var UserConnected = /** @class */ (function () {
8
- function UserConnected() {
9
- var storedUser = localStorage.getItem('user');
10
- this._me = storedUser ? JSON.parse(storedUser) : null;
11
- }
12
- UserConnected.getInstance = function () {
13
- if (!UserConnected.instance) {
14
- UserConnected.instance = new UserConnected();
15
- }
16
- return UserConnected.instance;
17
- };
18
- Object.defineProperty(UserConnected.prototype, "me", {
19
- get: function () {
20
- var _this = this;
21
- if (!this._me) {
22
- var storedUser = localStorage.getItem('user');
23
- if (storedUser === undefined || storedUser === null || storedUser === 'undefined') {
24
- UserService_1.default.getCurrentUser()
25
- .then(function (response) {
26
- localStorage.setItem('user', JSON.stringify(response.data));
27
- _this._me = response.data;
28
- return _this._me;
29
- });
30
- }
31
- else {
32
- this._me = JSON.parse(storedUser);
33
- return this._me;
34
- }
35
- }
36
- else {
37
- return this._me;
38
- }
39
- },
40
- set: function (user) {
41
- this._me = user;
42
- if (user) {
43
- localStorage.setItem('user', JSON.stringify(user));
44
- }
45
- else {
46
- localStorage.removeItem('user'); // Supprime les données si user est null ou undefined
47
- }
48
- },
49
- enumerable: false,
50
- configurable: true
51
- });
52
- UserConnected.prototype.clearUser = function () {
53
- // Méthode pour effacer l'utilisateur
54
- this._me = null;
55
- localStorage.removeItem('user');
56
- };
57
- return UserConnected;
58
- }());
59
- exports.default = UserConnected;
@@ -1,56 +0,0 @@
1
- import User from "../models/User";
2
- import UserService from "./UserService";
3
-
4
- export default class UserConnected {
5
- private static instance: UserConnected;
6
- private _me: User | null; // Replace 'any' with the appropriate type for the user information
7
-
8
- private constructor() {
9
- const storedUser = localStorage.getItem('user');
10
- this._me = storedUser ? JSON.parse(storedUser) : null;
11
- }
12
-
13
- public static getInstance(): UserConnected {
14
- if (!UserConnected.instance) {
15
- UserConnected.instance = new UserConnected();
16
- }
17
-
18
- return UserConnected.instance;
19
- }
20
-
21
- public get me(): any {
22
- if (!this._me) {
23
- const storedUser = localStorage.getItem('user');
24
- if(storedUser === undefined || storedUser === null || storedUser === 'undefined') {
25
- UserService.getCurrentUser()
26
- .then((response) => {
27
- localStorage.setItem('user', JSON.stringify(response.data));
28
- this._me = response.data as User;
29
- return this._me;
30
- })
31
- } else {
32
- this._me = JSON.parse(storedUser);
33
- return this._me;
34
- }
35
- } else {
36
- return this._me;
37
- }
38
- }
39
-
40
-
41
- public set me(user: any) {
42
- this._me = user;
43
- if (user) {
44
- localStorage.setItem('user', JSON.stringify(user));
45
- } else {
46
- localStorage.removeItem('user'); // Supprime les données si user est null ou undefined
47
- }
48
- }
49
-
50
- public clearUser() {
51
- // Méthode pour effacer l'utilisateur
52
- this._me = null;
53
- localStorage.removeItem('user');
54
- }
55
-
56
- }