@movalib/movalib-commons 1.59.16 → 1.59.18

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) {
@@ -8,6 +8,7 @@ type ConfirmationDialogProps = DialogProps & {
8
8
  closeLabel?: string;
9
9
  title?: React.ReactNode;
10
10
  message?: React.ReactNode;
11
+ autoFocus?: boolean;
11
12
  };
12
13
  declare const ConfirmationDialog: FunctionComponent<ConfirmationDialogProps>;
13
14
  export default ConfirmationDialog;
@@ -35,7 +35,7 @@ var Button_1 = __importDefault(require("@mui/material/Button"));
35
35
  var material_1 = require("@mui/material");
36
36
  var Tools_1 = require("./helpers/Tools");
37
37
  var ConfirmationDialog = function (_a) {
38
- var open = _a.open, onClose = _a.onClose, onConfirm = _a.onConfirm, title = _a.title, message = _a.message, _b = _a.showConfirm, showConfirm = _b === void 0 ? true : _b, confirmLabel = _a.confirmLabel, closeLabel = _a.closeLabel, dialogProps = __rest(_a, ["open", "onClose", "onConfirm", "title", "message", "showConfirm", "confirmLabel", "closeLabel"]);
38
+ var open = _a.open, onClose = _a.onClose, onConfirm = _a.onConfirm, title = _a.title, message = _a.message, _b = _a.showConfirm, showConfirm = _b === void 0 ? true : _b, confirmLabel = _a.confirmLabel, closeLabel = _a.closeLabel, _c = _a.autoFocus, autoFocus = _c === void 0 ? true : _c, dialogProps = __rest(_a, ["open", "onClose", "onConfirm", "title", "message", "showConfirm", "confirmLabel", "closeLabel", "autoFocus"]);
39
39
  var theme = (0, material_1.useTheme)();
40
40
  var defaultMessage = "Êtes-vous sûr de vouloir continuer ?";
41
41
  var defaultTitle = "Confirmation";
@@ -46,6 +46,6 @@ var ConfirmationDialog = function (_a) {
46
46
  }, style: Tools_1.flexLeftRow }, { children: title || defaultTitle })), (0, jsx_runtime_1.jsx)(DialogContent_1.default, __assign({ sx: { textAlign: 'center' } }, { children: (0, jsx_runtime_1.jsx)(DialogContentText_1.default, __assign({ id: "alert-dialog-description", sx: { pt: 2 } }, { children: message || defaultMessage })) })), (0, jsx_runtime_1.jsxs)(DialogActions_1.default, __assign({ sx: {
47
47
  py: 1,
48
48
  backgroundColor: theme.palette.grey[200]
49
- } }, { children: [showConfirm && (0, jsx_runtime_1.jsx)(Button_1.default, __assign({ onClick: onConfirm, color: "inherit", autoFocus: true, sx: { ml: 1 } }, { children: (0, jsx_runtime_1.jsx)("b", { children: confirmLabel || defaultConfirmLabel }) })), (0, jsx_runtime_1.jsx)(Button_1.default, __assign({ onClick: onClose, color: "inherit" }, { children: closeLabel || defaultCloseLabel }))] }))] })));
49
+ } }, { children: [showConfirm && (0, jsx_runtime_1.jsx)(Button_1.default, __assign({ onClick: onConfirm, color: "inherit", autoFocus: autoFocus, sx: { ml: 1 } }, { children: (0, jsx_runtime_1.jsx)("b", { children: confirmLabel || defaultConfirmLabel }) })), (0, jsx_runtime_1.jsx)(Button_1.default, __assign({ onClick: onClose, color: "inherit" }, { children: closeLabel || defaultCloseLabel }))] }))] })));
50
50
  };
51
51
  exports.default = ConfirmationDialog;
@@ -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,12 @@ 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
34
  // Ajout du " / "
35
35
  if (value.length >= 3 && !(rawValue.length == 5 && isDeleting)) {
36
36
  value = "".concat(value.substring(0, 3), " / ").concat(value.substring(3));
@@ -39,19 +39,43 @@ var MovaVehicleTireField = function (_a) {
39
39
  if (value.length >= 8 && !(rawValue.length == 9 && isDeleting)) {
40
40
  value = "".concat(value.substring(0, 8), " R").concat(value.substring(8));
41
41
  }
42
+ var additonalChar = false;
43
+ if (value[12] && /^[A-Z]$/.test(value[12])) {
44
+ if (rawValue.length === 14 && isDeleting) {
45
+ value = "".concat(value.substring(0, 12));
46
+ }
47
+ else {
48
+ additonalChar = true;
49
+ value = "".concat(value.substring(0, 13), " ").concat(value.substring(13));
50
+ }
51
+ }
42
52
  // Ajout d'un espace après la saisie du diamètre des pneus
43
53
  if (value.length >= 12 && !(rawValue.length <= 12 && isDeleting)) {
44
54
  value = "".concat(value.substring(0, 12), " ").concat(value.substring(12));
45
55
  }
46
- setTireInfo(value);
56
+ //console.log('2 valeu',JSON.stringify(value));
57
+ if (additonalChar) {
58
+ var endString = rawValue.substring(15);
59
+ value = value.substring(0, 15) + (endString !== undefined ? endString : '');
60
+ console.log(rawValue.split(' ')[5]);
61
+ }
62
+ else {
63
+ var endString = rawValue.substring(12);
64
+ if (endString && endString.length > 1) {
65
+ value = value.substring(0, 13) + endString.trimStart();
66
+ }
67
+ }
47
68
  var parts = value.split(" ");
48
- if (value.length >= 16 && !(rawValue.length == 18 && isDeleting) && parts.length === 5) {
69
+ setTireInfo(value);
70
+ if (value.length >= 16) {
49
71
  var width = parts[0], _separator = parts[1], height = parts[2], diameter = parts[3], speedIndex = parts[4];
72
+ speedIndex = value.substring(13);
50
73
  var vehicleTire_1 = new VehicleTire_1.default(width, height, diameter, speedIndex);
51
74
  onChangeVehicleTire(vehicleTire_1, isValid);
52
75
  }
53
76
  else {
54
77
  var width = parts[0], _separator = parts[1], height = parts[2], diameter = parts[3], speedIndex = parts[4];
78
+ speedIndex = value.substring(13);
55
79
  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
80
  onChangeVehicleTire(vehicleTire_2, isValid);
57
81
  }
@@ -218,20 +218,18 @@ var formatVehicleTire = function (vehicleTire) {
218
218
  };
219
219
  exports.formatVehicleTire = formatVehicleTire;
220
220
  var formatVehicleTireStr = function (input) {
221
- var formatted = input.toUpperCase().replace(/[^0-9A-QS-Za-qs-z]/g, '').slice(0, 10);
222
- 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) {
223
223
  formatted = "".concat(formatted.substring(0, 3), " / ").concat(formatted.substring(3));
224
224
  }
225
- var indexOfR = formatted.indexOf(" R");
226
- if (formatted.length >= 8 && indexOfR === -1) {
227
- formatted = "".concat(formatted.substring(0, 8), " R").concat(formatted.substring(8));
228
- if (formatted.length >= 12 && indexOfR === -1)
229
- 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;
230
229
  }
231
- else if (indexOfR !== -1 && formatted.length > indexOfR + 2) {
232
- 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);
233
232
  }
234
- console.log(formatted);
235
233
  return formatted;
236
234
  };
237
235
  exports.formatVehicleTireStr = formatVehicleTireStr;
@@ -17,7 +17,9 @@ export default class GarageService {
17
17
  static sendGarageMandate(garageId: string): Promise<APIResponse<string>>;
18
18
  static getGarageAllData(garageId: string): Promise<APIResponse<Garage>>;
19
19
  static createGaragePrestationRequest(garageId: string, req: any): Promise<APIResponse<string>>;
20
- static getGarageSettings(garageId: string): Promise<APIResponse<Garage>>;
20
+ static getGarageSettings({ garageId }: {
21
+ garageId: string;
22
+ }): Promise<APIResponse<Garage>>;
21
23
  static uploadLogo(garageId: string, formData: FormData): Promise<APIResponse<string>>;
22
24
  static sendAppointmentVehicleAvailable(garageId: string, eventId: string): Promise<APIResponse<string>>;
23
25
  static enableGaragePrestation(garageId: string, prestationId: string): Promise<APIResponse<string>>;
@@ -121,7 +121,8 @@ var GarageService = /** @class */ (function () {
121
121
  body: JSON.stringify(req),
122
122
  });
123
123
  };
124
- GarageService.getGarageSettings = function (garageId) {
124
+ GarageService.getGarageSettings = function (_a) {
125
+ var garageId = _a.garageId;
125
126
  return (0, ApiHelper_1.request)({
126
127
  url: "".concat(ApiHelper_1.API_BASE_URL, "/garage/").concat(garageId, "/settings"),
127
128
  method: Enums_1.APIMethod.GET,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@movalib/movalib-commons",
3
- "version": "1.59.16",
3
+ "version": "1.59.18",
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",
@@ -16,10 +16,11 @@ type ConfirmationDialogProps = DialogProps & {
16
16
  closeLabel?: string;
17
17
  title?: React.ReactNode;
18
18
  message?: React.ReactNode;
19
+ autoFocus?: boolean;
19
20
  }
20
21
 
21
22
  const ConfirmationDialog: FunctionComponent<ConfirmationDialogProps> = ({ open, onClose, onConfirm, title, message, showConfirm = true,
22
- confirmLabel, closeLabel, ...dialogProps }) => {
23
+ confirmLabel, closeLabel,autoFocus = true, ...dialogProps }) => {
23
24
 
24
25
  const theme = useTheme();
25
26
  const defaultMessage = "Êtes-vous sûr de vouloir continuer ?";
@@ -51,7 +52,7 @@ const ConfirmationDialog: FunctionComponent<ConfirmationDialogProps> = ({ open,
51
52
  backgroundColor: theme.palette.grey[200]
52
53
  }}
53
54
  >
54
- {showConfirm && <Button onClick={onConfirm} color="inherit" autoFocus sx={{ ml: 1}}>
55
+ {showConfirm && <Button onClick={onConfirm} color="inherit" autoFocus={autoFocus} sx={{ ml: 1}}>
55
56
  <b>{confirmLabel || defaultConfirmLabel}</b>
56
57
  </Button>}
57
58
  <Button onClick={onClose} color="inherit">
@@ -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
 
@@ -239,26 +239,18 @@ export const formatVehicleTire = (vehicleTire: VehicleTire) => {
239
239
  }
240
240
 
241
241
  export const formatVehicleTireStr = (input: string) => {
242
-
243
- let formatted = input.toUpperCase().replace(/[^0-9A-QS-Za-qs-z]/g, '').slice(0, 10);
244
-
245
- 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) {
246
244
  formatted = `${formatted.substring(0, 3)} / ${formatted.substring(3)}`;
247
245
  }
248
-
249
- const indexOfR = formatted.indexOf(" R");
250
-
251
- if (formatted.length >= 8 && indexOfR === -1) {
252
- formatted = `${formatted.substring(0, 8)} R${formatted.substring(8)}`;
253
-
254
- if (formatted.length >= 12 && indexOfR === -1)
255
- formatted = `${formatted.substring(0, 12)} ${formatted.substring(12)}`;
256
-
257
- } else if (indexOfR !== -1 && formatted.length > indexOfR + 2) {
258
- 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}`;
259
253
  }
260
-
261
- console.log(formatted);
262
254
  return formatted;
263
255
  };
264
256
 
@@ -149,7 +149,7 @@ export default class GarageService {
149
149
  });
150
150
  }
151
151
 
152
- static getGarageSettings(garageId: string): Promise<APIResponse<Garage>> {
152
+ static getGarageSettings({garageId}: { garageId: string }): Promise<APIResponse<Garage>> {
153
153
  return request({
154
154
  url: `${API_BASE_URL}/garage/${garageId}/settings`,
155
155
  method: APIMethod.GET,