@movalib/movalib-commons 1.0.73 → 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/src/helpers/ApiHelper.js +1 -2
- package/dist/src/helpers/DateUtils.d.ts +4 -0
- package/dist/src/helpers/DateUtils.js +19 -9
- package/package.json +1 -1
- package/src/ScheduleFields.tsx +1 -0
- package/src/helpers/ApiHelper.ts +1 -1
- package/src/helpers/DateUtils.ts +20 -7
- 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 () {
|
|
@@ -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:
|
package/package.json
CHANGED
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/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
|
};
|