@movalib/movalib-commons 1.68.8 → 1.68.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -58,7 +58,6 @@ var material_1 = require("@mui/material");
58
58
  var x_date_pickers_1 = require("@mui/x-date-pickers");
59
59
  var moment_1 = __importDefault(require("moment"));
60
60
  var react_1 = require("react");
61
- var car_plate_bg_png_1 = __importDefault(require("../../assets/images/car_plate_bg.png"));
62
61
  var ConfirmationDialog_1 = __importDefault(require("../../ConfirmationDialog"));
63
62
  var DateUtils_1 = require("../../helpers/DateUtils");
64
63
  var Enums_1 = require("../../helpers/Enums");
@@ -85,21 +84,35 @@ var initialUserFormState = {
85
84
  secondaryTireWidth: { value: "", isValid: true },
86
85
  secondaryTireSize: { value: null, isValid: true },
87
86
  };
87
+ // Styles partagés pour les lignes label/valeur
88
+ var rowSx = {
89
+ display: "flex",
90
+ justifyContent: "space-between",
91
+ alignItems: "center",
92
+ py: 0.75,
93
+ borderBottom: "0.5px solid",
94
+ borderColor: "divider",
95
+ "&:last-child": { borderBottom: "none" },
96
+ };
88
97
  var VehicleFullCard = function (_a) {
89
- var _b;
90
- 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;
98
+ var _b, _c, _d, _e;
99
+ var vehicle = _a.vehicle, fullwidth = _a.fullwidth, onError = _a.onError, onUploadDocument = _a.onUploadDocument, onDeleteDocument = _a.onDeleteDocument, appType = _a.appType, _f = _a.editMode, editMode = _f === void 0 ? false : _f, _g = _a.focused, focused = _g === void 0 ? false : _g, onUpdate = _a.onUpdate, onDelete = _a.onDelete, currentUpload = _a.currentUpload, currentUser = _a.currentUser;
91
100
  var theme = (0, material_1.useTheme)();
92
- var _e = (0, react_1.useState)(editMode), localEditMode = _e[0], setLocalEditMode = _e[1];
93
- var _f = (0, react_1.useState)(false), openConfirmDocumentDelete = _f[0], setOpenConfirmDocumentDelete = _f[1];
94
- var _g = (0, react_1.useState)(false), openConfirmVehicleDelete = _g[0], setOpenConfirmVehicleDelete = _g[1];
95
- var _h = (0, react_1.useState)(""), documentToDelete = _h[0], setDocumentToDelete = _h[1];
96
- var _j = (0, react_1.useState)(false), sizeLimit = _j[0], setSizeLimit = _j[1];
97
- // Formulaire utilisé pour les modifications d'informations sur le véhicule
98
- var _k = (0, react_1.useState)(initialUserFormState), form = _k[0], setForm = _k[1];
99
- // Références aux éventuels documents uploadés depuis la fiche
101
+ var sectionTitleSx = {
102
+ fontWeight: "bold",
103
+ textTransform: "uppercase",
104
+ mb: 1,
105
+ color: theme.palette.primary.main
106
+ };
107
+ var _h = (0, react_1.useState)(editMode), localEditMode = _h[0], setLocalEditMode = _h[1];
108
+ var _j = (0, react_1.useState)(false), openConfirmDocumentDelete = _j[0], setOpenConfirmDocumentDelete = _j[1];
109
+ var _k = (0, react_1.useState)(false), openConfirmVehicleDelete = _k[0], setOpenConfirmVehicleDelete = _k[1];
110
+ var _l = (0, react_1.useState)(""), documentToDelete = _l[0], setDocumentToDelete = _l[1];
111
+ var _m = (0, react_1.useState)(false), sizeLimit = _m[0], setSizeLimit = _m[1];
112
+ var _o = (0, react_1.useState)(initialUserFormState), form = _o[0], setForm = _o[1];
100
113
  var invoiceInputRef = (0, react_1.useRef)(null);
101
114
  var tirePictureInputRef = (0, react_1.useRef)(null);
102
- var _l = (0, react_1.useState)(false), isShowLinkedDocument = _l[0], setShowLinkedDocument = _l[1];
115
+ var _p = (0, react_1.useState)(false), isShowLinkedDocument = _p[0], setShowLinkedDocument = _p[1];
103
116
  var docTypeCurrent = (0, react_1.useRef)();
104
117
  var messageRGPD = appType === Enums_1.MovaAppType.INDIVIDUAL ? ((0, jsx_runtime_1.jsx)(material_1.Box, {})) : ((0, jsx_runtime_1.jsx)(material_1.Box, __assign({ sx: { mt: 2 } }, { children: (0, jsx_runtime_1.jsx)(material_1.Alert, __assign({ severity: "warning" }, { children: "Vous \u00EAtes responsable des documents que vous importez, en ajoutant un document vous reconnaissez disposer du consentement explicite du client pour le stockage de ses donn\u00E9es conform\u00E9ment \u00E0 la r\u00E9glementation RGPD." })) })));
105
118
  (0, react_1.useEffect)(function () {
@@ -112,11 +125,7 @@ var VehicleFullCard = function (_a) {
112
125
  if (!vehicle)
113
126
  return;
114
127
  setForm(function (prevForm) {
115
- var updatedForm = __assign(__assign({}, prevForm), { currentMileage: __assign(__assign({}, prevForm.currentMileage), { value: vehicle.currentMileage }), averageMileagePerYear: __assign(__assign({}, prevForm.averageMileagePerYear), { value: vehicle.averageMileagePerYear }), tireWidth: __assign(__assign({}, prevForm.tireWidth), { value: vehicle.tireWidth }), tireHeight: __assign(__assign({}, prevForm.tireHeight), { value: vehicle.tireHeight }), tireDiameter: __assign(__assign({}, prevForm.tireDiameter), { value: vehicle.tireDiameter }), tireSpeedIndex: __assign(__assign({}, prevForm.tireSpeedIndex), { value: vehicle.tireSpeedIndex }), secondaryTireWidth: __assign(__assign({}, prevForm.secondaryTireWidth), { value: vehicle.secondaryTireWidth }), secondaryTireHeight: __assign(__assign({}, prevForm.secondaryTireHeight), { value: vehicle.secondaryTireHeight }), secondaryTireDiameter: __assign(__assign({}, prevForm.secondaryTireDiameter), { value: vehicle.secondaryTireDiameter }), secondaryTireSpeedIndex: __assign(__assign({}, prevForm.secondaryTireSpeedIndex), { value: vehicle.secondaryTireSpeedIndex }), lastInspectionDate: __assign(__assign({}, prevForm.lastInspectionDate), { value: vehicle.lastInspectionDate
116
- ? new Date(vehicle.lastInspectionDate)
117
- : null }), lastMaintenanceDate: __assign(__assign({}, prevForm.lastMaintenanceDate), { value: vehicle.lastMaintenanceDate
118
- ? new Date(vehicle.lastMaintenanceDate)
119
- : null }), tireBrand: __assign(__assign({}, prevForm.tireBrand), { value: vehicle.tireBrand }), tireProfile: __assign(__assign({}, prevForm.tireProfile), { value: vehicle.tireProfile }) });
128
+ var updatedForm = __assign(__assign({}, prevForm), { currentMileage: __assign(__assign({}, prevForm.currentMileage), { value: vehicle.currentMileage }), averageMileagePerYear: __assign(__assign({}, prevForm.averageMileagePerYear), { value: vehicle.averageMileagePerYear }), tireWidth: __assign(__assign({}, prevForm.tireWidth), { value: vehicle.tireWidth }), tireHeight: __assign(__assign({}, prevForm.tireHeight), { value: vehicle.tireHeight }), tireDiameter: __assign(__assign({}, prevForm.tireDiameter), { value: vehicle.tireDiameter }), tireSpeedIndex: __assign(__assign({}, prevForm.tireSpeedIndex), { value: vehicle.tireSpeedIndex }), secondaryTireWidth: __assign(__assign({}, prevForm.secondaryTireWidth), { value: vehicle.secondaryTireWidth }), secondaryTireHeight: __assign(__assign({}, prevForm.secondaryTireHeight), { value: vehicle.secondaryTireHeight }), secondaryTireDiameter: __assign(__assign({}, prevForm.secondaryTireDiameter), { value: vehicle.secondaryTireDiameter }), secondaryTireSpeedIndex: __assign(__assign({}, prevForm.secondaryTireSpeedIndex), { value: vehicle.secondaryTireSpeedIndex }), lastInspectionDate: __assign(__assign({}, prevForm.lastInspectionDate), { value: vehicle.lastInspectionDate ? new Date(vehicle.lastInspectionDate) : null }), lastMaintenanceDate: __assign(__assign({}, prevForm.lastMaintenanceDate), { value: vehicle.lastMaintenanceDate ? new Date(vehicle.lastMaintenanceDate) : null }), tireBrand: __assign(__assign({}, prevForm.tireBrand), { value: vehicle.tireBrand }), tireProfile: __assign(__assign({}, prevForm.tireProfile), { value: vehicle.tireProfile }) });
120
129
  if (vehicle.foreignPlate) {
121
130
  updatedForm.vehicleModel = __assign(__assign({}, prevForm.vehicleModel), { value: vehicle.model });
122
131
  }
@@ -141,19 +150,15 @@ var VehicleFullCard = function (_a) {
141
150
  }
142
151
  };
143
152
  var isVehicleTireSizeDefined = function (vehicle) {
144
- return (vehicle.tireSize && vehicle.tireSize.diameter && vehicle.tireSize.height);
153
+ return vehicle.tireSize && vehicle.tireSize.diameter && vehicle.tireSize.height;
145
154
  };
146
155
  var isVehicleSecondaryTireSizeDefined = function (vehicle) {
147
- return (vehicle.secondaryTireSize &&
156
+ return vehicle.secondaryTireSize &&
148
157
  vehicle.secondaryTireSize.diameter &&
149
- vehicle.secondaryTireSize.height);
158
+ vehicle.secondaryTireSize.height;
150
159
  };
151
160
  var validateForm = function () {
152
161
  var newForm = __assign({}, form);
153
- // Validator pour les champs obligatoires
154
- // newForm.currentMileage = validateField(form.currentMileage, value => !!value, 'Champ obligatoire');
155
- // newForm.averageMileagePerYear = validateField(form.averageMileagePerYear, value => !!value, 'Champ obligatoire');
156
- // La validation de la saisie des pneumatiques se fait dans le composant "MovaVehicleTireField", traitée dans le callback "handleOnChangeVehicleTire"
157
162
  setForm(newForm);
158
163
  return (newForm.currentMileage.isValid &&
159
164
  newForm.averageMileagePerYear.isValid &&
@@ -167,9 +172,7 @@ var VehicleFullCard = function (_a) {
167
172
  };
168
173
  var handleChange = function (fieldName, fieldValue) {
169
174
  var _a;
170
- var newField = (_a = {},
171
- _a[fieldName] = { value: fieldValue, isValid: true },
172
- _a);
175
+ var newField = (_a = {}, _a[fieldName] = { value: fieldValue, isValid: true }, _a);
173
176
  setForm(__assign(__assign({}, form), newField));
174
177
  };
175
178
  var uploadVehicleDocument = function (document, documentType) {
@@ -178,34 +181,21 @@ var VehicleFullCard = function (_a) {
178
181
  return;
179
182
  }
180
183
  if (vehicle && document && documentType) {
181
- // Utilisation d'un formData pour permettre le trasnfert de fichier vers l'API
182
184
  var formData = new FormData();
183
185
  formData.append("documentType", documentType);
184
- // Ajouter la facture à FormData
185
186
  formData.append("file", document);
186
- // Appel du callback correspondant
187
187
  if (onUploadDocument)
188
188
  onUploadDocument(formData);
189
189
  }
190
190
  };
191
- /**
192
- *
193
- * @param event L'upload des documents se fait directement lors du téléchargement
194
- * @param docType
195
- */
196
191
  var handleFileChange = function (event, docType) {
192
+ var _a, _b;
197
193
  event.preventDefault();
198
- if (event &&
199
- event.target.files &&
200
- event.target.files.length > 0 &&
201
- docType) {
202
- uploadVehicleDocument(event.target.files[0], docType);
194
+ if (((_b = (_a = event === null || event === void 0 ? void 0 : event.target.files) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) > 0 && docType) {
195
+ uploadVehicleDocument((event.target.files)[0], docType);
203
196
  }
204
197
  };
205
- var handleOnClickEdit = function () {
206
- // On passe la fiche véhicule en mode édition
207
- setLocalEditMode(true);
208
- };
198
+ var handleOnClickEdit = function () { return setLocalEditMode(true); };
209
199
  var handleOnChangeVehicleTire = function (vehicleTire, isValid) {
210
200
  setForm(function (prevForm) { return (__assign(__assign({}, prevForm), { tireSize: __assign(__assign({}, prevForm["tireSize"]), { value: vehicleTire, isValid: isValid }) })); });
211
201
  };
@@ -224,40 +214,6 @@ var VehicleFullCard = function (_a) {
224
214
  var handleOnClickValidate = function () {
225
215
  if (validateForm()) {
226
216
  Logger_1.default.info(form.tireSize.value);
227
- var query = {
228
- currentMileage: form.currentMileage.value,
229
- averageMileagePerYear: form.averageMileagePerYear.value,
230
- tireWidth: form.tireSize.isValid && form.tireSize.value
231
- ? form.tireSize.value.width
232
- : undefined,
233
- tireHeight: form.tireSize.isValid && form.tireSize.value
234
- ? form.tireSize.value.height
235
- : undefined,
236
- tireDiameter: form.tireSize.isValid && form.tireSize.value
237
- ? form.tireSize.value.diameter
238
- : undefined,
239
- tireSpeedIndex: form.tireSize.isValid && form.tireSize.value
240
- ? form.tireSize.value.speedIndex
241
- : undefined,
242
- secondaryTireWidth: form.secondaryTireSize && form.secondaryTireSize.value
243
- ? form.secondaryTireSize.value.width
244
- : undefined,
245
- secondaryTireHeight: form.secondaryTireSize && form.secondaryTireSize.value
246
- ? form.secondaryTireSize.value.height
247
- : undefined,
248
- secondaryTireDiameter: form.secondaryTireSize && form.secondaryTireSize.value
249
- ? form.secondaryTireSize.value.diameter
250
- : undefined,
251
- secondaryTireSpeedIndex: form.secondaryTireSize && form.secondaryTireSize.value
252
- ? form.secondaryTireSize.value.speedIndex
253
- : undefined,
254
- lastInspectionDate: form.lastInspectionDate.value,
255
- lastMaintenanceDate: form.lastMaintenanceDate.value,
256
- tireBrand: form.tireBrand.value,
257
- tireProfile: form.tireProfile.value,
258
- };
259
- Logger_1.default.info(query);
260
- // Appel du callback correspondant
261
217
  if (onUpdate)
262
218
  onUpdate(form);
263
219
  }
@@ -270,112 +226,123 @@ var VehicleFullCard = function (_a) {
270
226
  setOpenConfirmDocumentDelete(false);
271
227
  setDocumentToDelete("");
272
228
  };
273
- var handleCloseConfirmVehicleDelete = function () {
274
- setOpenConfirmVehicleDelete(false);
275
- };
276
- /**
277
- *
278
- */
229
+ var handleCloseConfirmVehicleDelete = function () { return setOpenConfirmVehicleDelete(false); };
279
230
  var handleConfirmDocumentDelete = function () {
280
231
  setOpenConfirmDocumentDelete(false);
281
- if (vehicle && documentToDelete) {
282
- // Appel du callback correspondant
283
- if (onDeleteDocument)
284
- onDeleteDocument(documentToDelete);
285
- }
232
+ if (vehicle && documentToDelete && onDeleteDocument)
233
+ onDeleteDocument(documentToDelete);
286
234
  };
287
235
  var handleConfirmVehicleDelete = function () {
288
236
  setOpenConfirmVehicleDelete(false);
289
- if (vehicle && onDelete) {
290
- // Appel du callback correspondant
237
+ if (vehicle && onDelete)
291
238
  onDelete();
292
- }
239
+ };
240
+ var formatDate = function (date) {
241
+ var formatted = (0, DateUtils_1.formatDateByTimezone)(date, "Europe/Paris", Enums_1.DateFormatTypes.SHORT_FORMAT_DATE);
242
+ return formatted !== "" ? formatted : "-";
293
243
  };
294
244
  return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [vehicle && ((0, jsx_runtime_1.jsxs)(material_1.Card, __assign({ variant: "outlined", sx: {
295
- maxWidth: fullwidth ? "80%" : 500,
245
+ width: "100%",
296
246
  backgroundColor: focused ? theme.palette.primary.light : "white",
297
247
  overflow: "visible",
298
248
  mt: 4,
299
- pb: 1,
300
- } }, { children: [(0, jsx_runtime_1.jsxs)(material_1.CardContent, __assign({ sx: { pt: 0, pb: 0 } }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Typography, __assign({ variant: "h6", component: "div", align: "center", sx: { mb: 1 }, color: (0, material_1.darken)(theme.palette.primary.main, 0.2) }, { children: [vehicle.brand && "".concat(vehicle.brand, " "), vehicle.model && "".concat(vehicle.model, " "), vehicle.version && "".concat(vehicle.version)] })), (0, jsx_runtime_1.jsxs)(material_1.Grid, __assign({ container: true, justifyContent: "space-between" }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Grid, __assign({ container: true, sx: { mb: 1, alignItems: "center", justifyContent: "center" } }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Grid, __assign({ item: true, xs: 6, sx: { position: "relative", minWidth: "234px" } }, { children: [(0, jsx_runtime_1.jsx)("img", { src: car_plate_bg_png_1.default, alt: "Plaque d'immatriculation", style: { height: "50px", position: "relative" } }), (0, jsx_runtime_1.jsxs)(material_1.Typography, __assign({ variant: "h6", color: theme.palette.text.primary, sx: {
301
- position: "absolute",
302
- top: "8px",
303
- left: "76px",
304
- display: "flex",
305
- } }, { children: [(0, jsx_runtime_1.jsx)("b", { children: (0, Tools_1.formatVehiclePlate)(vehicle.plate, vehicle.foreignPlate) }), (0, jsx_runtime_1.jsx)(material_1.IconButton, __assign({ sx: { ml: 1 }, onClick: function () { return __awaiter(void 0, void 0, void 0, function () {
306
- return __generator(this, function (_a) {
307
- switch (_a.label) {
308
- case 0: return [4 /*yield*/, navigator.clipboard.writeText((0, Tools_1.formatVehiclePlate)(vehicle.plate, vehicle.foreignPlate))];
309
- case 1: return [2 /*return*/, _a.sent()];
310
- }
311
- });
312
- }); }, size: "small", "aria-label": "Copier le VIN" }, { children: (0, jsx_runtime_1.jsx)(icons_material_1.ContentCopy, { fontSize: "small" }) }))] }))] })), onDelete && ((0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 6, style: {
313
- display: "flex",
249
+ borderRadius: 2,
250
+ border: "0.5px solid",
251
+ borderColor: "divider",
252
+ } }, { children: [(0, jsx_runtime_1.jsxs)(material_1.CardContent, __assign({ sx: { pt: 0, pb: 0 } }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Box, __assign({ sx: {
253
+ display: "flex",
254
+ justifyContent: "space-between",
255
+ alignItems: "flex-start",
256
+ px: 2,
257
+ pt: 2,
258
+ pb: 2,
259
+ borderBottom: "0.5px solid",
260
+ borderColor: "divider",
261
+ } }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { children: [(0, jsx_runtime_1.jsxs)(material_1.Typography, __assign({ variant: "h6", sx: { fontWeight: 500, lineHeight: 1.2, color: "text.primary" } }, { children: [vehicle.brand && "".concat(vehicle.brand, " "), vehicle.model && "".concat(vehicle.model, " ")] })), vehicle.version && ((0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "body2", color: "text.secondary", sx: { mt: 0.25 } }, { children: vehicle.version }))), (0, jsx_runtime_1.jsxs)(material_1.Box, __assign({ sx: {
262
+ display: "inline-flex",
314
263
  alignItems: "center",
315
- justifyContent: "center",
316
- } }, { children: (0, jsx_runtime_1.jsx)(material_1.Button, __assign({ variant: "contained", color: "error", onClick: function (e) { return handleOnClickDeleteVehicle(e); } }, { children: "Supprimer" })) })))] })), !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 actuel :" })) })), (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.currentMileage, " km"] }) })) }))] }))), !localEditMode && vehicle.vin && ((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: "Vin :" })) })), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 6, sx: { textAlign: "right" } }, { children: (0, jsx_runtime_1.jsxs)(material_1.Typography, __assign({ variant: "body1", color: "text.secondary", sx: {
317
- display: "flex",
318
- flexDirection: "row",
319
- alignItems: "center",
320
- justifyContent: "flex-end",
321
- } }, { children: [(0, jsx_runtime_1.jsx)("b", { children: vehicle.vin }), (0, jsx_runtime_1.jsx)(material_1.IconButton, __assign({ sx: { ml: 1, height: "24px" }, onClick: function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
264
+ gap: 0.75,
265
+ mt: 1.25,
266
+ px: 1.25,
267
+ py: 0.5,
268
+ bgcolor: "#F5F4F0",
269
+ border: "0.5px solid #D3D1C7",
270
+ borderRadius: "6px",
271
+ } }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "body1", sx: {
272
+ fontWeight: 600,
273
+ letterSpacing: "0.1em",
274
+ color: "text.primary",
275
+ fontSize: "14px",
276
+ } }, { children: (0, Tools_1.formatVehiclePlate)(vehicle.plate, vehicle.foreignPlate) })), (0, jsx_runtime_1.jsx)(material_1.IconButton, __assign({ size: "small", sx: { p: 0.25 }, onClick: function () { return __awaiter(void 0, void 0, void 0, function () {
277
+ return __generator(this, function (_a) {
322
278
  switch (_a.label) {
323
- case 0: return [4 /*yield*/, navigator.clipboard.writeText(vehicle.vin)];
279
+ case 0: return [4 /*yield*/, navigator.clipboard.writeText((0, Tools_1.formatVehiclePlate)(vehicle.plate, vehicle.foreignPlate))];
324
280
  case 1: return [2 /*return*/, _a.sent()];
325
281
  }
326
- }); }); }, size: "small", "aria-label": "Copier le VIN" }, { children: (0, jsx_runtime_1.jsx)(icons_material_1.ContentCopy, { fontSize: "small" }) }))] })) }))] }))), localEditMode && form.vehicleModel && vehicle.foreignPlate && ((0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 12 }, { children: (0, jsx_runtime_1.jsx)(material_1.TextField, { label: "Mod\u00E8le de la voiture ", name: "vehicleModel", variant: "outlined", type: "text", required: true, value: form.vehicleModel.value, onChange: function (e) { return handleInputChange(e); }, error: Boolean(form.vehicleModel.error), sx: {
327
- width: "100%",
328
- mt: 2,
329
- "& input": { textTransform: "uppercase" }, // CSS pour forcer les majuscules dans l'input
330
- } }) }))), localEditMode && ((0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 12 }, { children: (0, jsx_runtime_1.jsx)(material_1.TextField, { label: "Kilom\u00E9trage actuel", name: "currentMileage", variant: "outlined", type: "number", required: true, value: form.currentMileage.value, onChange: function (e) { return handleInputChange(e); }, error: Boolean(form.currentMileage.error), sx: {
331
- width: "100%",
332
- mt: 2,
333
- "& input": { textTransform: "uppercase" }, // CSS pour forcer les majuscules dans l'input
334
- }, helperText: Boolean(form.currentMileage.error &&
335
- form.currentMileage.value > 0)
336
- ? form.currentMileage.error
337
- : "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
338
- ? String(form.averageMileagePerYear.value)
339
- : "", 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)(jsx_runtime_1.Fragment, { children: [(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.jsxs)(material_1.Typography, __assign({ variant: "body1", color: "text.secondary" }, { children: ["Pneumatiques", " ", isVehicleSecondaryTireSizeDefined(vehicle) ? "AV" : "", " ", ":"] })) })), (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) })) : ("-") })) }))] })), isVehicleSecondaryTireSizeDefined(vehicle) && ((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 AR:" })) })), (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: isVehicleSecondaryTireSizeDefined(vehicle) ? ((0, jsx_runtime_1.jsx)("b", { children: (0, Tools_1.formatVehicleTire)(vehicle.secondaryTireSize) })) : ("-") })) }))] })))] })), !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: "Marque 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: vehicle.tireBrand ? (0, jsx_runtime_1.jsx)("b", { children: vehicle.tireBrand }) : "-" })) }))] }))), !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: "Mod\u00E8le 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: vehicle.tireProfile ? (0, jsx_runtime_1.jsx)("b", { children: vehicle.tireProfile }) : "-" })) }))] }))), localEditMode && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(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, { label: "AV", vehicleTire: form.tireSize.value, onChangeVehicleTire: handleOnChangeVehicleTire }) })), (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, { label: "AR", vehicleTire: form.secondaryTireSize.value, onChangeVehicleTire: handleOnChangeVehicleSecondaryTire }) }))] })), localEditMode && ((0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 12 }, { children: (0, jsx_runtime_1.jsx)(material_1.TextField, { label: "Mod\u00E8le pneumatique", name: "tireProfile", variant: "outlined", value: form.tireProfile.value, onChange: function (e) { return handleInputChange(e); }, error: Boolean(form.tireProfile.error), sx: {
340
- width: "100%",
341
- mt: 2,
342
- "& input": { textTransform: "uppercase" }, // CSS pour forcer les majuscules dans l'input
343
- } }) }))), localEditMode && ((0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 12 }, { children: (0, jsx_runtime_1.jsx)(material_1.TextField, { label: "Marque pneumatique", name: "tireBrand", variant: "outlined", value: form.tireBrand.value, onChange: function (e) { return handleInputChange(e); }, error: Boolean(form.tireBrand.error), sx: {
344
- width: "100%",
345
- mt: 2,
346
- "& input": { textTransform: "uppercase" }, // CSS pour forcer les majuscules dans l'input
347
- } }) }))), !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: "Dernier contr\u00F4le technique :" })) })), (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.jsx)("b", { children: (0, DateUtils_1.formatDateByTimezone)(vehicle.lastInspectionDate, "Europe/Paris", Enums_1.DateFormatTypes.SHORT_FORMAT_DATE) !== ""
348
- ? (0, DateUtils_1.formatDateByTimezone)(vehicle.lastInspectionDate, "Europe/Paris", Enums_1.DateFormatTypes.SHORT_FORMAT_DATE)
349
- : "-" }) })) }))] }))), localEditMode && ((0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 12 }, { children: (0, jsx_runtime_1.jsx)(material_1.FormControl, __assign({ fullWidth: true, sx: { marginTop: 2 } }, { children: (0, jsx_runtime_1.jsx)(x_date_pickers_1.DatePicker, { label: "Dernier contrôle technique", name: "lastInspectionDate", value: (form.lastInspectionDate.value
350
- ? (0, moment_1.default)(form.lastInspectionDate.value)
351
- : null), onChange: function (e) {
352
- return handleChange("lastInspectionDate", e ? (0, moment_1.default)(e).toISOString() : "");
353
- }, format: "DD/MM/YYYY", formatDensity: "dense", views: ["day"], displayWeekNumber: true }) })) }))), !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: "Dernier entretien :" })) })), (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.jsx)("b", { children: (0, DateUtils_1.formatDateByTimezone)(vehicle.lastMaintenanceDate, "Europe/Paris", Enums_1.DateFormatTypes.SHORT_FORMAT_DATE) !== ""
354
- ? (0, DateUtils_1.formatDateByTimezone)(vehicle.lastMaintenanceDate, "Europe/Paris", Enums_1.DateFormatTypes.SHORT_FORMAT_DATE)
355
- : "-" }) })) }))] }))), localEditMode && ((0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 12 }, { children: (0, jsx_runtime_1.jsx)(material_1.FormControl, __assign({ fullWidth: true, sx: { marginTop: 2 } }, { children: (0, jsx_runtime_1.jsx)(x_date_pickers_1.DatePicker, { label: "Dernier entretien", name: "lastMaintenanceDate", value: (form.lastMaintenanceDate.value
356
- ? (0, moment_1.default)(form.lastMaintenanceDate.value)
357
- : null), format: "DD/MM/YYYY", formatDensity: "dense", views: ["day"], displayWeekNumber: true, onChange: function (e) {
358
- var _a;
359
- return handleChange("lastMaintenanceDate", (_a = e === null || e === void 0 ? void 0 : e.toDate()) !== null && _a !== void 0 ? _a : null);
360
- } }) })) })))] })), !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 &&
361
- ((_b = vehicle.documents) === null || _b === void 0 ? void 0 : _b.filter(function (doc) { return doc.fileSignedUrl; }).map(function (invoice, index) { return ((0, jsx_runtime_1.jsxs)(material_1.Grid, __assign({ container: true, sx: {
362
- justifyContent: "space-between",
363
- alignItems: "center",
364
- } }, { 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 })) })) })) }), (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) {
365
- return handleDeleteDocument(e, invoice === null || invoice === void 0 ? void 0 : invoice.id);
366
- } }, { children: (0, jsx_runtime_1.jsx)(CloseRounded_1.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) {
367
- return handleFileChange(e, docTypeCurrent.current);
368
- } }), (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: {
369
- alignItems: "center",
370
- width: "90%",
371
- mt: 2,
372
- mb: 1,
373
- height: "50px",
374
- p: 1,
375
- color: (0, material_1.darken)(theme.palette.primary.main, 0.2),
376
- } }, { 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 && ((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 && ((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: {
377
- width: "45%",
378
- color: (0, material_1.darken)(theme.palette.primary.main, 0.2),
379
- }, 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 })), (0, jsx_runtime_1.jsx)(ConfirmationDialog_1.default, { open: openConfirmDocumentDelete, onClose: handleCloseConfirmDocumentDelete, onConfirm: handleConfirmDocumentDelete, message: "\u00CAtes-vous s\u00FBr de vouloir supprimer ce document ?" }), (0, jsx_runtime_1.jsx)(ConfirmationDialog_1.default, { open: openConfirmVehicleDelete, onClose: handleCloseConfirmVehicleDelete, onConfirm: handleConfirmVehicleDelete, message: "\u00CAtes-vous s\u00FBr de vouloir supprimer ce v\u00E9hicule ?" })] }));
282
+ });
283
+ }); }, "aria-label": "Copier la plaque" }, { children: (0, jsx_runtime_1.jsx)(icons_material_1.ContentCopy, { sx: { fontSize: 14, color: "text.disabled" } }) }))] }))] }), (0, jsx_runtime_1.jsxs)(material_1.Box, __assign({ sx: { display: "flex", flexDirection: "row", alignItems: "flex-end", gap: 1 } }, { children: [onDelete && ((0, jsx_runtime_1.jsx)(material_1.Button, __assign({ variant: "outlined", color: "error", size: "small", onClick: function (e) { return handleOnClickDeleteVehicle(e); } }, { children: "Supprimer" }))), !localEditMode && ((0, jsx_runtime_1.jsx)(material_1.Button, __assign({ onClick: handleOnClickEdit, size: "small", variant: "outlined", startIcon: (0, jsx_runtime_1.jsx)(EditRounded_1.default, { sx: { fontSize: "14px !important" } }), sx: {
284
+ fontSize: 12,
285
+ borderColor: "divider",
286
+ } }, { children: "Modifier" })))] }))] })), (0, jsx_runtime_1.jsxs)(material_1.Box, __assign({ sx: { px: 2, py: 1.5, borderBottom: "0.5px solid", borderColor: "divider" } }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "body2", sx: sectionTitleSx }, { children: "Kilom\u00E9trage" })), (0, jsx_runtime_1.jsxs)(material_1.Box, __assign({ sx: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 1 } }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Box, __assign({ sx: { bgcolor: "grey.50", borderRadius: 1, p: 1.25 } }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "caption", color: "text.secondary", display: "block" }, { children: "Actuel" })), !localEditMode ? ((0, jsx_runtime_1.jsxs)(material_1.Typography, __assign({ variant: "body1", fontWeight: 500 }, { children: [(_b = vehicle.currentMileage) !== null && _b !== void 0 ? _b : "-", " ", (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ component: "span", variant: "caption", color: "text.secondary" }, { children: "km" }))] }))) : ((0, jsx_runtime_1.jsx)(material_1.TextField, { name: "currentMileage", variant: "standard", type: "number", required: true, value: (_c = form.currentMileage.value) !== null && _c !== void 0 ? _c : "", onChange: handleInputChange, error: Boolean(form.currentMileage.error), helperText: Boolean(form.currentMileage.error && form.currentMileage.value > 0)
287
+ ? form.currentMileage.error
288
+ : "Sur votre tableau de bord 😉", InputProps: { disableUnderline: false }, sx: { mt: 0.5, width: "100%" } }))] })), (0, jsx_runtime_1.jsxs)(material_1.Box, __assign({ sx: { bgcolor: "grey.50", borderRadius: 1, p: 1.25 } }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "caption", color: "text.secondary", display: "block" }, { children: "Moyen annuel" })), !localEditMode ? ((0, jsx_runtime_1.jsxs)(material_1.Typography, __assign({ variant: "body1", fontWeight: 500 }, { children: [(_d = vehicle.averageMileagePerYear) !== null && _d !== void 0 ? _d : "-", " ", (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ component: "span", variant: "caption", color: "text.secondary" }, { children: "km" }))] }))) : ((0, jsx_runtime_1.jsxs)(material_1.FormControl, __assign({ fullWidth: true, variant: "standard", error: Boolean(form.averageMileagePerYear.error) }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Select, __assign({ name: "averageMileagePerYear", value: form.averageMileagePerYear.value ? String(form.averageMileagePerYear.value) : "", onChange: handleSelectChange, disableUnderline: false, sx: { mt: 0.5, fontSize: 14 } }, { children: [[5000, 10000, 15000, 20000, 25000, 30000, 50000, 75000, 100000].map(function (v) { return ((0, jsx_runtime_1.jsx)(material_1.MenuItem, __assign({ value: v }, { children: v.toLocaleString("fr-FR") }), v)); }), (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 })] })))] }))] }))] })), (0, jsx_runtime_1.jsxs)(material_1.Box, __assign({ sx: { px: 2, py: 1.5, borderBottom: "0.5px solid", borderColor: "divider" } }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "body2", sx: sectionTitleSx }, { children: "Identit\u00E9 technique" })), localEditMode && form.vehicleModel && vehicle.foreignPlate && ((0, jsx_runtime_1.jsx)(material_1.TextField, { label: "Mod\u00E8le de la voiture", name: "vehicleModel", variant: "outlined", type: "text", required: true, fullWidth: true, value: form.vehicleModel.value, onChange: handleInputChange, error: Boolean(form.vehicleModel.error), sx: { mb: 1.5, "& input": { textTransform: "uppercase" } } })), vehicle.firstRegistrationDate && ((0, jsx_runtime_1.jsxs)(material_1.Box, __assign({ sx: rowSx }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "body2", color: "text.secondary" }, { children: "Mise en circulation" })), (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "body2", fontWeight: 500 }, { children: formatDate(vehicle.firstRegistrationDate) }))] }))), vehicle.vin && ((0, jsx_runtime_1.jsxs)(material_1.Box, __assign({ sx: rowSx }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "body2", color: "text.secondary" }, { children: "VIN" })), (0, jsx_runtime_1.jsxs)(material_1.Box, __assign({ sx: { display: "flex", alignItems: "center", gap: 0.5 } }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "body2", fontWeight: 500, sx: { fontSize: 12 } }, { children: vehicle.vin })), (0, jsx_runtime_1.jsx)(material_1.IconButton, __assign({ size: "small", sx: { p: 0.25 }, onClick: function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
289
+ switch (_a.label) {
290
+ case 0: return [4 /*yield*/, navigator.clipboard.writeText(vehicle.vin)];
291
+ case 1: return [2 /*return*/, _a.sent()];
292
+ }
293
+ }); }); }, "aria-label": "Copier le VIN" }, { children: (0, jsx_runtime_1.jsx)(icons_material_1.ContentCopy, { sx: { fontSize: 13, color: "text.disabled" } }) }))] }))] }))), vehicle.energy && ((0, jsx_runtime_1.jsxs)(material_1.Box, __assign({ sx: rowSx }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "body2", color: "text.secondary" }, { children: "\u00C9nergie" })), (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "body2", fontWeight: 500 }, { children: vehicle.energy }))] }))), vehicle.gearboxType && ((0, jsx_runtime_1.jsxs)(material_1.Box, __assign({ sx: rowSx }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "body2", color: "text.secondary" }, { children: "Type bo\u00EEte" })), (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "body2", fontWeight: 500 }, { children: vehicle.gearboxType }))] }))), vehicle.gearboxCode && ((0, jsx_runtime_1.jsxs)(material_1.Box, __assign({ sx: rowSx }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "body2", color: "text.secondary" }, { children: "Code bo\u00EEte" })), (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "body2", fontWeight: 500 }, { children: vehicle.gearboxCode }))] }))), vehicle.engineCode && ((0, jsx_runtime_1.jsxs)(material_1.Box, __assign({ sx: rowSx }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "body2", color: "text.secondary" }, { children: "Code moteur" })), (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "body2", fontWeight: 500, sx: { fontSize: 12 } }, { children: vehicle.engineCode }))] })))] })), (0, jsx_runtime_1.jsxs)(material_1.Box, __assign({ sx: { px: 2, py: 1.5, borderBottom: "0.5px solid", borderColor: "divider" } }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "body2", sx: sectionTitleSx }, { children: "Pneumatiques" })), !localEditMode ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(material_1.Box, __assign({ sx: rowSx }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "body2", color: "text.secondary" }, { children: isVehicleSecondaryTireSizeDefined(vehicle) ? "Avant" : "Taille" })), isVehicleTireSizeDefined(vehicle) ? ((0, jsx_runtime_1.jsx)(material_1.Chip, { label: (0, Tools_1.formatVehicleTire)(vehicle.tireSize), size: "small", sx: {
294
+ bgcolor: "#E6F1FB",
295
+ color: "#0C447C",
296
+ fontWeight: 500,
297
+ fontSize: 12,
298
+ height: 24,
299
+ "& .MuiChip-label": { px: 1 },
300
+ } })) : ((0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "body2", color: "text.disabled" }, { children: "\u2014" })))] })), isVehicleSecondaryTireSizeDefined(vehicle) && ((0, jsx_runtime_1.jsxs)(material_1.Box, __assign({ sx: rowSx }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "body2", color: "text.secondary" }, { children: "Arri\u00E8re" })), (0, jsx_runtime_1.jsx)(material_1.Chip, { label: (0, Tools_1.formatVehicleTire)(vehicle.secondaryTireSize), size: "small", sx: {
301
+ bgcolor: "#E6F1FB",
302
+ color: "#0C447C",
303
+ fontWeight: 500,
304
+ fontSize: 12,
305
+ height: 24,
306
+ "& .MuiChip-label": { px: 1 },
307
+ } })] }))), (0, jsx_runtime_1.jsxs)(material_1.Box, __assign({ sx: rowSx }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "body2", color: "text.secondary" }, { children: "Marque" })), (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "body2", fontWeight: 500 }, { children: vehicle.tireBrand || "—" }))] })), (0, jsx_runtime_1.jsxs)(material_1.Box, __assign({ sx: rowSx }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "body2", color: "text.secondary" }, { children: "Mod\u00E8le" })), (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "body2", fontWeight: 500 }, { children: vehicle.tireProfile || "—" }))] }))] })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Box, __assign({ sx: { mt: 1 } }, { children: (0, jsx_runtime_1.jsx)(MovaVehicleTireField_1.default, { label: "AV", vehicleTire: form.tireSize.value, onChangeVehicleTire: handleOnChangeVehicleTire }) })), (0, jsx_runtime_1.jsx)(material_1.Box, __assign({ sx: { mt: 1 } }, { children: (0, jsx_runtime_1.jsx)(MovaVehicleTireField_1.default, { label: "AR", vehicleTire: form.secondaryTireSize.value, onChangeVehicleTire: handleOnChangeVehicleSecondaryTire }) })), (0, jsx_runtime_1.jsx)(material_1.TextField, { label: "Marque pneumatique", name: "tireBrand", variant: "outlined", fullWidth: true, value: form.tireBrand.value, onChange: handleInputChange, error: Boolean(form.tireBrand.error), sx: { mt: 2, "& input": { textTransform: "uppercase" } } }), (0, jsx_runtime_1.jsx)(material_1.TextField, { label: "Mod\u00E8le pneumatique", name: "tireProfile", variant: "outlined", fullWidth: true, value: form.tireProfile.value, onChange: handleInputChange, error: Boolean(form.tireProfile.error), sx: { mt: 1, "& input": { textTransform: "uppercase" } } })] }))] })), (0, jsx_runtime_1.jsxs)(material_1.Box, __assign({ sx: { px: 2, py: 1.5, borderBottom: "0.5px solid", borderColor: "divider" } }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "body2", sx: sectionTitleSx }, { children: "Entretien" })), !localEditMode ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(material_1.Box, __assign({ sx: rowSx }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Box, __assign({ sx: { display: "flex", alignItems: "center", gap: 0.75 } }, { children: [(0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
308
+ width: 6,
309
+ height: 6,
310
+ borderRadius: "50%",
311
+ bgcolor: vehicle.lastInspectionDate ? "success.main" : "warning.main",
312
+ flexShrink: 0,
313
+ } }), (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "body2", color: "text.secondary" }, { children: "Contr\u00F4le technique" }))] })), (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "body2", fontWeight: 500 }, { children: formatDate(vehicle.lastInspectionDate) }))] })), (0, jsx_runtime_1.jsxs)(material_1.Box, __assign({ sx: rowSx }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Box, __assign({ sx: { display: "flex", alignItems: "center", gap: 0.75 } }, { children: [(0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
314
+ width: 6,
315
+ height: 6,
316
+ borderRadius: "50%",
317
+ bgcolor: vehicle.lastMaintenanceDate ? "success.main" : "warning.main",
318
+ flexShrink: 0,
319
+ } }), (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "body2", color: "text.secondary" }, { children: "Dernier entretien" }))] })), (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "body2", fontWeight: 500 }, { children: formatDate(vehicle.lastMaintenanceDate) }))] }))] })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.FormControl, __assign({ fullWidth: true, sx: { mt: 1.5 } }, { children: (0, jsx_runtime_1.jsx)(x_date_pickers_1.DatePicker, { label: "Dernier contrôle technique", name: "lastInspectionDate", value: (form.lastInspectionDate.value
320
+ ? (0, moment_1.default)(form.lastInspectionDate.value)
321
+ : null), onChange: function (e) {
322
+ return handleChange("lastInspectionDate", e ? (0, moment_1.default)(e).toISOString() : "");
323
+ }, format: "DD/MM/YYYY", formatDensity: "dense", views: ["day"], displayWeekNumber: true }) })), (0, jsx_runtime_1.jsx)(material_1.FormControl, __assign({ fullWidth: true, sx: { mt: 2 } }, { children: (0, jsx_runtime_1.jsx)(x_date_pickers_1.DatePicker, { label: "Dernier entretien", name: "lastMaintenanceDate", value: (form.lastMaintenanceDate.value
324
+ ? (0, moment_1.default)(form.lastMaintenanceDate.value)
325
+ : null), format: "DD/MM/YYYY", formatDensity: "dense", views: ["day"], displayWeekNumber: true, onChange: function (e) {
326
+ var _a;
327
+ return handleChange("lastMaintenanceDate", (_a = e === null || e === void 0 ? void 0 : e.toDate()) !== null && _a !== void 0 ? _a : null);
328
+ } }) }))] }))] })), !localEditMode && ((0, jsx_runtime_1.jsxs)(material_1.Box, __assign({ sx: { px: 2, py: 1.5 } }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "body2", sx: sectionTitleSx }, { children: "Carnet du v\u00E9hicule" })), (_e = vehicle.documents) === null || _e === void 0 ? void 0 : _e.filter(function (doc) { return doc.fileSignedUrl; }).map(function (invoice, index) { return ((0, jsx_runtime_1.jsxs)(material_1.Box, __assign({ sx: {
329
+ display: "flex",
330
+ alignItems: "center",
331
+ justifyContent: "space-between",
332
+ bgcolor: "grey.50",
333
+ borderRadius: 1,
334
+ px: 1.5,
335
+ py: 0.75,
336
+ mb: 0.75,
337
+ } }, { children: [(0, jsx_runtime_1.jsx)(material_1.Tooltip, __assign({ title: invoice.originalFileName }, { children: (0, jsx_runtime_1.jsx)(material_1.Link, __assign({ href: invoice.fileSignedUrl, target: "_blank", rel: "noopener", underline: "hover", sx: { fontSize: 13, color: "#185FA5", flex: 1, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" } }, { children: invoice.fileName })) })), (0, jsx_runtime_1.jsx)(material_1.IconButton, __assign({ size: "small", disabled: !(invoice.ownerId.toString() === currentUser.id), onClick: function (e) { return handleDeleteDocument(e, invoice === null || invoice === void 0 ? void 0 : invoice.id); }, sx: { ml: 1, flexShrink: 0 } }, { children: (0, jsx_runtime_1.jsx)(CloseRounded_1.default, { sx: { fontSize: 16 } }) }))] }), index + 1)); }), (0, jsx_runtime_1.jsxs)(material_1.Box, __assign({ sx: { mt: 1.5 } }, { 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({ fullWidth: true, size: "medium", disabled: currentUpload, onClick: function () { return setShowLinkedDocument(true); }, component: "span", variant: "outlined", startIcon: (0, jsx_runtime_1.jsx)(icons_material_1.AttachFile, {}), sx: {
338
+ border: "1.5px dashed",
339
+ borderColor: "divider",
340
+ color: "text.secondary",
341
+ "&:hover": { borderColor: "text.secondary", bgcolor: "grey.50" },
342
+ } }, { children: "Ajouter un document" })), currentUpload && ((0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "caption", color: "text.secondary", display: "block", textAlign: "center", sx: { mt: 0.75 } }, { children: "Document en cours d'importation..." }))), sizeLimit ? ((0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "caption", color: "warning.dark", display: "block", textAlign: "center", sx: { mt: 0.5 } }, { children: "\u00C9chec : fichier sup\u00E9rieur \u00E0 10 Mo" }))) : ((0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "caption", color: "text.disabled", display: "block", textAlign: "center", sx: { mt: 0.5 } }, { children: "Taille maximale : 10 Mo" })))] }))] })))] })), localEditMode && ((0, jsx_runtime_1.jsxs)(material_1.CardActions, __assign({ sx: { justifyContent: "center", px: 2, pb: 2, gap: 1 } }, { children: [(0, jsx_runtime_1.jsx)(material_1.Button, __assign({ onClick: handleOnClickCancel, variant: "outlined", startIcon: (0, jsx_runtime_1.jsx)(CloseRounded_1.default, {}), sx: { width: "45%", color: "text.secondary", borderColor: "divider" } }, { children: "Annuler" })), (0, jsx_runtime_1.jsx)(material_1.Button, __assign({ onClick: handleOnClickValidate, variant: "contained", startIcon: (0, jsx_runtime_1.jsx)(EditRounded_1.default, {}), sx: {
343
+ width: "45%",
344
+ bgcolor: (0, material_1.darken)(theme.palette.primary.main, 0.1),
345
+ "&:hover": { bgcolor: (0, material_1.darken)(theme.palette.primary.main, 0.25) },
346
+ } }, { children: "Valider" }))] })))] }))), isShowLinkedDocument && ((0, jsx_runtime_1.jsx)(LinkedDocumentDialog_1.LinkedDocumentDialog, { isVehicle: true, isShowLinkedDocument: isShowLinkedDocument, appType: appType, toggleShowLinkedDocument: toggleShowLinkedDocument, message: messageRGPD })), (0, jsx_runtime_1.jsx)(ConfirmationDialog_1.default, { open: openConfirmDocumentDelete, onClose: handleCloseConfirmDocumentDelete, onConfirm: handleConfirmDocumentDelete, message: "\u00CAtes-vous s\u00FBr de vouloir supprimer ce document ?" }), (0, jsx_runtime_1.jsx)(ConfirmationDialog_1.default, { open: openConfirmVehicleDelete, onClose: handleCloseConfirmVehicleDelete, onConfirm: handleConfirmVehicleDelete, message: "\u00CAtes-vous s\u00FBr de vouloir supprimer ce v\u00E9hicule ?" })] }));
380
347
  };
381
348
  exports.default = VehicleFullCard;
@@ -30,6 +30,10 @@ export default class Vehicle {
30
30
  secondaryTireSpeedIndex: string;
31
31
  secondaryTireWidth: string;
32
32
  secondaryTireSize: VehicleTire;
33
- constructor(id: number, ownerId: number, averageMileagePerYear: number, plate: string, brand: string, model: string, version: string, vin: string, currentMileage: number, digitalPassportIndex: DigitalPassportIndex, firstRegistrationDate: Date, ktype: string, tireDiameter: string, tireHeight: string, tireSpeedIndex: string, tireWidth: string, documents: Document[], tireSize: VehicleTire, lastInspectionDate: Date, lastMaintenanceDate: Date, foreignPlate: boolean, secondaryTireDiameter: string, secondaryTireHeight: string, secondaryTireSpeedIndex: string, secondaryTireWidth: string, secondaryTireSize: VehicleTire, tireBrand?: string, tireProfile?: string);
33
+ engineCode: string;
34
+ gearboxCode: string;
35
+ gearboxType: string;
36
+ energy: string;
37
+ constructor(id: number, ownerId: number, averageMileagePerYear: number, plate: string, brand: string, model: string, version: string, vin: string, currentMileage: number, digitalPassportIndex: DigitalPassportIndex, firstRegistrationDate: Date, ktype: string, tireDiameter: string, tireHeight: string, tireSpeedIndex: string, tireWidth: string, documents: Document[], tireSize: VehicleTire, lastInspectionDate: Date, lastMaintenanceDate: Date, foreignPlate: boolean, secondaryTireDiameter: string, secondaryTireHeight: string, secondaryTireSpeedIndex: string, secondaryTireWidth: string, secondaryTireSize: VehicleTire, engineCode: string, gearboxCode: string, gearboxType: string, energy: string, tireBrand?: string, tireProfile?: string);
34
38
  getVehicleLabel(): string;
35
39
  }
@@ -11,7 +11,7 @@ Carburant : Essence
11
11
  Cylindrée : 1984 cm3
12
12
  Puissance : 140 KW (190 HP) */
13
13
  var Vehicle = /** @class */ (function () {
14
- function Vehicle(id, ownerId, averageMileagePerYear, plate, brand, model, version, vin, currentMileage, digitalPassportIndex, firstRegistrationDate, ktype, tireDiameter, tireHeight, tireSpeedIndex, tireWidth, documents, tireSize, lastInspectionDate, lastMaintenanceDate, foreignPlate, secondaryTireDiameter, secondaryTireHeight, secondaryTireSpeedIndex, secondaryTireWidth, secondaryTireSize, tireBrand, tireProfile) {
14
+ function Vehicle(id, ownerId, averageMileagePerYear, plate, brand, model, version, vin, currentMileage, digitalPassportIndex, firstRegistrationDate, ktype, tireDiameter, tireHeight, tireSpeedIndex, tireWidth, documents, tireSize, lastInspectionDate, lastMaintenanceDate, foreignPlate, secondaryTireDiameter, secondaryTireHeight, secondaryTireSpeedIndex, secondaryTireWidth, secondaryTireSize, engineCode, gearboxCode, gearboxType, energy, tireBrand, tireProfile) {
15
15
  this.id = id;
16
16
  this.ownerId = ownerId;
17
17
  this.averageMileagePerYear = averageMileagePerYear;
@@ -40,6 +40,10 @@ var Vehicle = /** @class */ (function () {
40
40
  this.secondaryTireSpeedIndex = secondaryTireSpeedIndex;
41
41
  this.secondaryTireWidth = secondaryTireWidth;
42
42
  this.secondaryTireSize = secondaryTireSize;
43
+ this.engineCode = engineCode;
44
+ this.gearboxCode = gearboxCode;
45
+ this.gearboxType = gearboxType;
46
+ this.energy = energy;
43
47
  }
44
48
  Vehicle.prototype.getVehicleLabel = function () {
45
49
  return "".concat(this.brand, " ").concat(this.model, " ").concat(this.version);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@movalib/movalib-commons",
3
- "version": "1.68.8",
3
+ "version": "1.68.9",
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",