@movalib/movalib-commons 1.59.31 → 1.59.33

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.
@@ -21,6 +21,7 @@ var MovaVehicleTireField_1 = __importDefault(require("../../MovaVehicleTireField
21
21
  var ConfirmationDialog_1 = __importDefault(require("../../ConfirmationDialog"));
22
22
  var Enums_1 = require("../../helpers/Enums");
23
23
  var Tools_1 = require("../../helpers/Tools");
24
+ var DateUtils_1 = require("../../helpers/DateUtils");
24
25
  var CloseRounded_1 = __importDefault(require("@mui/icons-material/CloseRounded"));
25
26
  var EditRounded_1 = __importDefault(require("@mui/icons-material/EditRounded"));
26
27
  var CloseRounded_2 = __importDefault(require("@mui/icons-material/CloseRounded"));
@@ -28,6 +29,7 @@ var Logger_1 = __importDefault(require("../../helpers/Logger"));
28
29
  var icons_material_1 = require("@mui/icons-material");
29
30
  var LinkedDocumentDialog_1 = require("../LinkedDocumentDialog");
30
31
  var car_plate_bg_png_1 = __importDefault(require("../../assets/images/car_plate_bg.png"));
32
+ var x_date_pickers_1 = require("@mui/x-date-pickers");
31
33
  var initialUserFormState = {
32
34
  currentMileage: { value: null, isValid: true },
33
35
  averageMileagePerYear: { value: null, isValid: true },
@@ -35,7 +37,9 @@ var initialUserFormState = {
35
37
  tireWidth: { value: '', isValid: true },
36
38
  tireHeight: { value: '', isValid: true },
37
39
  tireDiameter: { value: '', isValid: true },
38
- tireSpeedIndex: { value: '', isValid: true }
40
+ tireSpeedIndex: { value: '', isValid: true },
41
+ lastInspectionDate: { value: null, isValid: true },
42
+ lastMaintenanceDate: { value: null, isValid: true }
39
43
  };
40
44
  var VehicleFullCard = function (_a) {
41
45
  var _b;
@@ -86,6 +90,14 @@ var VehicleFullCard = function (_a) {
86
90
  var _a;
87
91
  return (__assign(__assign({}, prevForm), (_a = {}, _a['tireSpeedIndex'] = __assign(__assign({}, prevForm['tireSpeedIndex']), { value: vehicle.tireSpeedIndex }), _a)));
88
92
  });
93
+ setForm(function (prevForm) {
94
+ var _a;
95
+ return (__assign(__assign({}, prevForm), (_a = {}, _a['lastInspectionDate'] = __assign(__assign({}, prevForm['lastInspectionDate']), { value: vehicle.lastInspectionDate ? new Date(vehicle.lastInspectionDate) : null }), _a)));
96
+ });
97
+ setForm(function (prevForm) {
98
+ var _a;
99
+ return (__assign(__assign({}, prevForm), (_a = {}, _a['lastMaintenanceDate'] = __assign(__assign({}, prevForm['lastMaintenanceDate']), { value: vehicle.lastMaintenanceDate ? new Date(vehicle.lastMaintenanceDate) : null }), _a)));
100
+ });
89
101
  if (isVehicleTireSizeDefined(vehicle)) {
90
102
  setForm(function (prevForm) {
91
103
  var _a;
@@ -125,6 +137,7 @@ var VehicleFullCard = function (_a) {
125
137
  };
126
138
  var handleChange = function (fieldName, fieldValue) {
127
139
  var _a;
140
+ console.log(fieldName, fieldValue);
128
141
  var newField = (_a = {}, _a[fieldName] = { value: fieldValue, isValid: true }, _a);
129
142
  setForm(__assign(__assign({}, form), newField));
130
143
  };
@@ -183,7 +196,9 @@ var VehicleFullCard = function (_a) {
183
196
  tireWidth: form.tireSize.isValid && form.tireSize.value ? form.tireSize.value.width : undefined,
184
197
  tireHeight: form.tireSize.isValid && form.tireSize.value ? form.tireSize.value.height : undefined,
185
198
  tireDiameter: form.tireSize.isValid && form.tireSize.value ? form.tireSize.value.diameter : undefined,
186
- tireSpeedIndex: form.tireSize.isValid && form.tireSize.value ? form.tireSize.value.speedIndex : undefined
199
+ tireSpeedIndex: form.tireSize.isValid && form.tireSize.value ? form.tireSize.value.speedIndex : undefined,
200
+ lastInspectionDate: form.lastInspectionDate.value,
201
+ lastMaintenanceDate: form.lastMaintenanceDate.value,
187
202
  };
188
203
  Logger_1.default.info(query);
189
204
  // Appel du callback correspondant
@@ -231,7 +246,7 @@ var VehicleFullCard = function (_a) {
231
246
  '& input': { textTransform: 'uppercase' } // CSS pour forcer les majuscules dans l'input
232
247
  }, helperText: Boolean(form.currentMileage.error && form.currentMileage.value > 0)
233
248
  ? 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 ?
234
- 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 })) })) })) }), (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 &&
249
+ 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)(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) !== '' ? (0, DateUtils_1.formatDateByTimezone)(vehicle.lastInspectionDate, 'Europe/Paris', Enums_1.DateFormatTypes.SHORT_FORMAT_DATE) : '-' }) })) }))] })), 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, format: 'dd/MM/yyyy', formatDensity: 'dense', views: ['day'], displayWeekNumber: true, onChange: function (e) { return handleChange('lastInspectionDate', e); } }) })) })), !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) !== '' ? (0, DateUtils_1.formatDateByTimezone)(vehicle.lastMaintenanceDate, 'Europe/Paris', Enums_1.DateFormatTypes.SHORT_FORMAT_DATE) : '-' }) })) }))] })), 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 entretient", name: 'lastMaintenanceDate', value: form.lastMaintenanceDate.value, format: 'dd/MM/yyyy', formatDensity: 'dense', views: ['day'], displayWeekNumber: true, onChange: function (e) { return handleChange('lastMaintenanceDate', e); } }) })) }))] })), !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 })) })) })) }), (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 &&
235
250
  (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 &&
236
251
  (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 }), (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 ?" })] }));
237
252
  };
@@ -14,6 +14,8 @@ export type MovaVehicleForm = {
14
14
  tireHeight: MovaFormField;
15
15
  tireDiameter: MovaFormField;
16
16
  tireSpeedIndex: MovaFormField;
17
+ lastInspectionDate: MovaFormField;
18
+ lastMaintenanceDate: MovaFormField;
17
19
  };
18
20
  /**
19
21
  * Type utilisé pour définir un interval sur une objet Schedule
@@ -54,5 +54,6 @@ export default class Garage {
54
54
  paymentAuthorizationMinDowntime?: number;
55
55
  timezone: string;
56
56
  customStyle?: string;
57
- constructor(id: string, adminId: string, name: string, address: Address, workforce: number, prestations: Prestation[], schedules: Schedule[], contactPhone: string, prestationCategories: CategoryPrestation[], dayPeriodFastServiceExcluded: boolean, loanerVehicleFastServiceExcluded: boolean, fastServiceThreshold: number, timezone: string, vehicles?: VehicleGarage[], contactEmail?: string, logo?: string, suppliers?: Supplier[], documents?: Document[], subscriptions?: Subscription[], loanerVehicleActive?: boolean, loanerVehicleRequestActive?: boolean, customStyle?: string, subscription?: Subscription, partialWorkforce?: number);
57
+ mailCustomization?: boolean;
58
+ constructor(id: string, adminId: string, name: string, address: Address, workforce: number, prestations: Prestation[], schedules: Schedule[], contactPhone: string, prestationCategories: CategoryPrestation[], dayPeriodFastServiceExcluded: boolean, loanerVehicleFastServiceExcluded: boolean, fastServiceThreshold: number, timezone: string, vehicles?: VehicleGarage[], contactEmail?: string, logo?: string, suppliers?: Supplier[], documents?: Document[], subscriptions?: Subscription[], loanerVehicleActive?: boolean, loanerVehicleRequestActive?: boolean, customStyle?: string, subscription?: Subscription, partialWorkforce?: number, mailCustomization?: boolean);
58
59
  }
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  var Garage = /** @class */ (function () {
4
- function Garage(id, adminId, name, address, workforce, prestations, schedules, contactPhone, prestationCategories, dayPeriodFastServiceExcluded, loanerVehicleFastServiceExcluded, fastServiceThreshold, timezone, vehicles, contactEmail, logo, suppliers, documents, subscriptions, loanerVehicleActive, loanerVehicleRequestActive, customStyle, subscription, partialWorkforce) {
4
+ function Garage(id, adminId, name, address, workforce, prestations, schedules, contactPhone, prestationCategories, dayPeriodFastServiceExcluded, loanerVehicleFastServiceExcluded, fastServiceThreshold, timezone, vehicles, contactEmail, logo, suppliers, documents, subscriptions, loanerVehicleActive, loanerVehicleRequestActive, customStyle, subscription, partialWorkforce, mailCustomization) {
5
5
  this.id = id;
6
6
  this.adminId = adminId;
7
7
  this.name = name;
@@ -26,6 +26,7 @@ var Garage = /** @class */ (function () {
26
26
  this.fastServiceThreshold = fastServiceThreshold;
27
27
  this.customStyle = customStyle;
28
28
  this.timezone = timezone;
29
+ this.mailCustomization = mailCustomization;
29
30
  }
30
31
  return Garage;
31
32
  }());
@@ -20,6 +20,8 @@ export default class Vehicle {
20
20
  tireWidth: string;
21
21
  documents: Document[];
22
22
  tireSize: VehicleTire;
23
- 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);
23
+ lastInspectionDate: Date;
24
+ lastMaintenanceDate: Date;
25
+ 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);
24
26
  getVehicleLabel(): string;
25
27
  }
@@ -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) {
14
+ function Vehicle(id, ownerId, averageMileagePerYear, plate, brand, model, version, vin, currentMileage, digitalPassportIndex, firstRegistrationDate, ktype, tireDiameter, tireHeight, tireSpeedIndex, tireWidth, documents, tireSize, lastInspectionDate, lastMaintenanceDate) {
15
15
  this.id = id;
16
16
  this.ownerId = ownerId;
17
17
  this.averageMileagePerYear = averageMileagePerYear;
@@ -30,6 +30,8 @@ var Vehicle = /** @class */ (function () {
30
30
  this.tireWidth = tireWidth;
31
31
  this.documents = documents;
32
32
  this.tireSize = tireSize;
33
+ this.lastInspectionDate = lastInspectionDate;
34
+ this.lastMaintenanceDate = lastMaintenanceDate;
33
35
  }
34
36
  Vehicle.prototype.getVehicleLabel = function () {
35
37
  return "".concat(this.brand, " ").concat(this.model, " ").concat(this.version);
@@ -14,6 +14,8 @@ export type AddCustomerVehicleParams = {
14
14
  tireHeight?: string;
15
15
  tireDiameter?: string;
16
16
  tireSpeedIndex?: string;
17
+ lastMaintenanceDate?: string;
18
+ lastInspectionDate?: string;
17
19
  };
18
20
  export type DeleteCustomerVehicleParams = {
19
21
  /** L'identifiant unique du garage */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@movalib/movalib-commons",
3
- "version": "1.59.31",
3
+ "version": "1.59.33",
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",
@@ -23,6 +23,7 @@ import { AttachFile } from '@mui/icons-material';
23
23
  import { LinkedDocumentDialog } from '../LinkedDocumentDialog';
24
24
  import User from '../../models/User';
25
25
  import CatPlateBg from '../../assets/images/car_plate_bg.png';
26
+ import { DatePicker } from '@mui/x-date-pickers';
26
27
 
27
28
  interface VehicleFullCardProps {
28
29
  currentUser: User,
@@ -46,7 +47,9 @@ const initialUserFormState = {
46
47
  tireWidth: { value: '', isValid: true },
47
48
  tireHeight: { value: '', isValid: true },
48
49
  tireDiameter: { value: '', isValid: true },
49
- tireSpeedIndex: { value: '', isValid: true }
50
+ tireSpeedIndex: { value: '', isValid: true },
51
+ lastInspectionDate: { value: null, isValid: true },
52
+ lastMaintenanceDate: { value: null, isValid: true }
50
53
  }
51
54
 
52
55
  const VehicleFullCard: FC<VehicleFullCardProps> = ({ vehicle, fullwidth, onError, onUploadDocument, onDeleteDocument, appType, editMode = false, focused = false, onUpdate, onDelete, currentUpload, currentUser }) => {
@@ -80,7 +83,8 @@ const VehicleFullCard: FC<VehicleFullCardProps> = ({ vehicle, fullwidth, onError
80
83
  }, [vehicle]);
81
84
 
82
85
  const initForm = () => {
83
- if (vehicle) {
86
+ if (vehicle)
87
+ {
84
88
 
85
89
  setForm(prevForm => (
86
90
  { ...prevForm, ['currentMileage']: { ...prevForm['currentMileage'], value: vehicle.currentMileage } }));
@@ -94,6 +98,10 @@ const VehicleFullCard: FC<VehicleFullCardProps> = ({ vehicle, fullwidth, onError
94
98
  { ...prevForm, ['tireDiameter']: { ...prevForm['tireDiameter'], value: vehicle.tireDiameter } }));
95
99
  setForm(prevForm => (
96
100
  { ...prevForm, ['tireSpeedIndex']: { ...prevForm['tireSpeedIndex'], value: vehicle.tireSpeedIndex } }));
101
+ setForm(prevForm => (
102
+ { ...prevForm, ['lastInspectionDate']: { ...prevForm['lastInspectionDate'], value: vehicle.lastInspectionDate ? new Date(vehicle.lastInspectionDate) : null } }));
103
+ setForm(prevForm => (
104
+ { ...prevForm, ['lastMaintenanceDate']: { ...prevForm['lastMaintenanceDate'], value: vehicle.lastMaintenanceDate ? new Date(vehicle.lastMaintenanceDate) : null } }));
97
105
 
98
106
  if (isVehicleTireSizeDefined(vehicle))
99
107
  {
@@ -107,10 +115,12 @@ const VehicleFullCard: FC<VehicleFullCardProps> = ({ vehicle, fullwidth, onError
107
115
 
108
116
  const toggleShowLinkedDocument = (docType: DocumentType | null) => {
109
117
  setShowLinkedDocument(!isShowLinkedDocument);
110
- if (docType && invoiceInputRef.current) {
118
+ if (docType && invoiceInputRef.current)
119
+ {
111
120
  docTypeCurrent.current = docType;
112
121
  invoiceInputRef.current.click();
113
- } else {
122
+ } else
123
+ {
114
124
  docTypeCurrent.current = undefined;
115
125
  }
116
126
  }
@@ -142,18 +152,21 @@ const VehicleFullCard: FC<VehicleFullCardProps> = ({ vehicle, fullwidth, onError
142
152
  }
143
153
 
144
154
  const handleChange = (fieldName: string, fieldValue: string): void => {
155
+ console.log(fieldName, fieldValue);
145
156
  const newField: MovaFormField = { [fieldName]: { value: fieldValue, isValid: true } };
146
157
 
147
158
  setForm({ ...form, ...newField });
148
159
  }
149
160
 
150
161
  const uploadVehicleDocument = (document: File, documentType: DocumentType) => {
151
- if (document.size > 10000000) {
162
+ if (document.size > 10000000)
163
+ {
152
164
  setSizeLimit(true);
153
165
  return;
154
166
  }
155
167
 
156
- if (vehicle && document && documentType) {
168
+ if (vehicle && document && documentType)
169
+ {
157
170
 
158
171
  // Utilisation d'un formData pour permettre le trasnfert de fichier vers l'API
159
172
  let formData = new FormData();
@@ -175,7 +188,8 @@ const VehicleFullCard: FC<VehicleFullCardProps> = ({ vehicle, fullwidth, onError
175
188
  const handleFileChange = (event: React.ChangeEvent<HTMLInputElement>, docType: DocumentType) => {
176
189
  event.preventDefault();
177
190
 
178
- if (event && event.target.files && event.target.files.length > 0 && docType) {
191
+ if (event && event.target.files && event.target.files.length > 0 && docType)
192
+ {
179
193
  uploadVehicleDocument(event.target.files[0], docType);
180
194
  }
181
195
 
@@ -192,6 +206,7 @@ const VehicleFullCard: FC<VehicleFullCardProps> = ({ vehicle, fullwidth, onError
192
206
  { ...prevForm, ['tireSize']: { ...prevForm['tireSize'], value: vehicleTire, isValid: isValid } }));
193
207
  }
194
208
 
209
+
195
210
  const handleOnClickDeleteVehicle = (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => {
196
211
  e.preventDefault();
197
212
  setOpenConfirmVehicleDelete(true);
@@ -205,7 +220,8 @@ const VehicleFullCard: FC<VehicleFullCardProps> = ({ vehicle, fullwidth, onError
205
220
 
206
221
  const handleOnClickValidate = () => {
207
222
 
208
- if (validateForm()) {
223
+ if (validateForm())
224
+ {
209
225
 
210
226
  Logger.info(form.tireSize.value);
211
227
 
@@ -215,7 +231,9 @@ const VehicleFullCard: FC<VehicleFullCardProps> = ({ vehicle, fullwidth, onError
215
231
  tireWidth: form.tireSize.isValid && form.tireSize.value ? (form.tireSize.value as VehicleTire).width : undefined,
216
232
  tireHeight: form.tireSize.isValid && form.tireSize.value ? (form.tireSize.value as VehicleTire).height : undefined,
217
233
  tireDiameter: form.tireSize.isValid && form.tireSize.value ? (form.tireSize.value as VehicleTire).diameter : undefined,
218
- tireSpeedIndex: form.tireSize.isValid && form.tireSize.value ? (form.tireSize.value as VehicleTire).speedIndex : undefined
234
+ tireSpeedIndex: form.tireSize.isValid && form.tireSize.value ? (form.tireSize.value as VehicleTire).speedIndex : undefined,
235
+ lastInspectionDate: form.lastInspectionDate.value,
236
+ lastMaintenanceDate: form.lastMaintenanceDate.value,
219
237
  }
220
238
  Logger.info(query)
221
239
 
@@ -245,7 +263,8 @@ const VehicleFullCard: FC<VehicleFullCardProps> = ({ vehicle, fullwidth, onError
245
263
  const handleConfirmDocumentDelete = () => {
246
264
  setOpenConfirmDocumentDelete(false);
247
265
 
248
- if (vehicle && documentToDelete) {
266
+ if (vehicle && documentToDelete)
267
+ {
249
268
 
250
269
  // Appel du callback correspondant
251
270
  if (onDeleteDocument)
@@ -256,7 +275,8 @@ const VehicleFullCard: FC<VehicleFullCardProps> = ({ vehicle, fullwidth, onError
256
275
  const handleConfirmVehicleDelete = () => {
257
276
  setOpenConfirmVehicleDelete(false);
258
277
 
259
- if (vehicle && onDelete) {
278
+ if (vehicle && onDelete)
279
+ {
260
280
 
261
281
  // Appel du callback correspondant
262
282
  onDelete();
@@ -280,12 +300,12 @@ const VehicleFullCard: FC<VehicleFullCardProps> = ({ vehicle, fullwidth, onError
280
300
  </Typography>
281
301
  <Grid container justifyContent="space-between">
282
302
 
283
- <Grid container sx={{ mb: 1, alignItems: 'center', justifyContent: 'center' }}>
284
- <Grid item xs={6} sx={{ position: 'relative', minWidth: '234px'}}>
303
+ <Grid container sx={{ mb: 1, alignItems: 'center', justifyContent: 'center' }}>
304
+ <Grid item xs={6} sx={{ position: 'relative', minWidth: '234px' }}>
285
305
  <img
286
306
  src={CatPlateBg}
287
307
  alt="Plaque d'immatriculation"
288
- style={{ height: '50px', position: 'relative', }}
308
+ style={{ height: '50px', position: 'relative', }}
289
309
  />
290
310
  <Typography
291
311
  variant='h6'
@@ -395,6 +415,64 @@ const VehicleFullCard: FC<VehicleFullCardProps> = ({ vehicle, fullwidth, onError
395
415
  />
396
416
  </Grid>}
397
417
 
418
+ {!localEditMode && <Grid container textAlign='justify' sx={{ pt: 2 }}>
419
+ <Grid item xs={8} >
420
+ <Typography variant="body1" color="text.secondary">
421
+ Dernier contrôle technique :
422
+ </Typography>
423
+ </Grid>
424
+ <Grid item xs={4} sx={{ textAlign: 'right' }}>
425
+ <Typography variant="body1" color="text.secondary">
426
+ <b>{formatDateByTimezone(vehicle.lastInspectionDate, 'Europe/Paris', DateFormatTypes.SHORT_FORMAT_DATE) !== '' ? formatDateByTimezone(vehicle.lastInspectionDate, 'Europe/Paris', DateFormatTypes.SHORT_FORMAT_DATE) : '-'}</b>
427
+ </Typography>
428
+ </Grid>
429
+ </Grid>}
430
+
431
+ {localEditMode && <Grid item xs={12}>
432
+ <FormControl fullWidth sx={{marginTop: 2}}>
433
+ <DatePicker
434
+ label={"Dernier contrôle technique"}
435
+ name={'lastInspectionDate'}
436
+ value={form.lastInspectionDate.value}
437
+ format='dd/MM/yyyy'
438
+ formatDensity='dense'
439
+ views={['day']}
440
+ displayWeekNumber
441
+ onChange={(e)=>handleChange('lastInspectionDate',e)}
442
+ />
443
+ </FormControl>
444
+ </Grid>}
445
+
446
+ {!localEditMode && <Grid container textAlign='justify' sx={{ pt: 2 }}>
447
+ <Grid item xs={8} >
448
+ <Typography variant="body1" color="text.secondary">
449
+ Dernier entretien :
450
+ </Typography>
451
+ </Grid>
452
+ <Grid item xs={4} sx={{ textAlign: 'right' }}>
453
+ <Typography variant="body1" color="text.secondary">
454
+ <b>{formatDateByTimezone(vehicle.lastMaintenanceDate, 'Europe/Paris', DateFormatTypes.SHORT_FORMAT_DATE) !== '' ? formatDateByTimezone(vehicle.lastMaintenanceDate, 'Europe/Paris', DateFormatTypes.SHORT_FORMAT_DATE) : '-'}</b>
455
+ </Typography>
456
+ </Grid>
457
+ </Grid>}
458
+
459
+ {localEditMode && <Grid item xs={12}>
460
+ <FormControl fullWidth sx={{marginTop: 2}}>
461
+ <DatePicker
462
+ label={"Dernier entretient"}
463
+ name={'lastMaintenanceDate'}
464
+ value={form.lastMaintenanceDate.value}
465
+ format='dd/MM/yyyy'
466
+ formatDensity='dense'
467
+ views={['day']}
468
+ displayWeekNumber
469
+ onChange={(e)=>handleChange('lastMaintenanceDate',e)}
470
+ />
471
+ </FormControl>
472
+ </Grid>}
473
+
474
+
475
+
398
476
  </Grid>
399
477
 
400
478
  {!localEditMode && <>
@@ -15,7 +15,9 @@ export type MovaVehicleForm = {
15
15
  tireWidth: MovaFormField,
16
16
  tireHeight: MovaFormField,
17
17
  tireDiameter: MovaFormField,
18
- tireSpeedIndex: MovaFormField
18
+ tireSpeedIndex: MovaFormField,
19
+ lastInspectionDate: MovaFormField,
20
+ lastMaintenanceDate: MovaFormField,
19
21
  }
20
22
 
21
23
  /**
@@ -55,6 +55,7 @@ export default class Garage {
55
55
  paymentAuthorizationMinDowntime?: number;
56
56
  timezone: string;
57
57
  customStyle?: string;
58
+ mailCustomization?: boolean;
58
59
 
59
60
  constructor(
60
61
  id:string,
@@ -81,6 +82,7 @@ export default class Garage {
81
82
  customStyle?: string,
82
83
  subscription?: Subscription,
83
84
  partialWorkforce?: number,
85
+ mailCustomization?: boolean,
84
86
  ) {
85
87
  this.id = id;
86
88
  this.adminId = adminId;
@@ -106,5 +108,6 @@ export default class Garage {
106
108
  this.fastServiceThreshold = fastServiceThreshold;
107
109
  this.customStyle = customStyle;
108
110
  this.timezone = timezone;
111
+ this.mailCustomization = mailCustomization;
109
112
  }
110
113
  }
@@ -34,6 +34,8 @@ export default class Vehicle {
34
34
  tireWidth: string;
35
35
  documents : Document[];
36
36
  tireSize: VehicleTire;
37
+ lastInspectionDate: Date;
38
+ lastMaintenanceDate: Date;
37
39
 
38
40
  constructor(
39
41
  id: number,
@@ -53,7 +55,9 @@ export default class Vehicle {
53
55
  tireSpeedIndex: string,
54
56
  tireWidth: string,
55
57
  documents: Document[],
56
- tireSize: VehicleTire
58
+ tireSize: VehicleTire,
59
+ lastInspectionDate: Date,
60
+ lastMaintenanceDate: Date
57
61
  ) {
58
62
  this.id = id;
59
63
  this.ownerId = ownerId;
@@ -73,6 +77,8 @@ export default class Vehicle {
73
77
  this.tireWidth = tireWidth;
74
78
  this.documents = documents;
75
79
  this.tireSize = tireSize;
80
+ this.lastInspectionDate = lastInspectionDate;
81
+ this.lastMaintenanceDate = lastMaintenanceDate;
76
82
  }
77
83
 
78
84
  getVehicleLabel() {
@@ -15,6 +15,8 @@ export type AddCustomerVehicleParams = {
15
15
  tireHeight?: string;
16
16
  tireDiameter?: string;
17
17
  tireSpeedIndex?: string;
18
+ lastMaintenanceDate?: string;
19
+ lastInspectionDate?: string;
18
20
  }
19
21
 
20
22