@movalib/movalib-commons 1.0.59 → 1.0.61
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/index.d.ts +5 -2
- package/dist/index.js +12 -1
- package/dist/src/MovaDigitalPassport.d.ts +7 -0
- package/dist/src/MovaDigitalPassport.js +36 -0
- package/dist/src/VehicleFullCard.d.ts +24 -0
- package/dist/src/VehicleFullCard.js +228 -0
- package/dist/src/assets/images/speedometer_green.png +0 -0
- package/dist/src/assets/images/speedometer_orange.png +0 -0
- package/dist/src/assets/images/speedometer_red.png +0 -0
- package/dist/src/helpers/DateUtils.d.ts +4 -0
- package/dist/src/helpers/DateUtils.js +53 -0
- package/dist/src/helpers/Enums.d.ts +5 -0
- package/dist/src/helpers/Enums.js +7 -1
- package/dist/src/helpers/Logger.d.ts +8 -0
- package/dist/src/helpers/Logger.js +44 -0
- package/dist/src/helpers/Tools.d.ts +1 -0
- package/dist/src/helpers/Tools.js +17 -1
- package/dist/src/models/Event.d.ts +5 -5
- package/dist/src/models/Event.js +8 -5
- package/index.ts +5 -2
- package/package.json +4 -2
- package/src/MovaDigitalPassport.tsx +47 -0
- package/src/VehicleFullCard.tsx +509 -0
- package/src/assets/images/speedometer_green.png +0 -0
- package/src/assets/images/speedometer_orange.png +0 -0
- package/src/assets/images/speedometer_red.png +0 -0
- package/src/helpers/DateUtils.ts +63 -0
- package/src/helpers/Enums.ts +7 -0
- package/src/helpers/Logger.ts +28 -0
- package/src/helpers/Tools.ts +19 -0
- package/src/models/Event.ts +12 -8
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { format, utcToZonedTime } from 'date-fns-tz';
|
|
2
|
+
import { fr } from 'date-fns/locale';
|
|
3
|
+
import { DateFormatTypes } from './Enums';
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
export const formatDateByCountryCode = (date: Date | undefined, countryCode: string, formatType: DateFormatTypes): string => {
|
|
7
|
+
|
|
8
|
+
if(date){
|
|
9
|
+
// Tableau de correspondance entre les codes de pays et les fuseaux horaires
|
|
10
|
+
const countryTimeZones: { [key: string]: string } = {
|
|
11
|
+
'FR': 'Europe/Paris',
|
|
12
|
+
// Ajoutez d'autres correspondances de codes de pays et de fuseaux horaires ici
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const timeZone = countryTimeZones[countryCode.toUpperCase()];
|
|
16
|
+
|
|
17
|
+
if (!timeZone) {
|
|
18
|
+
throw new Error('Code de pays non pris en charge');
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Convertir la date UTC en date du fuseau horaire local
|
|
22
|
+
const zonedDate = utcToZonedTime(date, timeZone);
|
|
23
|
+
|
|
24
|
+
// Formater la date
|
|
25
|
+
switch(formatType){
|
|
26
|
+
|
|
27
|
+
case DateFormatTypes.SHORT_FORMAT_DATE:
|
|
28
|
+
case DateFormatTypes.LONG_FORMAT_DATETIME:
|
|
29
|
+
return format(zonedDate, formatType, { timeZone, locale: fr });
|
|
30
|
+
|
|
31
|
+
case DateFormatTypes.LONG_FORMAT_DATETIME_LITERAL:
|
|
32
|
+
return getLongFormattedDateTime(zonedDate, timeZone, fr);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return format(zonedDate, formatType, { timeZone, locale: fr });
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return '';
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export function getLongFormattedDateTime(date: Date | undefined, timeZone: string, locale: Locale){
|
|
42
|
+
if(date){
|
|
43
|
+
const day = capitalizeFirstLetter(format(date, 'eeee', { timeZone, locale: locale }));
|
|
44
|
+
const month = capitalizeFirstLetter(format(date, 'MMMM', { timeZone, locale: locale }));
|
|
45
|
+
const hours = format(date, 'HH', { timeZone, locale: locale });
|
|
46
|
+
const minutes = format(date, 'mm', { timeZone, locale: locale });
|
|
47
|
+
const dayOfMonth = format(date, 'dd', { timeZone, locale });
|
|
48
|
+
|
|
49
|
+
return `${day} ${dayOfMonth} ${month} à ${hours}:${minutes}`;
|
|
50
|
+
}
|
|
51
|
+
return '';
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function capitalizeFirstLetter(str: string): string {
|
|
55
|
+
if (str.length === 0) {
|
|
56
|
+
return str;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const firstChar = str.charAt(0).toUpperCase();
|
|
60
|
+
const restOfString = str.slice(1);
|
|
61
|
+
|
|
62
|
+
return firstChar + restOfString;
|
|
63
|
+
}
|
package/src/helpers/Enums.ts
CHANGED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
class Logger {
|
|
2
|
+
|
|
3
|
+
static isEnabled(): boolean {
|
|
4
|
+
return localStorage.getItem('modeDebug') === 'true';
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
static enableLogging() {
|
|
8
|
+
localStorage.setItem('modeDebug', 'true');
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
static disableLogging() {
|
|
12
|
+
localStorage.removeItem('modeDebug');
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
static info(...args: any[]) {
|
|
16
|
+
if (Logger.isEnabled()) {
|
|
17
|
+
console.info('INFO:', ...args);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
static error(...args: any[]) {
|
|
22
|
+
if (Logger.isEnabled()) {
|
|
23
|
+
console.error('ERROR:', ...args);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default Logger;
|
package/src/helpers/Tools.ts
CHANGED
|
@@ -1,6 +1,25 @@
|
|
|
1
1
|
import VehicleTire from "../models/VehicleTire";
|
|
2
2
|
import { MovaFormField } from "./Types";
|
|
3
3
|
|
|
4
|
+
export const formatFrenchVehiclePlate = (input: string | undefined): string => {
|
|
5
|
+
if(input){
|
|
6
|
+
// Supprimer tous les caractères non alphanumériques
|
|
7
|
+
let cleanedInput = input.replace(/[^A-Z0-9]/gi, '').toUpperCase();
|
|
8
|
+
|
|
9
|
+
// Ajouter des tirets aux positions appropriées
|
|
10
|
+
if (cleanedInput.length >= 2) {
|
|
11
|
+
cleanedInput = `${cleanedInput.slice(0, 2)}-${cleanedInput.slice(2)}`;
|
|
12
|
+
}
|
|
13
|
+
if (cleanedInput.length >= 6) {
|
|
14
|
+
cleanedInput = `${cleanedInput.slice(0, 6)}-${cleanedInput.slice(6, 8)}`;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return cleanedInput;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return "";
|
|
21
|
+
};
|
|
22
|
+
|
|
4
23
|
export function formatVehicleTire(vehicleTire: VehicleTire){
|
|
5
24
|
if(vehicleTire){
|
|
6
25
|
let concatened = `${vehicleTire.width}${vehicleTire.height}${vehicleTire.diameter}${vehicleTire.speedIndex}`;
|
package/src/models/Event.ts
CHANGED
|
@@ -4,6 +4,7 @@ import Prestation from "./Prestation";
|
|
|
4
4
|
import Customer from "./Customer";
|
|
5
5
|
import Vehicle from "./Vehicle";
|
|
6
6
|
import { OriginReference } from "../helpers/Types";
|
|
7
|
+
import { channel } from "diagnostics_channel";
|
|
7
8
|
|
|
8
9
|
export default class Event {
|
|
9
10
|
|
|
@@ -14,8 +15,8 @@ export default class Event {
|
|
|
14
15
|
title: string;
|
|
15
16
|
garageName: string;
|
|
16
17
|
garageId: number;
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
start?: Date;
|
|
19
|
+
end?: Date;
|
|
19
20
|
state: EventState;
|
|
20
21
|
prestations?: Prestation[];
|
|
21
22
|
/**
|
|
@@ -41,9 +42,9 @@ export default class Event {
|
|
|
41
42
|
*/
|
|
42
43
|
originReferences?: OriginReference[];
|
|
43
44
|
|
|
44
|
-
constructor({ id, notes, ownerId, type, title, garageName, garageId, state,
|
|
45
|
+
constructor({ id, notes, ownerId, type, title, garageName, garageId, state, start, end, prestations, guestsId, vehicleId, quoteId, originReferences }
|
|
45
46
|
: { id: string; notes?: string; ownerId: number; type : EventType; title: string; garageName: string; garageId: number;
|
|
46
|
-
state: EventState;
|
|
47
|
+
state: EventState; start?: Date; end?: Date, prestations?: Prestation[],
|
|
47
48
|
guestsId?: string[], vehicleId?: number, quoteId?: number, originReferences?: OriginReference[]})
|
|
48
49
|
{
|
|
49
50
|
this.id = id;
|
|
@@ -54,8 +55,8 @@ export default class Event {
|
|
|
54
55
|
this.garageName = garageName;
|
|
55
56
|
this.garageId = garageId;
|
|
56
57
|
this.state = state;
|
|
57
|
-
this.
|
|
58
|
-
this.
|
|
58
|
+
this.start = start ? new Date(start) : undefined;
|
|
59
|
+
this.end = end ? new Date(end) : undefined;
|
|
59
60
|
this.prestations = prestations;
|
|
60
61
|
this.guestsId = guestsId;
|
|
61
62
|
this.vehicleId = vehicleId;
|
|
@@ -67,8 +68,11 @@ export default class Event {
|
|
|
67
68
|
let list:string = '';
|
|
68
69
|
|
|
69
70
|
if(event.originReferences && event.originReferences.length !== 0){
|
|
70
|
-
event.originReferences?.forEach(reference => {
|
|
71
|
-
|
|
71
|
+
event.originReferences?.forEach((reference, index) => {
|
|
72
|
+
if(index > 0){
|
|
73
|
+
list += " / ";
|
|
74
|
+
}
|
|
75
|
+
list += `${reference.key} : ${reference.value}`;
|
|
72
76
|
})
|
|
73
77
|
}
|
|
74
78
|
return list;
|