@movalib/movalib-commons 1.59.35 → 1.59.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/components/vehicle/VehicleFullCard.d.ts +5 -5
- package/dist/src/components/vehicle/VehicleFullCard.js +101 -82
- package/dist/src/helpers/Enums.d.ts +7 -6
- package/dist/src/helpers/Enums.js +6 -5
- package/dist/src/models/Document.d.ts +2 -1
- package/dist/src/models/Document.js +3 -5
- package/dist/src/models/Event.d.ts +19 -7
- package/dist/src/models/Event.js +14 -5
- package/dist/src/models/Product.d.ts +2 -1
- package/dist/src/models/Product.js +2 -1
- package/dist/src/services/GarageService.d.ts +3 -1
- package/dist/src/services/GarageService.js +18 -4
- package/package.json +1 -1
- package/src/components/vehicle/VehicleFullCard.tsx +847 -559
- package/src/helpers/Enums.ts +216 -217
- package/src/models/Document.ts +42 -37
- package/src/models/Event.ts +147 -103
- package/src/models/Product.ts +40 -26
- package/src/services/GarageService.ts +667 -621
|
@@ -1,508 +1,748 @@
|
|
|
1
|
+
import { AttachFile } from "@mui/icons-material";
|
|
1
2
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
} from
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
3
|
+
default as CancelIcon,
|
|
4
|
+
default as CloseIcon,
|
|
5
|
+
} from "@mui/icons-material/CloseRounded";
|
|
6
|
+
import EditIcon from "@mui/icons-material/EditRounded";
|
|
7
|
+
import {
|
|
8
|
+
Alert,
|
|
9
|
+
Box,
|
|
10
|
+
Button,
|
|
11
|
+
Card,
|
|
12
|
+
CardActions,
|
|
13
|
+
CardContent,
|
|
14
|
+
FormControl,
|
|
15
|
+
FormHelperText,
|
|
16
|
+
Grid,
|
|
17
|
+
IconButton,
|
|
18
|
+
InputLabel,
|
|
19
|
+
Link,
|
|
20
|
+
MenuItem,
|
|
21
|
+
Select,
|
|
22
|
+
SelectChangeEvent,
|
|
23
|
+
TextField,
|
|
24
|
+
Tooltip,
|
|
25
|
+
Typography,
|
|
26
|
+
darken,
|
|
27
|
+
useTheme,
|
|
28
|
+
} from "@mui/material";
|
|
29
|
+
import { DatePicker } from "@mui/x-date-pickers";
|
|
30
|
+
import { useEffect, useRef, useState, type FC } from "react";
|
|
31
|
+
import CatPlateBg from "../../assets/images/car_plate_bg.png";
|
|
32
|
+
import ConfirmationDialog from "../../ConfirmationDialog";
|
|
33
|
+
import { formatDateByTimezone } from "../../helpers/DateUtils";
|
|
34
|
+
import {
|
|
35
|
+
DateFormatTypes,
|
|
36
|
+
DocumentType,
|
|
37
|
+
MovaAppType,
|
|
38
|
+
} from "../../helpers/Enums";
|
|
39
|
+
import Logger from "../../helpers/Logger";
|
|
40
|
+
import {
|
|
41
|
+
formatFrenchVehiclePlate,
|
|
42
|
+
formatVehicleTire,
|
|
43
|
+
} from "../../helpers/Tools";
|
|
44
|
+
import { MovaFormField, MovaVehicleForm } from "../../helpers/Types";
|
|
45
|
+
import User from "../../models/User";
|
|
46
|
+
import Vehicle from "../../models/Vehicle";
|
|
47
|
+
import VehicleTire from "../../models/VehicleTire";
|
|
48
|
+
import MovaVehicleTireField from "../../MovaVehicleTireField";
|
|
49
|
+
import { LinkedDocumentDialog } from "../LinkedDocumentDialog";
|
|
27
50
|
|
|
28
51
|
interface VehicleFullCardProps {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
52
|
+
currentUser: User;
|
|
53
|
+
vehicle: Vehicle;
|
|
54
|
+
onError: (message: string) => void;
|
|
55
|
+
onUploadDocument: (data: FormData) => void;
|
|
56
|
+
onDeleteDocument: (documentId: string) => void;
|
|
57
|
+
editMode: boolean;
|
|
58
|
+
appType: MovaAppType;
|
|
59
|
+
fullwidth?: boolean;
|
|
60
|
+
focused?: boolean;
|
|
61
|
+
onUpdate?: (form: MovaVehicleForm) => void;
|
|
62
|
+
onDelete?: () => void;
|
|
63
|
+
currentUpload: boolean;
|
|
41
64
|
}
|
|
42
65
|
|
|
43
66
|
const initialUserFormState = {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const VehicleFullCard: FC<VehicleFullCardProps> = ({
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
{ ...prevForm, ['tireDiameter']: { ...prevForm['tireDiameter'], value: vehicle.tireDiameter } }));
|
|
99
|
-
setForm(prevForm => (
|
|
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 } }));
|
|
105
|
-
|
|
106
|
-
if (isVehicleTireSizeDefined(vehicle))
|
|
107
|
-
{
|
|
108
|
-
setForm(prevForm => (
|
|
109
|
-
{ ...prevForm, ['tireSize']: { ...prevForm['tireSize'], value: vehicle.tireSize } }));
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
Logger.info(form);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
const toggleShowLinkedDocument = (docType: DocumentType | null) => {
|
|
117
|
-
setShowLinkedDocument(!isShowLinkedDocument);
|
|
118
|
-
if (docType && invoiceInputRef.current)
|
|
119
|
-
{
|
|
120
|
-
docTypeCurrent.current = docType;
|
|
121
|
-
invoiceInputRef.current.click();
|
|
122
|
-
} else
|
|
123
|
-
{
|
|
124
|
-
docTypeCurrent.current = undefined;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
const isVehicleTireSizeDefined = (vehicle: Vehicle) => {
|
|
129
|
-
return vehicle.tireSize && vehicle.tireSize.diameter && vehicle.tireSize.height && vehicle.tireSize.speedIndex && vehicle.tireSize.width;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
const validateForm = () => {
|
|
133
|
-
let newForm: MovaVehicleForm = { ...form };
|
|
134
|
-
|
|
135
|
-
// Validator pour les champs obligatoires
|
|
136
|
-
newForm.currentMileage = validateField(form.currentMileage, value => !!value, 'Champ obligatoire');
|
|
137
|
-
newForm.averageMileagePerYear = validateField(form.averageMileagePerYear, value => !!value, 'Champ obligatoire');
|
|
138
|
-
|
|
139
|
-
// La validation de la saisie des pneumatiques se fait dans le composant "MovaVehicleTireField", traitée dans le callback "handleOnChangeVehicleTire"
|
|
140
|
-
|
|
141
|
-
setForm(newForm);
|
|
142
|
-
|
|
143
|
-
return newForm.currentMileage.isValid && newForm.averageMileagePerYear.isValid && newForm.tireSize.isValid;
|
|
144
|
-
}
|
|
67
|
+
currentMileage: { value: null, isValid: true },
|
|
68
|
+
averageMileagePerYear: { value: null, isValid: true },
|
|
69
|
+
tireSize: { value: null, isValid: true },
|
|
70
|
+
tireWidth: { value: "", isValid: true },
|
|
71
|
+
tireHeight: { value: "", isValid: true },
|
|
72
|
+
tireDiameter: { value: "", isValid: true },
|
|
73
|
+
tireSpeedIndex: { value: "", isValid: true },
|
|
74
|
+
lastInspectionDate: { value: null, isValid: true },
|
|
75
|
+
lastMaintenanceDate: { value: null, isValid: true },
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const VehicleFullCard: FC<VehicleFullCardProps> = ({
|
|
79
|
+
vehicle,
|
|
80
|
+
fullwidth,
|
|
81
|
+
onError,
|
|
82
|
+
onUploadDocument,
|
|
83
|
+
onDeleteDocument,
|
|
84
|
+
appType,
|
|
85
|
+
editMode = false,
|
|
86
|
+
focused = false,
|
|
87
|
+
onUpdate,
|
|
88
|
+
onDelete,
|
|
89
|
+
currentUpload,
|
|
90
|
+
currentUser,
|
|
91
|
+
}) => {
|
|
92
|
+
const theme = useTheme();
|
|
93
|
+
const [localEditMode, setLocalEditMode] = useState(editMode);
|
|
94
|
+
const [openConfirmDocumentDelete, setOpenConfirmDocumentDelete] =
|
|
95
|
+
useState(false);
|
|
96
|
+
const [openConfirmVehicleDelete, setOpenConfirmVehicleDelete] =
|
|
97
|
+
useState(false);
|
|
98
|
+
const [documentToDelete, setDocumentToDelete] = useState("");
|
|
99
|
+
const [sizeLimit, setSizeLimit] = useState(false);
|
|
100
|
+
// Formulaire utilisé pour les modifications d'informations sur le véhicule
|
|
101
|
+
const [form, setForm] = useState<MovaVehicleForm>(initialUserFormState);
|
|
102
|
+
// Références aux éventuels documents uploadés depuis la fiche
|
|
103
|
+
const invoiceInputRef = useRef<HTMLInputElement>(null);
|
|
104
|
+
const tirePictureInputRef = useRef(null);
|
|
105
|
+
const [isShowLinkedDocument, setShowLinkedDocument] = useState(false);
|
|
106
|
+
const docTypeCurrent = useRef<DocumentType>();
|
|
107
|
+
|
|
108
|
+
const messageRGPD =
|
|
109
|
+
appType === MovaAppType.INDIVIDUAL ? (
|
|
110
|
+
<Box></Box>
|
|
111
|
+
) : (
|
|
112
|
+
<Box sx={{ mt: 2 }}>
|
|
113
|
+
<Alert severity="warning">
|
|
114
|
+
Vous êtes responsable des documents que vous importez, en ajoutant un
|
|
115
|
+
document vous reconnaissez disposer du consentement explicite du
|
|
116
|
+
client pour le stockage de ses données conformément à la
|
|
117
|
+
réglementation RGPD.
|
|
118
|
+
</Alert>
|
|
119
|
+
</Box>
|
|
120
|
+
);
|
|
145
121
|
|
|
146
|
-
|
|
147
|
-
|
|
122
|
+
useEffect(() => {
|
|
123
|
+
setLocalEditMode(editMode);
|
|
124
|
+
}, [editMode]);
|
|
125
|
+
|
|
126
|
+
useEffect(() => {
|
|
127
|
+
initForm();
|
|
128
|
+
}, [vehicle]);
|
|
129
|
+
|
|
130
|
+
const initForm = () => {
|
|
131
|
+
if (vehicle) {
|
|
132
|
+
setForm((prevForm) => ({
|
|
133
|
+
...prevForm,
|
|
134
|
+
currentMileage: {
|
|
135
|
+
...prevForm["currentMileage"],
|
|
136
|
+
value: vehicle.currentMileage,
|
|
137
|
+
},
|
|
138
|
+
}));
|
|
139
|
+
setForm((prevForm) => ({
|
|
140
|
+
...prevForm,
|
|
141
|
+
averageMileagePerYear: {
|
|
142
|
+
...prevForm["averageMileagePerYear"],
|
|
143
|
+
value: vehicle.averageMileagePerYear,
|
|
144
|
+
},
|
|
145
|
+
}));
|
|
146
|
+
setForm((prevForm) => ({
|
|
147
|
+
...prevForm,
|
|
148
|
+
tireWidth: { ...prevForm["tireWidth"], value: vehicle.tireWidth },
|
|
149
|
+
}));
|
|
150
|
+
setForm((prevForm) => ({
|
|
151
|
+
...prevForm,
|
|
152
|
+
tireHeight: { ...prevForm["tireHeight"], value: vehicle.tireHeight },
|
|
153
|
+
}));
|
|
154
|
+
setForm((prevForm) => ({
|
|
155
|
+
...prevForm,
|
|
156
|
+
tireDiameter: {
|
|
157
|
+
...prevForm["tireDiameter"],
|
|
158
|
+
value: vehicle.tireDiameter,
|
|
159
|
+
},
|
|
160
|
+
}));
|
|
161
|
+
setForm((prevForm) => ({
|
|
162
|
+
...prevForm,
|
|
163
|
+
tireSpeedIndex: {
|
|
164
|
+
...prevForm["tireSpeedIndex"],
|
|
165
|
+
value: vehicle.tireSpeedIndex,
|
|
166
|
+
},
|
|
167
|
+
}));
|
|
168
|
+
setForm((prevForm) => ({
|
|
169
|
+
...prevForm,
|
|
170
|
+
lastInspectionDate: {
|
|
171
|
+
...prevForm["lastInspectionDate"],
|
|
172
|
+
value: vehicle.lastInspectionDate
|
|
173
|
+
? new Date(vehicle.lastInspectionDate)
|
|
174
|
+
: null,
|
|
175
|
+
},
|
|
176
|
+
}));
|
|
177
|
+
setForm((prevForm) => ({
|
|
178
|
+
...prevForm,
|
|
179
|
+
lastMaintenanceDate: {
|
|
180
|
+
...prevForm["lastMaintenanceDate"],
|
|
181
|
+
value: vehicle.lastMaintenanceDate
|
|
182
|
+
? new Date(vehicle.lastMaintenanceDate)
|
|
183
|
+
: null,
|
|
184
|
+
},
|
|
185
|
+
}));
|
|
186
|
+
|
|
187
|
+
if (isVehicleTireSizeDefined(vehicle)) {
|
|
188
|
+
setForm((prevForm) => ({
|
|
189
|
+
...prevForm,
|
|
190
|
+
tireSize: { ...prevForm["tireSize"], value: vehicle.tireSize },
|
|
191
|
+
}));
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
Logger.info(form);
|
|
148
195
|
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
const toggleShowLinkedDocument = (docType: DocumentType | null) => {
|
|
199
|
+
setShowLinkedDocument(!isShowLinkedDocument);
|
|
200
|
+
if (docType && invoiceInputRef.current) {
|
|
201
|
+
docTypeCurrent.current = docType;
|
|
202
|
+
invoiceInputRef.current.click();
|
|
203
|
+
} else {
|
|
204
|
+
docTypeCurrent.current = undefined;
|
|
152
205
|
}
|
|
206
|
+
};
|
|
153
207
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
208
|
+
const isVehicleTireSizeDefined = (vehicle: Vehicle) => {
|
|
209
|
+
return (
|
|
210
|
+
vehicle.tireSize &&
|
|
211
|
+
vehicle.tireSize.diameter &&
|
|
212
|
+
vehicle.tireSize.height &&
|
|
213
|
+
vehicle.tireSize.speedIndex &&
|
|
214
|
+
vehicle.tireSize.width
|
|
215
|
+
);
|
|
216
|
+
};
|
|
157
217
|
|
|
158
|
-
|
|
159
|
-
}
|
|
218
|
+
const validateForm = () => {
|
|
219
|
+
let newForm: MovaVehicleForm = { ...form };
|
|
160
220
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
setSizeLimit(true);
|
|
165
|
-
return;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
if (vehicle && document && documentType)
|
|
169
|
-
{
|
|
170
|
-
|
|
171
|
-
// Utilisation d'un formData pour permettre le trasnfert de fichier vers l'API
|
|
172
|
-
let formData = new FormData();
|
|
173
|
-
formData.append("documentType", documentType);
|
|
174
|
-
// Ajouter la facture à FormData
|
|
175
|
-
formData.append('file', document);
|
|
176
|
-
|
|
177
|
-
// Appel du callback correspondant
|
|
178
|
-
if (onUploadDocument)
|
|
179
|
-
onUploadDocument(formData);
|
|
180
|
-
}
|
|
181
|
-
}
|
|
221
|
+
// Validator pour les champs obligatoires
|
|
222
|
+
// newForm.currentMileage = validateField(form.currentMileage, value => !!value, 'Champ obligatoire');
|
|
223
|
+
// newForm.averageMileagePerYear = validateField(form.averageMileagePerYear, value => !!value, 'Champ obligatoire');
|
|
182
224
|
|
|
183
|
-
|
|
184
|
-
*
|
|
185
|
-
* @param event L'upload des documents se fait directement lors du téléchargement
|
|
186
|
-
* @param docType
|
|
187
|
-
*/
|
|
188
|
-
const handleFileChange = (event: React.ChangeEvent<HTMLInputElement>, docType: DocumentType) => {
|
|
189
|
-
event.preventDefault();
|
|
225
|
+
// La validation de la saisie des pneumatiques se fait dans le composant "MovaVehicleTireField", traitée dans le callback "handleOnChangeVehicleTire"
|
|
190
226
|
|
|
191
|
-
|
|
192
|
-
{
|
|
193
|
-
uploadVehicleDocument(event.target.files[0], docType);
|
|
194
|
-
}
|
|
227
|
+
setForm(newForm);
|
|
195
228
|
|
|
229
|
+
return (
|
|
230
|
+
newForm.currentMileage.isValid &&
|
|
231
|
+
newForm.averageMileagePerYear.isValid &&
|
|
232
|
+
newForm.tireSize.isValid
|
|
233
|
+
);
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
const handleInputChange = (
|
|
237
|
+
e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>
|
|
238
|
+
): void => {
|
|
239
|
+
handleChange(e.target.name, e.target.value);
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
const handleSelectChange = (e: SelectChangeEvent<string>): void => {
|
|
243
|
+
handleChange(e.target.name, e.target.value);
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
const handleChange = (fieldName: string, fieldValue: string): void => {
|
|
247
|
+
console.log(fieldName, fieldValue);
|
|
248
|
+
const newField: MovaFormField = {
|
|
249
|
+
[fieldName]: { value: fieldValue, isValid: true },
|
|
196
250
|
};
|
|
197
251
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
// On passe la fiche véhicule en mode édition
|
|
201
|
-
setLocalEditMode(true);
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
const handleOnChangeVehicleTire = (vehicleTire: VehicleTire, isValid: boolean) => {
|
|
205
|
-
setForm(prevForm => (
|
|
206
|
-
{ ...prevForm, ['tireSize']: { ...prevForm['tireSize'], value: vehicleTire, isValid: isValid } }));
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
const handleOnClickDeleteVehicle = (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => {
|
|
211
|
-
e.preventDefault();
|
|
212
|
-
setOpenConfirmVehicleDelete(true);
|
|
213
|
-
}
|
|
252
|
+
setForm({ ...form, ...newField });
|
|
253
|
+
};
|
|
214
254
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
255
|
+
const uploadVehicleDocument = (
|
|
256
|
+
document: File,
|
|
257
|
+
documentType: DocumentType
|
|
258
|
+
) => {
|
|
259
|
+
if (document.size > 10000000) {
|
|
260
|
+
setSizeLimit(true);
|
|
261
|
+
return;
|
|
219
262
|
}
|
|
220
263
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
let query = {
|
|
229
|
-
currentMileage: form.currentMileage.value,
|
|
230
|
-
averageMileagePerYear: form.averageMileagePerYear.value,
|
|
231
|
-
tireWidth: form.tireSize.isValid && form.tireSize.value ? (form.tireSize.value as VehicleTire).width : undefined,
|
|
232
|
-
tireHeight: form.tireSize.isValid && form.tireSize.value ? (form.tireSize.value as VehicleTire).height : undefined,
|
|
233
|
-
tireDiameter: form.tireSize.isValid && form.tireSize.value ? (form.tireSize.value as VehicleTire).diameter : 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,
|
|
237
|
-
}
|
|
238
|
-
Logger.info(query)
|
|
239
|
-
|
|
240
|
-
// Appel du callback correspondant
|
|
241
|
-
if (onUpdate)
|
|
242
|
-
onUpdate(form);
|
|
243
|
-
}
|
|
244
|
-
}
|
|
264
|
+
if (vehicle && document && documentType) {
|
|
265
|
+
// Utilisation d'un formData pour permettre le trasnfert de fichier vers l'API
|
|
266
|
+
let formData = new FormData();
|
|
267
|
+
formData.append("documentType", documentType);
|
|
268
|
+
// Ajouter la facture à FormData
|
|
269
|
+
formData.append("file", document);
|
|
245
270
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
setLocalEditMode(false);
|
|
271
|
+
// Appel du callback correspondant
|
|
272
|
+
if (onUploadDocument) onUploadDocument(formData);
|
|
249
273
|
}
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
*
|
|
278
|
+
* @param event L'upload des documents se fait directement lors du téléchargement
|
|
279
|
+
* @param docType
|
|
280
|
+
*/
|
|
281
|
+
const handleFileChange = (
|
|
282
|
+
event: React.ChangeEvent<HTMLInputElement>,
|
|
283
|
+
docType: DocumentType
|
|
284
|
+
) => {
|
|
285
|
+
event.preventDefault();
|
|
286
|
+
|
|
287
|
+
if (
|
|
288
|
+
event &&
|
|
289
|
+
event.target.files &&
|
|
290
|
+
event.target.files.length > 0 &&
|
|
291
|
+
docType
|
|
292
|
+
) {
|
|
293
|
+
uploadVehicleDocument(event.target.files[0], docType);
|
|
254
294
|
}
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
const handleOnClickEdit = () => {
|
|
298
|
+
// On passe la fiche véhicule en mode édition
|
|
299
|
+
setLocalEditMode(true);
|
|
300
|
+
};
|
|
301
|
+
|
|
302
|
+
const handleOnChangeVehicleTire = (
|
|
303
|
+
vehicleTire: VehicleTire,
|
|
304
|
+
isValid: boolean
|
|
305
|
+
) => {
|
|
306
|
+
setForm((prevForm) => ({
|
|
307
|
+
...prevForm,
|
|
308
|
+
tireSize: {
|
|
309
|
+
...prevForm["tireSize"],
|
|
310
|
+
value: vehicleTire,
|
|
311
|
+
isValid: isValid,
|
|
312
|
+
},
|
|
313
|
+
}));
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
const handleOnClickDeleteVehicle = (
|
|
317
|
+
e: React.MouseEvent<HTMLButtonElement, MouseEvent>
|
|
318
|
+
) => {
|
|
319
|
+
e.preventDefault();
|
|
320
|
+
setOpenConfirmVehicleDelete(true);
|
|
321
|
+
};
|
|
322
|
+
|
|
323
|
+
const handleDeleteDocument = (
|
|
324
|
+
e: React.MouseEvent<HTMLButtonElement, MouseEvent>,
|
|
325
|
+
documentId: string
|
|
326
|
+
) => {
|
|
327
|
+
e.preventDefault();
|
|
328
|
+
setDocumentToDelete(documentId);
|
|
329
|
+
setOpenConfirmDocumentDelete(true);
|
|
330
|
+
};
|
|
331
|
+
|
|
332
|
+
const handleOnClickValidate = () => {
|
|
333
|
+
if (validateForm()) {
|
|
334
|
+
Logger.info(form.tireSize.value);
|
|
335
|
+
|
|
336
|
+
let query = {
|
|
337
|
+
currentMileage: form.currentMileage.value,
|
|
338
|
+
averageMileagePerYear: form.averageMileagePerYear.value,
|
|
339
|
+
tireWidth:
|
|
340
|
+
form.tireSize.isValid && form.tireSize.value
|
|
341
|
+
? (form.tireSize.value as VehicleTire).width
|
|
342
|
+
: undefined,
|
|
343
|
+
tireHeight:
|
|
344
|
+
form.tireSize.isValid && form.tireSize.value
|
|
345
|
+
? (form.tireSize.value as VehicleTire).height
|
|
346
|
+
: undefined,
|
|
347
|
+
tireDiameter:
|
|
348
|
+
form.tireSize.isValid && form.tireSize.value
|
|
349
|
+
? (form.tireSize.value as VehicleTire).diameter
|
|
350
|
+
: undefined,
|
|
351
|
+
tireSpeedIndex:
|
|
352
|
+
form.tireSize.isValid && form.tireSize.value
|
|
353
|
+
? (form.tireSize.value as VehicleTire).speedIndex
|
|
354
|
+
: undefined,
|
|
355
|
+
lastInspectionDate: form.lastInspectionDate.value,
|
|
356
|
+
lastMaintenanceDate: form.lastMaintenanceDate.value,
|
|
357
|
+
};
|
|
358
|
+
Logger.info(query);
|
|
359
|
+
|
|
360
|
+
// Appel du callback correspondant
|
|
361
|
+
if (onUpdate) onUpdate(form);
|
|
258
362
|
}
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
363
|
+
};
|
|
364
|
+
|
|
365
|
+
const handleOnClickCancel = () => {
|
|
366
|
+
initForm();
|
|
367
|
+
setLocalEditMode(false);
|
|
368
|
+
};
|
|
369
|
+
|
|
370
|
+
const handleCloseConfirmDocumentDelete = () => {
|
|
371
|
+
setOpenConfirmDocumentDelete(false);
|
|
372
|
+
setDocumentToDelete("");
|
|
373
|
+
};
|
|
374
|
+
|
|
375
|
+
const handleCloseConfirmVehicleDelete = () => {
|
|
376
|
+
setOpenConfirmVehicleDelete(false);
|
|
377
|
+
};
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
*
|
|
381
|
+
*/
|
|
382
|
+
const handleConfirmDocumentDelete = () => {
|
|
383
|
+
setOpenConfirmDocumentDelete(false);
|
|
384
|
+
|
|
385
|
+
if (vehicle && documentToDelete) {
|
|
386
|
+
// Appel du callback correspondant
|
|
387
|
+
if (onDeleteDocument) onDeleteDocument(documentToDelete);
|
|
273
388
|
}
|
|
389
|
+
};
|
|
274
390
|
|
|
275
|
-
|
|
276
|
-
|
|
391
|
+
const handleConfirmVehicleDelete = () => {
|
|
392
|
+
setOpenConfirmVehicleDelete(false);
|
|
277
393
|
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
// Appel du callback correspondant
|
|
282
|
-
onDelete();
|
|
283
|
-
}
|
|
394
|
+
if (vehicle && onDelete) {
|
|
395
|
+
// Appel du callback correspondant
|
|
396
|
+
onDelete();
|
|
284
397
|
}
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
398
|
+
};
|
|
399
|
+
|
|
400
|
+
return (
|
|
401
|
+
<>
|
|
402
|
+
{vehicle && (
|
|
403
|
+
<Card
|
|
404
|
+
variant="outlined"
|
|
405
|
+
sx={{
|
|
406
|
+
maxWidth: fullwidth ? "80%" : 500,
|
|
407
|
+
backgroundColor: focused ? theme.palette.primary.light : "white",
|
|
408
|
+
overflow: "visible",
|
|
409
|
+
mt: 4,
|
|
410
|
+
pb: 1,
|
|
411
|
+
}}
|
|
412
|
+
>
|
|
413
|
+
<CardContent sx={{ pt: 0, pb: 0 }}>
|
|
414
|
+
<Typography
|
|
415
|
+
variant="h6"
|
|
416
|
+
component="div"
|
|
417
|
+
align="center"
|
|
418
|
+
sx={{ mb: 1 }}
|
|
419
|
+
color={darken(theme.palette.primary.main, 0.2)}
|
|
420
|
+
>
|
|
421
|
+
{vehicle.brand && `${vehicle.brand} `}
|
|
422
|
+
{vehicle.model && `${vehicle.model} `}
|
|
423
|
+
{vehicle.version && `${vehicle.version}`}
|
|
424
|
+
</Typography>
|
|
425
|
+
<Grid container justifyContent="space-between">
|
|
426
|
+
<Grid
|
|
427
|
+
container
|
|
428
|
+
sx={{ mb: 1, alignItems: "center", justifyContent: "center" }}
|
|
429
|
+
>
|
|
430
|
+
<Grid
|
|
431
|
+
item
|
|
432
|
+
xs={6}
|
|
433
|
+
sx={{ position: "relative", minWidth: "234px" }}
|
|
294
434
|
>
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
435
|
+
<img
|
|
436
|
+
src={CatPlateBg}
|
|
437
|
+
alt="Plaque d'immatriculation"
|
|
438
|
+
style={{ height: "50px", position: "relative" }}
|
|
439
|
+
/>
|
|
440
|
+
<Typography
|
|
441
|
+
variant="h6"
|
|
442
|
+
color={theme.palette.text.primary}
|
|
443
|
+
sx={{ position: "absolute", top: "8px", left: "76px" }}
|
|
444
|
+
>
|
|
445
|
+
<b>{formatFrenchVehiclePlate(vehicle.plate)}</b>
|
|
446
|
+
</Typography>
|
|
447
|
+
</Grid>
|
|
448
|
+
{onDelete && (
|
|
449
|
+
<Grid
|
|
450
|
+
item
|
|
451
|
+
xs={6}
|
|
452
|
+
style={{
|
|
453
|
+
display: "flex",
|
|
454
|
+
alignItems: "center",
|
|
455
|
+
justifyContent: "center",
|
|
456
|
+
}}
|
|
457
|
+
>
|
|
458
|
+
<Button
|
|
459
|
+
variant="contained"
|
|
460
|
+
color="error"
|
|
461
|
+
onClick={(e) => handleOnClickDeleteVehicle(e)}
|
|
462
|
+
>
|
|
463
|
+
Supprimer
|
|
464
|
+
</Button>
|
|
465
|
+
</Grid>
|
|
466
|
+
)}
|
|
467
|
+
</Grid>
|
|
468
|
+
|
|
469
|
+
{!localEditMode && (
|
|
470
|
+
<Grid container textAlign="justify" sx={{ pt: 2 }}>
|
|
471
|
+
<Grid item xs={8}>
|
|
472
|
+
<Typography variant="body1" color="text.secondary">
|
|
473
|
+
Km actuel :
|
|
474
|
+
</Typography>
|
|
475
|
+
</Grid>
|
|
476
|
+
<Grid item xs={4} sx={{ textAlign: "right" }}>
|
|
477
|
+
<Typography variant="body1" color="text.secondary">
|
|
478
|
+
<b>{vehicle.currentMileage} km</b>
|
|
479
|
+
</Typography>
|
|
480
|
+
</Grid>
|
|
481
|
+
</Grid>
|
|
482
|
+
)}
|
|
483
|
+
|
|
484
|
+
{localEditMode && (
|
|
485
|
+
<Grid item xs={12}>
|
|
486
|
+
<TextField
|
|
487
|
+
label="Kilométrage actuel"
|
|
488
|
+
name="currentMileage"
|
|
489
|
+
variant="outlined"
|
|
490
|
+
type="number"
|
|
491
|
+
required
|
|
492
|
+
value={form.currentMileage.value}
|
|
493
|
+
onChange={(e) => handleInputChange(e)}
|
|
494
|
+
error={Boolean(form.currentMileage.error)}
|
|
495
|
+
sx={{
|
|
496
|
+
width: "100%",
|
|
497
|
+
mt: 2,
|
|
498
|
+
"& input": { textTransform: "uppercase" }, // CSS pour forcer les majuscules dans l'input
|
|
499
|
+
}}
|
|
500
|
+
helperText={
|
|
501
|
+
Boolean(
|
|
502
|
+
form.currentMileage.error &&
|
|
503
|
+
form.currentMileage.value > 0
|
|
504
|
+
)
|
|
505
|
+
? form.currentMileage.error
|
|
506
|
+
: "Sur votre tableau de bord 😉"
|
|
507
|
+
}
|
|
508
|
+
/>
|
|
509
|
+
</Grid>
|
|
510
|
+
)}
|
|
511
|
+
|
|
512
|
+
{!localEditMode && (
|
|
513
|
+
<Grid container textAlign="justify" sx={{ pt: 2 }}>
|
|
514
|
+
<Grid item xs={8}>
|
|
515
|
+
<Typography variant="body1" color="text.secondary">
|
|
516
|
+
Km moyen annuel :
|
|
517
|
+
</Typography>
|
|
518
|
+
</Grid>
|
|
519
|
+
<Grid item xs={4} sx={{ textAlign: "right" }}>
|
|
520
|
+
<Typography variant="body1" color="text.secondary">
|
|
521
|
+
<b>{vehicle.averageMileagePerYear} km</b>
|
|
522
|
+
</Typography>
|
|
523
|
+
</Grid>
|
|
524
|
+
</Grid>
|
|
525
|
+
)}
|
|
526
|
+
|
|
527
|
+
{localEditMode && (
|
|
528
|
+
<Grid item xs={12}>
|
|
529
|
+
<FormControl
|
|
530
|
+
fullWidth
|
|
531
|
+
margin="normal"
|
|
532
|
+
error={Boolean(form.averageMileagePerYear.error)}
|
|
533
|
+
>
|
|
534
|
+
<InputLabel id="averageMileagePerYear-label">
|
|
535
|
+
Kilométrage moyen annuel
|
|
536
|
+
</InputLabel>
|
|
537
|
+
<Select
|
|
538
|
+
labelId="averageMileagePerYear-label"
|
|
539
|
+
id="averageMileagePerYear"
|
|
540
|
+
name="averageMileagePerYear"
|
|
541
|
+
value={
|
|
542
|
+
form.averageMileagePerYear.value
|
|
543
|
+
? String(form.averageMileagePerYear.value)
|
|
544
|
+
: ""
|
|
545
|
+
}
|
|
546
|
+
onChange={(e) => handleSelectChange(e)}
|
|
547
|
+
label="Kilométrage moyen annuel"
|
|
548
|
+
>
|
|
549
|
+
<MenuItem value={5000}>5 000</MenuItem>
|
|
550
|
+
<MenuItem value={10000}>10 000</MenuItem>
|
|
551
|
+
<MenuItem value={15000}>15 000</MenuItem>
|
|
552
|
+
<MenuItem value={20000}>20 000</MenuItem>
|
|
553
|
+
<MenuItem value={25000}>25 000</MenuItem>
|
|
554
|
+
<MenuItem value={30000}>30 000</MenuItem>
|
|
555
|
+
<MenuItem value={50000}>50 000</MenuItem>
|
|
556
|
+
<MenuItem value={75000}>75 000</MenuItem>
|
|
557
|
+
<MenuItem value={100000}>100 000</MenuItem>
|
|
558
|
+
<MenuItem value={999999}>+100 000</MenuItem>
|
|
559
|
+
</Select>
|
|
560
|
+
<FormHelperText>
|
|
561
|
+
{form.averageMileagePerYear.error}
|
|
562
|
+
</FormHelperText>
|
|
563
|
+
</FormControl>
|
|
564
|
+
</Grid>
|
|
565
|
+
)}
|
|
566
|
+
|
|
567
|
+
{!localEditMode && (
|
|
568
|
+
<Grid container textAlign="justify" sx={{ pt: 2 }}>
|
|
569
|
+
<Grid item xs={6}>
|
|
570
|
+
<Typography variant="body1" color="text.secondary">
|
|
571
|
+
Pneumatiques :
|
|
572
|
+
</Typography>
|
|
573
|
+
</Grid>
|
|
574
|
+
<Grid item xs={6} sx={{ textAlign: "right" }}>
|
|
575
|
+
<Typography variant="body1" color="text.secondary">
|
|
576
|
+
{isVehicleTireSizeDefined(vehicle) ? (
|
|
577
|
+
<b>{formatVehicleTire(vehicle.tireSize)}</b>
|
|
578
|
+
) : (
|
|
579
|
+
"-"
|
|
580
|
+
)}
|
|
581
|
+
</Typography>
|
|
582
|
+
</Grid>
|
|
583
|
+
</Grid>
|
|
584
|
+
)}
|
|
585
|
+
|
|
586
|
+
{localEditMode && (
|
|
587
|
+
<Grid item xs={12} sx={{ mt: 1 }}>
|
|
588
|
+
<MovaVehicleTireField
|
|
589
|
+
vehicleTire={form.tireSize.value}
|
|
590
|
+
onChangeVehicleTire={handleOnChangeVehicleTire}
|
|
591
|
+
/>
|
|
592
|
+
</Grid>
|
|
593
|
+
)}
|
|
594
|
+
|
|
595
|
+
{!localEditMode && (
|
|
596
|
+
<Grid container textAlign="justify" sx={{ pt: 2 }}>
|
|
597
|
+
<Grid item xs={8}>
|
|
598
|
+
<Typography variant="body1" color="text.secondary">
|
|
599
|
+
Dernier contrôle technique :
|
|
600
|
+
</Typography>
|
|
601
|
+
</Grid>
|
|
602
|
+
<Grid item xs={4} sx={{ textAlign: "right" }}>
|
|
603
|
+
<Typography variant="body1" color="text.secondary">
|
|
604
|
+
<b>
|
|
605
|
+
{formatDateByTimezone(
|
|
606
|
+
vehicle.lastInspectionDate,
|
|
607
|
+
"Europe/Paris",
|
|
608
|
+
DateFormatTypes.SHORT_FORMAT_DATE
|
|
609
|
+
) !== ""
|
|
610
|
+
? formatDateByTimezone(
|
|
611
|
+
vehicle.lastInspectionDate,
|
|
612
|
+
"Europe/Paris",
|
|
613
|
+
DateFormatTypes.SHORT_FORMAT_DATE
|
|
614
|
+
)
|
|
615
|
+
: "-"}
|
|
616
|
+
</b>
|
|
617
|
+
</Typography>
|
|
618
|
+
</Grid>
|
|
619
|
+
</Grid>
|
|
620
|
+
)}
|
|
621
|
+
|
|
622
|
+
{localEditMode && (
|
|
623
|
+
<Grid item xs={12}>
|
|
624
|
+
<FormControl fullWidth sx={{ marginTop: 2 }}>
|
|
625
|
+
<DatePicker
|
|
626
|
+
label={"Dernier contrôle technique"}
|
|
627
|
+
name={"lastInspectionDate"}
|
|
628
|
+
value={form.lastInspectionDate.value}
|
|
629
|
+
format="dd/MM/yyyy"
|
|
630
|
+
formatDensity="dense"
|
|
631
|
+
views={["day"]}
|
|
632
|
+
displayWeekNumber
|
|
633
|
+
onChange={(e) => handleChange("lastInspectionDate", e)}
|
|
634
|
+
/>
|
|
635
|
+
</FormControl>
|
|
636
|
+
</Grid>
|
|
637
|
+
)}
|
|
638
|
+
|
|
639
|
+
{!localEditMode && (
|
|
640
|
+
<Grid container textAlign="justify" sx={{ pt: 2 }}>
|
|
641
|
+
<Grid item xs={8}>
|
|
642
|
+
<Typography variant="body1" color="text.secondary">
|
|
643
|
+
Dernier entretien :
|
|
644
|
+
</Typography>
|
|
645
|
+
</Grid>
|
|
646
|
+
<Grid item xs={4} sx={{ textAlign: "right" }}>
|
|
647
|
+
<Typography variant="body1" color="text.secondary">
|
|
648
|
+
<b>
|
|
649
|
+
{formatDateByTimezone(
|
|
650
|
+
vehicle.lastMaintenanceDate,
|
|
651
|
+
"Europe/Paris",
|
|
652
|
+
DateFormatTypes.SHORT_FORMAT_DATE
|
|
653
|
+
) !== ""
|
|
654
|
+
? formatDateByTimezone(
|
|
655
|
+
vehicle.lastMaintenanceDate,
|
|
656
|
+
"Europe/Paris",
|
|
657
|
+
DateFormatTypes.SHORT_FORMAT_DATE
|
|
658
|
+
)
|
|
659
|
+
: "-"}
|
|
660
|
+
</b>
|
|
661
|
+
</Typography>
|
|
662
|
+
</Grid>
|
|
663
|
+
</Grid>
|
|
664
|
+
)}
|
|
665
|
+
|
|
666
|
+
{localEditMode && (
|
|
667
|
+
<Grid item xs={12}>
|
|
668
|
+
<FormControl fullWidth sx={{ marginTop: 2 }}>
|
|
669
|
+
<DatePicker
|
|
670
|
+
label={"Dernier entretien"}
|
|
671
|
+
name={"lastMaintenanceDate"}
|
|
672
|
+
value={form.lastMaintenanceDate.value}
|
|
673
|
+
format="dd/MM/yyyy"
|
|
674
|
+
formatDensity="dense"
|
|
675
|
+
views={["day"]}
|
|
676
|
+
displayWeekNumber
|
|
677
|
+
onChange={(e) => handleChange("lastMaintenanceDate", e)}
|
|
678
|
+
/>
|
|
679
|
+
</FormControl>
|
|
680
|
+
</Grid>
|
|
681
|
+
)}
|
|
682
|
+
</Grid>
|
|
683
|
+
|
|
684
|
+
{!localEditMode && (
|
|
685
|
+
<>
|
|
686
|
+
<Grid item xs={12}>
|
|
687
|
+
<Typography
|
|
688
|
+
variant="h6"
|
|
689
|
+
component="div"
|
|
690
|
+
align="center"
|
|
691
|
+
sx={{ mt: 3, mb: 1 }}
|
|
692
|
+
color={darken(theme.palette.primary.main, 0.2)}
|
|
693
|
+
>
|
|
694
|
+
CARNET DU VÉHICULE
|
|
695
|
+
</Typography>
|
|
696
|
+
</Grid>
|
|
697
|
+
|
|
698
|
+
{vehicle.documents &&
|
|
699
|
+
vehicle.documents?.map((invoice, index) => (
|
|
700
|
+
<Grid
|
|
701
|
+
container
|
|
702
|
+
sx={{
|
|
703
|
+
justifyContent: "space-between",
|
|
704
|
+
alignItems: "center",
|
|
705
|
+
}}
|
|
706
|
+
key={index + 1}
|
|
707
|
+
>
|
|
708
|
+
<Grid
|
|
709
|
+
item
|
|
710
|
+
xs={11}
|
|
711
|
+
key={(index + 1) * 50}
|
|
712
|
+
sx={{ textAlign: "left" }}
|
|
713
|
+
>
|
|
714
|
+
<Tooltip title={invoice.originalFileName}>
|
|
715
|
+
<Link
|
|
716
|
+
color={darken("#F29ABA", 0.2)}
|
|
717
|
+
href={invoice.fileSignedUrl}
|
|
718
|
+
target="_blank"
|
|
719
|
+
rel="noopener"
|
|
720
|
+
>
|
|
721
|
+
<Typography variant="body1">
|
|
722
|
+
{invoice.fileName}
|
|
723
|
+
</Typography>
|
|
724
|
+
</Link>
|
|
725
|
+
</Tooltip>
|
|
726
|
+
</Grid>
|
|
727
|
+
<Grid
|
|
728
|
+
item
|
|
729
|
+
xs={1}
|
|
730
|
+
key={(index + 1) * 100}
|
|
731
|
+
sx={{ textAlign: "right" }}
|
|
732
|
+
>
|
|
733
|
+
<IconButton
|
|
734
|
+
disabled={
|
|
735
|
+
!(invoice.ownerId.toString() == currentUser.id)
|
|
736
|
+
}
|
|
737
|
+
onClick={(e) => handleDeleteDocument(e, invoice?.id)}
|
|
738
|
+
>
|
|
739
|
+
<CloseIcon />
|
|
740
|
+
</IconButton>
|
|
741
|
+
</Grid>
|
|
742
|
+
</Grid>
|
|
743
|
+
))}
|
|
744
|
+
|
|
745
|
+
{/* * Les FACTURES du véhicule
|
|
506
746
|
{vehicle.documents && vehicle.documents?.filter(doc => doc.type === DocumentType.VEHICLE_MAINTENANCE_INVOICE)
|
|
507
747
|
.map((invoice, index) => (
|
|
508
748
|
<Grid container sx={{ justifyContent: 'space-between', alignItems: 'center' }} key={index+1}>
|
|
@@ -539,89 +779,137 @@ const VehicleFullCard: FC<VehicleFullCardProps> = ({ vehicle, fullwidth, onError
|
|
|
539
779
|
</Grid>
|
|
540
780
|
))} */}
|
|
541
781
|
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
<Button size='large' disabled={currentUpload} onClick={() => setShowLinkedDocument(true)} component="span" variant="outlined" startIcon={<AttachFile />}
|
|
554
|
-
sx={{ alignItems: 'center', width: '90%', mt: 2, mb: 1, height: '50px', p: 1, color: darken(theme.palette.primary.main, 0.2) }}>
|
|
555
|
-
|
|
556
|
-
Ajouter un document
|
|
557
|
-
|
|
558
|
-
</Button>
|
|
559
|
-
{currentUpload && <Typography variant='body2' sx={{ animation: 'blink 1.5s infinite' }}>
|
|
560
|
-
Document en cours d'importation...
|
|
561
|
-
</Typography>}
|
|
562
|
-
{sizeLimit && <Typography
|
|
563
|
-
variant='body1'
|
|
564
|
-
sx={{ animation: 'blink 1.5s infinite' }}
|
|
565
|
-
color={theme.palette.warning.dark}
|
|
566
|
-
>Echec de l'importation car la taille du fichier dépasse 10Mo</Typography>}
|
|
567
|
-
{!sizeLimit && <Typography variant='body2'>
|
|
568
|
-
Taille maximale du fichier : 10Mo
|
|
569
|
-
</Typography>}
|
|
570
|
-
</div>
|
|
571
|
-
</Grid>
|
|
572
|
-
</Grid>
|
|
573
|
-
</>
|
|
574
|
-
}
|
|
575
|
-
|
|
576
|
-
</CardContent>
|
|
577
|
-
|
|
578
|
-
<CardActions sx={{ mt: 3, justifyContent: localEditMode ? 'center' : 'end' }}>
|
|
579
|
-
{!localEditMode &&
|
|
580
|
-
<>
|
|
581
|
-
<Button onClick={handleOnClickEdit} color="inherit" sx={{ width: '45%' }} variant='text'>
|
|
582
|
-
<EditIcon sx={{ mr: 1 }} />MODIFIER
|
|
583
|
-
</Button>
|
|
584
|
-
</>
|
|
782
|
+
<Grid container>
|
|
783
|
+
<Grid item xs={12} sx={{ mt: 2, textAlign: "center" }}>
|
|
784
|
+
<div>
|
|
785
|
+
<input
|
|
786
|
+
accept="image/*, application/pdf"
|
|
787
|
+
type="file"
|
|
788
|
+
style={{ display: "none" }}
|
|
789
|
+
ref={invoiceInputRef}
|
|
790
|
+
id="raised-button-invoice"
|
|
791
|
+
onChange={(e) =>
|
|
792
|
+
handleFileChange(e, docTypeCurrent.current!)
|
|
585
793
|
}
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
794
|
+
/>
|
|
795
|
+
<Button
|
|
796
|
+
size="large"
|
|
797
|
+
disabled={currentUpload}
|
|
798
|
+
onClick={() => setShowLinkedDocument(true)}
|
|
799
|
+
component="span"
|
|
800
|
+
variant="outlined"
|
|
801
|
+
startIcon={<AttachFile />}
|
|
802
|
+
sx={{
|
|
803
|
+
alignItems: "center",
|
|
804
|
+
width: "90%",
|
|
805
|
+
mt: 2,
|
|
806
|
+
mb: 1,
|
|
807
|
+
height: "50px",
|
|
808
|
+
p: 1,
|
|
809
|
+
color: darken(theme.palette.primary.main, 0.2),
|
|
810
|
+
}}
|
|
811
|
+
>
|
|
812
|
+
Ajouter un document
|
|
813
|
+
</Button>
|
|
814
|
+
{currentUpload && (
|
|
815
|
+
<Typography
|
|
816
|
+
variant="body2"
|
|
817
|
+
sx={{ animation: "blink 1.5s infinite" }}
|
|
818
|
+
>
|
|
819
|
+
Document en cours d'importation...
|
|
820
|
+
</Typography>
|
|
821
|
+
)}
|
|
822
|
+
{sizeLimit && (
|
|
823
|
+
<Typography
|
|
824
|
+
variant="body1"
|
|
825
|
+
sx={{ animation: "blink 1.5s infinite" }}
|
|
826
|
+
color={theme.palette.warning.dark}
|
|
827
|
+
>
|
|
828
|
+
Echec de l'importation car la taille du fichier
|
|
829
|
+
dépasse 10Mo
|
|
830
|
+
</Typography>
|
|
831
|
+
)}
|
|
832
|
+
{!sizeLimit && (
|
|
833
|
+
<Typography variant="body2">
|
|
834
|
+
Taille maximale du fichier : 10Mo
|
|
835
|
+
</Typography>
|
|
836
|
+
)}
|
|
837
|
+
</div>
|
|
838
|
+
</Grid>
|
|
839
|
+
</Grid>
|
|
840
|
+
</>
|
|
841
|
+
)}
|
|
842
|
+
</CardContent>
|
|
843
|
+
|
|
844
|
+
<CardActions
|
|
845
|
+
sx={{ mt: 3, justifyContent: localEditMode ? "center" : "end" }}
|
|
846
|
+
>
|
|
847
|
+
{!localEditMode && (
|
|
848
|
+
<>
|
|
849
|
+
<Button
|
|
850
|
+
onClick={handleOnClickEdit}
|
|
851
|
+
color="inherit"
|
|
852
|
+
sx={{ width: "45%" }}
|
|
853
|
+
variant="text"
|
|
854
|
+
>
|
|
855
|
+
<EditIcon sx={{ mr: 1 }} />
|
|
856
|
+
MODIFIER
|
|
857
|
+
</Button>
|
|
858
|
+
</>
|
|
859
|
+
)}
|
|
860
|
+
|
|
861
|
+
{localEditMode && (
|
|
862
|
+
<>
|
|
863
|
+
<Button
|
|
864
|
+
onClick={handleOnClickCancel}
|
|
865
|
+
sx={{ width: "45%", color: theme.palette.text.secondary }}
|
|
866
|
+
variant="text"
|
|
867
|
+
>
|
|
868
|
+
<CancelIcon sx={{ mr: 1 }} />
|
|
869
|
+
ANNULER
|
|
870
|
+
</Button>
|
|
871
|
+
|
|
872
|
+
<Button
|
|
873
|
+
onClick={handleOnClickValidate}
|
|
874
|
+
sx={{
|
|
875
|
+
width: "45%",
|
|
876
|
+
color: darken(theme.palette.primary.main, 0.2),
|
|
877
|
+
}}
|
|
878
|
+
variant="text"
|
|
879
|
+
>
|
|
880
|
+
<EditIcon sx={{ mr: 1 }} />
|
|
881
|
+
VALIDER
|
|
882
|
+
</Button>
|
|
883
|
+
</>
|
|
884
|
+
)}
|
|
885
|
+
</CardActions>
|
|
886
|
+
</Card>
|
|
887
|
+
)}
|
|
888
|
+
{isShowLinkedDocument && (
|
|
889
|
+
<LinkedDocumentDialog
|
|
890
|
+
isVehicle={true}
|
|
891
|
+
isShowLinkedDocument={isShowLinkedDocument}
|
|
892
|
+
appType={appType}
|
|
893
|
+
toggleShowLinkedDocument={toggleShowLinkedDocument}
|
|
894
|
+
message={messageRGPD}
|
|
895
|
+
/>
|
|
896
|
+
)}
|
|
897
|
+
|
|
898
|
+
<ConfirmationDialog
|
|
899
|
+
open={openConfirmDocumentDelete}
|
|
900
|
+
onClose={handleCloseConfirmDocumentDelete}
|
|
901
|
+
onConfirm={handleConfirmDocumentDelete}
|
|
902
|
+
message="Êtes-vous sûr de vouloir supprimer ce document ?"
|
|
903
|
+
/>
|
|
904
|
+
|
|
905
|
+
<ConfirmationDialog
|
|
906
|
+
open={openConfirmVehicleDelete}
|
|
907
|
+
onClose={handleCloseConfirmVehicleDelete}
|
|
908
|
+
onConfirm={handleConfirmVehicleDelete}
|
|
909
|
+
message="Êtes-vous sûr de vouloir supprimer ce véhicule ?"
|
|
910
|
+
/>
|
|
911
|
+
</>
|
|
912
|
+
);
|
|
913
|
+
};
|
|
626
914
|
|
|
627
915
|
export default VehicleFullCard;
|