@movalib/movalib-commons 1.0.72 → 1.0.74
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/devIndex.tsx +1 -6
- package/dist/devIndex.js +1 -4
- package/dist/index.d.ts +2 -1
- package/dist/index.js +4 -2
- package/dist/src/AddressFields.d.ts +16 -0
- package/dist/src/AddressFields.js +20 -0
- package/dist/src/helpers/ApiHelper.js +1 -2
- package/dist/src/helpers/DateUtils.d.ts +4 -0
- package/dist/src/helpers/DateUtils.js +19 -9
- package/dist/src/helpers/Types.d.ts +1 -0
- package/dist/src/models/Garage.d.ts +2 -1
- package/dist/src/models/Garage.js +2 -1
- package/index.ts +2 -3
- package/package.json +1 -1
- package/src/AddressFields.tsx +68 -0
- package/src/ScheduleFields.tsx +1 -0
- package/src/helpers/ApiHelper.ts +1 -1
- package/src/helpers/DateUtils.ts +20 -7
- package/src/helpers/Types.ts +3 -0
- package/src/models/Garage.ts +3 -0
- package/webpack.config.js +2 -2
package/devIndex.tsx
CHANGED
|
@@ -23,18 +23,13 @@ import { flexCenter } from './src/helpers/Tools';
|
|
|
23
23
|
|
|
24
24
|
const App = () => {
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
if (process.env.NODE_ENV !== 'production' || localStorage.getItem('debugMode') === 'true') {
|
|
28
|
-
Logger.enableLogging();
|
|
29
|
-
}
|
|
26
|
+
Logger.enableLogging();
|
|
30
27
|
|
|
31
28
|
// Chargement de données garage de test
|
|
32
29
|
const [garage, setGarage] = useState<Garage>();
|
|
33
30
|
|
|
34
31
|
useEffect(() => {
|
|
35
|
-
|
|
36
32
|
refreshGarageData();
|
|
37
|
-
|
|
38
33
|
}, []);
|
|
39
34
|
|
|
40
35
|
|
package/dist/devIndex.js
CHANGED
|
@@ -58,10 +58,7 @@ var ScheduleFields_1 = __importDefault(require("./src/ScheduleFields"));
|
|
|
58
58
|
var Schedule_1 = __importDefault(require("./src/models/Schedule"));
|
|
59
59
|
var Tools_1 = require("./src/helpers/Tools");
|
|
60
60
|
var App = function () {
|
|
61
|
-
|
|
62
|
-
if (process.env.NODE_ENV !== 'production' || localStorage.getItem('debugMode') === 'true') {
|
|
63
|
-
Logger_1.default.enableLogging();
|
|
64
|
-
}
|
|
61
|
+
Logger_1.default.enableLogging();
|
|
65
62
|
// Chargement de données garage de test
|
|
66
63
|
var _a = (0, react_1.useState)(), garage = _a[0], setGarage = _a[1];
|
|
67
64
|
(0, react_1.useEffect)(function () {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { default as AuthenticationService } from './src/services/AuthenticationService';
|
|
2
2
|
export { default as GarageService } from './src/services/GarageService';
|
|
3
3
|
export { default as UserService } from './src/services/UserService';
|
|
4
|
+
export { default as AddressFields } from './src/AddressFields';
|
|
4
5
|
export { default as ScheduleFields } from './src/ScheduleFields';
|
|
5
6
|
export { default as VehicleFullCard } from './src/VehicleFullCard';
|
|
6
7
|
export { default as MovaDigitalPassport } from './src/MovaDigitalPassport';
|
|
@@ -29,7 +30,7 @@ export { default as Event } from './src/models/Event';
|
|
|
29
30
|
export { default as VehicleTire } from './src/models/VehicleTire';
|
|
30
31
|
export type { APIRequest, APIResponse } from './src/helpers/ApiHelper';
|
|
31
32
|
export type { DaySchedule } from './src/ScheduleFields';
|
|
32
|
-
export type { MovaFormField, MovaLoginForm, MovaUserSignUpForm, MovaInterval, OriginReference, MovaVehicleForm } from './src/helpers/Types';
|
|
33
|
+
export type { MovaFormField, MovaLoginForm, MovaUserSignUpForm, MovaInterval, OriginReference, MovaVehicleForm, AddressFieldName } from './src/helpers/Types';
|
|
33
34
|
export { readCookie, deleteCookie } from './src/helpers/CookieUtils';
|
|
34
35
|
export { validateField, formatVehicleTire, formatFrenchVehiclePlate, isEmpty } from './src/helpers/Tools';
|
|
35
36
|
export { validatePhoneNumber, validateText, validateEmail } from './src/helpers/Validator';
|
package/dist/index.js
CHANGED
|
@@ -4,8 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
5
|
};
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.
|
|
8
|
-
exports.DateFormatTypes = void 0;
|
|
7
|
+
exports.DocumentState = exports.DigitalPassportIndex = exports.DocumentType = exports.EventType = exports.EventState = exports.DayOfWeek = exports.MovaAppType = exports.RoleType = exports.capitalizeFirstLetter = exports.getLongFormattedDateTime = exports.formatDateByCountryCode = exports.validateEmail = exports.validateText = exports.validatePhoneNumber = exports.isEmpty = exports.formatFrenchVehiclePlate = exports.formatVehicleTire = exports.validateField = exports.deleteCookie = exports.readCookie = exports.VehicleTire = exports.Event = exports.Schedule = exports.Garage = exports.Document = exports.Vehicle = exports.Address = exports.Role = exports.User = exports.Customer = exports.Logger = exports.GenderSelector = exports.ConfirmationDialog = exports.MovaVehicleTireField = exports.MovaCopyright = exports.MovaSignUp = exports.MovaLogin = exports.MovaSnackbar = exports.TestButton = exports.VehiclePlateField = exports.QRCode = exports.MovaDialog = exports.Loader = exports.MovaDigitalPassport = exports.VehicleFullCard = exports.ScheduleFields = exports.AddressFields = exports.UserService = exports.GarageService = exports.AuthenticationService = void 0;
|
|
8
|
+
exports.DateFormatTypes = exports.Gender = void 0;
|
|
9
9
|
// Export des services
|
|
10
10
|
var AuthenticationService_1 = require("./src/services/AuthenticationService");
|
|
11
11
|
Object.defineProperty(exports, "AuthenticationService", { enumerable: true, get: function () { return __importDefault(AuthenticationService_1).default; } });
|
|
@@ -14,6 +14,8 @@ Object.defineProperty(exports, "GarageService", { enumerable: true, get: functio
|
|
|
14
14
|
var UserService_1 = require("./src/services/UserService");
|
|
15
15
|
Object.defineProperty(exports, "UserService", { enumerable: true, get: function () { return __importDefault(UserService_1).default; } });
|
|
16
16
|
// Export des composants
|
|
17
|
+
var AddressFields_1 = require("./src/AddressFields");
|
|
18
|
+
Object.defineProperty(exports, "AddressFields", { enumerable: true, get: function () { return __importDefault(AddressFields_1).default; } });
|
|
17
19
|
var ScheduleFields_1 = require("./src/ScheduleFields");
|
|
18
20
|
Object.defineProperty(exports, "ScheduleFields", { enumerable: true, get: function () { return __importDefault(ScheduleFields_1).default; } });
|
|
19
21
|
var VehicleFullCard_1 = require("./src/VehicleFullCard");
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { FunctionComponent } from "react";
|
|
2
|
+
import { AddressFieldName, MovaFormField } from "./helpers/Types";
|
|
3
|
+
type Form = {
|
|
4
|
+
streetNumber: MovaFormField;
|
|
5
|
+
streetName: MovaFormField;
|
|
6
|
+
additional: MovaFormField;
|
|
7
|
+
postalCode: MovaFormField;
|
|
8
|
+
cityName: MovaFormField;
|
|
9
|
+
};
|
|
10
|
+
interface AddressFieldsProps {
|
|
11
|
+
form: Form;
|
|
12
|
+
size: 'small' | 'medium';
|
|
13
|
+
handleChange: (fieldName: AddressFieldName, newValue: any, save?: boolean) => void;
|
|
14
|
+
}
|
|
15
|
+
declare const AddressFields: FunctionComponent<AddressFieldsProps>;
|
|
16
|
+
export default AddressFields;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
15
|
+
var material_1 = require("@mui/material");
|
|
16
|
+
var AddressFields = function (_a) {
|
|
17
|
+
var form = _a.form, size = _a.size, handleChange = _a.handleChange;
|
|
18
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.Grid, __assign({ container: true }, { children: [(0, jsx_runtime_1.jsx)(material_1.TextField, { id: "address-streetName", label: "RUE", value: form.streetName.value, required: true, size: size, onBlur: function (e) { return handleChange('streetName', e.target.value, true); }, onChange: function (e) { return handleChange('streetName', e.target.value, false); }, sx: { width: '98%', mt: 2.5 } }), (0, jsx_runtime_1.jsx)(material_1.TextField, { id: "address-additionnalInfo", label: "COMPL\u00C9MENT", size: size, value: form.additional.value, onBlur: function (e) { return handleChange('additional', e.target.value, true); }, onChange: function (e) { return handleChange('additional', e.target.value, false); }, sx: { width: '98%', mt: 2.5 } }), (0, jsx_runtime_1.jsx)(material_1.TextField, { id: "address-postalCode", label: "CODE POSTAL", value: form.postalCode.value, required: true, size: size, onBlur: function (e) { return handleChange('postalCode', e.target.value, true); }, onChange: function (e) { return handleChange('postalCode', e.target.value, false); }, sx: { width: '40%', mt: 2.5, pr: 2 } }), (0, jsx_runtime_1.jsx)(material_1.TextField, { id: "address-cityName", label: "VILLE", value: form.cityName.value, required: true, size: size, onBlur: function (e) { return handleChange('cityName', e.target.value, true); }, onChange: function (e) { return handleChange('cityName', e.target.value, false); }, sx: { width: '55%', mt: 2.5 } })] })));
|
|
19
|
+
};
|
|
20
|
+
exports.default = AddressFields;
|
|
@@ -2,12 +2,11 @@
|
|
|
2
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
|
-
var _a;
|
|
6
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
6
|
exports.request = exports.API_BASE_URL = void 0;
|
|
8
7
|
var CookieUtils_1 = require("./CookieUtils");
|
|
9
8
|
var Logger_1 = __importDefault(require("./Logger"));
|
|
10
|
-
exports.API_BASE_URL =
|
|
9
|
+
exports.API_BASE_URL = process.env.REACT_APP_API_URL || 'https://localhost:8443/api';
|
|
11
10
|
function handleError(error) {
|
|
12
11
|
var msg = error.message.includes('fetch') ? "Connexion impossible" : error.message;
|
|
13
12
|
return {
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { DateFormatTypes } from './Enums';
|
|
2
|
+
export declare const countryTimeZones: {
|
|
3
|
+
[key: string]: string;
|
|
4
|
+
};
|
|
5
|
+
export declare const toUTCToLocaleDate: (date: "" | Date | null, countryCode: string) => Date;
|
|
2
6
|
export declare const formatDateByCountryCode: (date: Date | undefined, countryCode: string, formatType: DateFormatTypes) => string;
|
|
3
7
|
export declare function getLongFormattedDateTime(date: Date | undefined, timeZone: string, locale: Locale): string;
|
|
4
8
|
export declare function capitalizeFirstLetter(str: string): string;
|
|
@@ -1,22 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.capitalizeFirstLetter = exports.getLongFormattedDateTime = exports.formatDateByCountryCode = void 0;
|
|
3
|
+
exports.capitalizeFirstLetter = exports.getLongFormattedDateTime = exports.formatDateByCountryCode = exports.toUTCToLocaleDate = exports.countryTimeZones = void 0;
|
|
4
4
|
var date_fns_tz_1 = require("date-fns-tz");
|
|
5
5
|
var locale_1 = require("date-fns/locale");
|
|
6
6
|
var Enums_1 = require("./Enums");
|
|
7
|
-
|
|
7
|
+
// Tableau de correspondance entre les codes de pays et les fuseaux horaires
|
|
8
|
+
exports.countryTimeZones = {
|
|
9
|
+
'FR': 'Europe/Paris',
|
|
10
|
+
// Ajoutez d'autres correspondances de codes de pays et de fuseaux horaires ici
|
|
11
|
+
};
|
|
12
|
+
var toUTCToLocaleDate = function (date, countryCode) {
|
|
13
|
+
var zonedDate = new Date(date !== null && date !== void 0 ? date : "");
|
|
8
14
|
if (date) {
|
|
9
|
-
|
|
10
|
-
var countryTimeZones = {
|
|
11
|
-
'FR': 'Europe/Paris',
|
|
12
|
-
// Ajoutez d'autres correspondances de codes de pays et de fuseaux horaires ici
|
|
13
|
-
};
|
|
14
|
-
var timeZone = countryTimeZones[countryCode.toUpperCase()];
|
|
15
|
+
var timeZone = exports.countryTimeZones[countryCode.toUpperCase()];
|
|
15
16
|
if (!timeZone) {
|
|
16
17
|
throw new Error('Code de pays non pris en charge');
|
|
17
18
|
}
|
|
18
19
|
// Convertir la date UTC en date du fuseau horaire local
|
|
19
|
-
|
|
20
|
+
zonedDate = (0, date_fns_tz_1.utcToZonedTime)(date, timeZone);
|
|
21
|
+
}
|
|
22
|
+
return zonedDate;
|
|
23
|
+
};
|
|
24
|
+
exports.toUTCToLocaleDate = toUTCToLocaleDate;
|
|
25
|
+
var formatDateByCountryCode = function (date, countryCode, formatType) {
|
|
26
|
+
if (date) {
|
|
27
|
+
// Convertir la date UTC en date du fuseau horaire local
|
|
28
|
+
var zonedDate = (0, exports.toUTCToLocaleDate)(date, countryCode);
|
|
29
|
+
var timeZone = exports.countryTimeZones[countryCode.toUpperCase()];
|
|
20
30
|
// Formater la date
|
|
21
31
|
switch (formatType) {
|
|
22
32
|
case Enums_1.DateFormatTypes.SHORT_FORMAT_DATE:
|
|
@@ -6,10 +6,11 @@ export default class Garage {
|
|
|
6
6
|
adminId: string;
|
|
7
7
|
name: string;
|
|
8
8
|
address: Address;
|
|
9
|
+
workforce: number;
|
|
9
10
|
contactPhone: string;
|
|
10
11
|
prestations: Prestation[];
|
|
11
12
|
schedules: Schedule[];
|
|
12
13
|
contactEmail?: string;
|
|
13
14
|
logo?: string;
|
|
14
|
-
constructor(id: string, adminId: string, name: string, address: Address, prestations: Prestation[], schedules: Schedule[], contactPhone: string, contactEmail?: string, logo?: string);
|
|
15
|
+
constructor(id: string, adminId: string, name: string, address: Address, workforce: number, prestations: Prestation[], schedules: Schedule[], contactPhone: string, contactEmail?: string, logo?: string);
|
|
15
16
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
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, prestations, schedules, contactPhone, contactEmail, logo) {
|
|
4
|
+
function Garage(id, adminId, name, address, workforce, prestations, schedules, contactPhone, contactEmail, logo) {
|
|
5
5
|
this.id = id;
|
|
6
6
|
this.adminId = adminId;
|
|
7
7
|
this.name = name;
|
|
8
8
|
this.address = address;
|
|
9
|
+
this.workforce = workforce;
|
|
9
10
|
this.prestations = prestations;
|
|
10
11
|
this.schedules = schedules;
|
|
11
12
|
this.contactPhone = contactPhone;
|
package/index.ts
CHANGED
|
@@ -6,6 +6,7 @@ export { default as GarageService } from './src/services/GarageService';
|
|
|
6
6
|
export { default as UserService } from './src/services/UserService';
|
|
7
7
|
|
|
8
8
|
// Export des composants
|
|
9
|
+
export { default as AddressFields } from './src/AddressFields';
|
|
9
10
|
export { default as ScheduleFields } from './src/ScheduleFields';
|
|
10
11
|
export { default as VehicleFullCard } from './src/VehicleFullCard';
|
|
11
12
|
export { default as MovaDigitalPassport } from './src/MovaDigitalPassport';
|
|
@@ -35,13 +36,11 @@ export { default as Schedule } from './src/models/Schedule';
|
|
|
35
36
|
export { default as Event } from './src/models/Event';
|
|
36
37
|
export { default as VehicleTire } from './src/models/VehicleTire';
|
|
37
38
|
|
|
38
|
-
|
|
39
|
-
|
|
40
39
|
// Export des types
|
|
41
40
|
export type { APIRequest, APIResponse } from './src/helpers/ApiHelper';
|
|
42
41
|
export type { DaySchedule } from './src/ScheduleFields';
|
|
43
42
|
export type { MovaFormField, MovaLoginForm, MovaUserSignUpForm, MovaInterval, OriginReference,
|
|
44
|
-
MovaVehicleForm } from './src/helpers/Types';
|
|
43
|
+
MovaVehicleForm, AddressFieldName} from './src/helpers/Types';
|
|
45
44
|
|
|
46
45
|
// Export des méthodes utilitaires
|
|
47
46
|
export { readCookie, deleteCookie } from './src/helpers/CookieUtils';
|
package/package.json
CHANGED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import React, { FunctionComponent } from "react";
|
|
2
|
+
import { Grid, TextField, Typography } from "@mui/material";
|
|
3
|
+
import { AddressFieldName, MovaFormField } from "./helpers/Types";
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
type Form = {
|
|
7
|
+
streetNumber: MovaFormField,
|
|
8
|
+
streetName: MovaFormField,
|
|
9
|
+
additional: MovaFormField,
|
|
10
|
+
postalCode: MovaFormField,
|
|
11
|
+
cityName: MovaFormField,
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
interface AddressFieldsProps {
|
|
15
|
+
form: Form;
|
|
16
|
+
size: 'small' | 'medium';
|
|
17
|
+
handleChange: (fieldName: AddressFieldName, newValue: any, save?:boolean) => void;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const AddressFields: FunctionComponent<AddressFieldsProps> = ({ form, size, handleChange }) => (
|
|
21
|
+
<Grid container>
|
|
22
|
+
<TextField
|
|
23
|
+
id="address-streetName"
|
|
24
|
+
label="RUE"
|
|
25
|
+
value={form.streetName.value}
|
|
26
|
+
required
|
|
27
|
+
size={size}
|
|
28
|
+
onBlur={(e) => handleChange('streetName', e.target.value, true)}
|
|
29
|
+
onChange={(e) => handleChange('streetName', e.target.value, false)}
|
|
30
|
+
sx={{ width: '98%', mt: 2.5 }}
|
|
31
|
+
>
|
|
32
|
+
</TextField>
|
|
33
|
+
<TextField
|
|
34
|
+
id="address-additionnalInfo"
|
|
35
|
+
label="COMPLÉMENT"
|
|
36
|
+
size={size}
|
|
37
|
+
value={form.additional.value}
|
|
38
|
+
onBlur={(e) => handleChange('additional', e.target.value, true)}
|
|
39
|
+
onChange={(e) => handleChange('additional', e.target.value, false)}
|
|
40
|
+
sx={{ width: '98%', mt: 2.5 }}
|
|
41
|
+
>
|
|
42
|
+
</TextField>
|
|
43
|
+
<TextField
|
|
44
|
+
id="address-postalCode"
|
|
45
|
+
label="CODE POSTAL"
|
|
46
|
+
value={form.postalCode.value}
|
|
47
|
+
required
|
|
48
|
+
size={size}
|
|
49
|
+
onBlur={(e) => handleChange('postalCode', e.target.value, true)}
|
|
50
|
+
onChange={(e) => handleChange('postalCode', e.target.value, false)}
|
|
51
|
+
sx={{ width: '40%', mt: 2.5 , pr: 2}}
|
|
52
|
+
>
|
|
53
|
+
</TextField>
|
|
54
|
+
<TextField
|
|
55
|
+
id="address-cityName"
|
|
56
|
+
label="VILLE"
|
|
57
|
+
value={form.cityName.value}
|
|
58
|
+
required
|
|
59
|
+
size={size}
|
|
60
|
+
onBlur={(e) => handleChange('cityName', e.target.value, true)}
|
|
61
|
+
onChange={(e) => handleChange('cityName', e.target.value, false)}
|
|
62
|
+
sx={{ width: '55%', mt: 2.5 }}
|
|
63
|
+
>
|
|
64
|
+
</TextField>
|
|
65
|
+
</Grid>
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
export default AddressFields;
|
package/src/ScheduleFields.tsx
CHANGED
|
@@ -9,6 +9,7 @@ import Schedule from './models/Schedule';
|
|
|
9
9
|
import { DayOfWeek } from './helpers/Enums';
|
|
10
10
|
import Logger from './helpers/Logger';
|
|
11
11
|
import { flexCenter } from './helpers/Tools';
|
|
12
|
+
import { toUTCToLocaleDate } from './helpers/DateUtils';
|
|
12
13
|
|
|
13
14
|
export const FR_WEEK_DAYS: string[] = ['Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi', 'Dimanche'];
|
|
14
15
|
|
package/src/helpers/ApiHelper.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { APIMethod } from "./Enums";
|
|
|
2
2
|
import { COOKIE_GARAGE_TOKEN, readCookie } from "./CookieUtils";
|
|
3
3
|
import Logger from "./Logger";
|
|
4
4
|
|
|
5
|
-
export const API_BASE_URL = process.env.REACT_APP_API_URL
|
|
5
|
+
export const API_BASE_URL = process.env.REACT_APP_API_URL || 'https://localhost:8443/api';
|
|
6
6
|
|
|
7
7
|
export type APIResponse<T> = {
|
|
8
8
|
success: boolean;
|
package/src/helpers/DateUtils.ts
CHANGED
|
@@ -2,15 +2,16 @@ import { format, utcToZonedTime } from 'date-fns-tz';
|
|
|
2
2
|
import { fr } from 'date-fns/locale';
|
|
3
3
|
import { DateFormatTypes } from './Enums';
|
|
4
4
|
|
|
5
|
+
// Tableau de correspondance entre les codes de pays et les fuseaux horaires
|
|
6
|
+
export const countryTimeZones: { [key: string]: string } = {
|
|
7
|
+
'FR': 'Europe/Paris',
|
|
8
|
+
// Ajoutez d'autres correspondances de codes de pays et de fuseaux horaires ici
|
|
9
|
+
};
|
|
5
10
|
|
|
6
|
-
export const
|
|
11
|
+
export const toUTCToLocaleDate = (date: "" | Date | null, countryCode: string): Date => {
|
|
12
|
+
let zonedDate = new Date(date ?? "");
|
|
7
13
|
|
|
8
14
|
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
|
|
|
15
16
|
const timeZone = countryTimeZones[countryCode.toUpperCase()];
|
|
16
17
|
|
|
@@ -19,7 +20,19 @@ export const formatDateByCountryCode = (date: Date | undefined, countryCode: str
|
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
// Convertir la date UTC en date du fuseau horaire local
|
|
22
|
-
|
|
23
|
+
zonedDate = utcToZonedTime(date, timeZone);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return zonedDate;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const formatDateByCountryCode = (date: Date | undefined, countryCode: string, formatType: DateFormatTypes): string => {
|
|
30
|
+
|
|
31
|
+
if(date){
|
|
32
|
+
|
|
33
|
+
// Convertir la date UTC en date du fuseau horaire local
|
|
34
|
+
let zonedDate = toUTCToLocaleDate(date, countryCode);
|
|
35
|
+
const timeZone = countryTimeZones[countryCode.toUpperCase()];
|
|
23
36
|
|
|
24
37
|
// Formater la date
|
|
25
38
|
switch(formatType){
|
package/src/helpers/Types.ts
CHANGED
package/src/models/Garage.ts
CHANGED
|
@@ -8,6 +8,7 @@ export default class Garage {
|
|
|
8
8
|
adminId:string;
|
|
9
9
|
name:string;
|
|
10
10
|
address:Address;
|
|
11
|
+
workforce: number;
|
|
11
12
|
contactPhone: string;
|
|
12
13
|
prestations: Prestation[];
|
|
13
14
|
schedules: Schedule[];
|
|
@@ -19,6 +20,7 @@ export default class Garage {
|
|
|
19
20
|
adminId:string,
|
|
20
21
|
name:string,
|
|
21
22
|
address:Address,
|
|
23
|
+
workforce: number,
|
|
22
24
|
prestations: Prestation[],
|
|
23
25
|
schedules: Schedule[],
|
|
24
26
|
contactPhone: string,
|
|
@@ -29,6 +31,7 @@ export default class Garage {
|
|
|
29
31
|
this.adminId = adminId;
|
|
30
32
|
this.name = name;
|
|
31
33
|
this.address = address;
|
|
34
|
+
this.workforce = workforce;
|
|
32
35
|
this.prestations = prestations;
|
|
33
36
|
this.schedules = schedules;
|
|
34
37
|
this.contactPhone = contactPhone;
|
package/webpack.config.js
CHANGED
|
@@ -37,8 +37,8 @@ module.exports = {
|
|
|
37
37
|
template: path.resolve(__dirname, 'public', 'index.html'), // Chemin vers votre fichier HTML de base
|
|
38
38
|
}),
|
|
39
39
|
new webpack.DefinePlugin({
|
|
40
|
-
'REACT_APP_API_URL': JSON.stringify(process.env.REACT_APP_API_URL),
|
|
41
|
-
'REACT_APP_MOVALIB_APP_URL': JSON.stringify(process.env.REACT_APP_MOVALIB_APP_URL)
|
|
40
|
+
'process.env.REACT_APP_API_URL': JSON.stringify(process.env.REACT_APP_API_URL),
|
|
41
|
+
'process.env.REACT_APP_MOVALIB_APP_URL': JSON.stringify(process.env.REACT_APP_MOVALIB_APP_URL)
|
|
42
42
|
}),
|
|
43
43
|
],
|
|
44
44
|
};
|