@movalib/movalib-commons 1.0.73 → 1.0.75
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/PV_README.md +4 -0
- package/devIndex.tsx +2 -6
- package/dist/devIndex.js +2 -4
- package/dist/src/MovaDialog.js +1 -1
- package/dist/src/QRCode.js +11 -9
- 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/MovaDialog.tsx +1 -1
- package/src/QRCode.tsx +11 -8
- 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/PV_README.md
CHANGED
|
@@ -21,3 +21,7 @@ Pour lier la librairie aux projets qui l'utilise, executer la commande suivnte
|
|
|
21
21
|
Les commandes exécutées (ci-dessous) permettent de contourner un problème de double référence vers react et react-dom lorsque les deux appli utilisent des Hook
|
|
22
22
|
|
|
23
23
|
"link": "npm link --only=production && npm link \"/home/dimitri/Projets/5 - MOVALIB/02 - Développement/Front-End/movalib-user-app/node_modules/react\" && npm link \"/home/dimitri/Projets/5 - MOVALIB/02 - Développement/Front-End/movalib-user-app/node_modules/react-dom\"",
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
gsutil setmeta -h "Cache-Control:no-cache, must-revalidate" gs://app.movalib.com/*
|
|
27
|
+
gsutil setmeta -h "Cache-Control:no-cache, must-revalidate" gs://pro.movalib.com/*
|
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
|
|
|
@@ -72,6 +67,7 @@ const App = () => {
|
|
|
72
67
|
|
|
73
68
|
const getQRCodeData = ():string => {
|
|
74
69
|
// On renvoie les données pour le QR Code, l'url change selon l'environnement (variables d'environnement)
|
|
70
|
+
return 'https://www.instagram.com/delightnord/';
|
|
75
71
|
return `https://localhost:3001/#/garage/1?redirect=garage`;
|
|
76
72
|
}
|
|
77
73
|
|
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 () {
|
|
@@ -96,6 +93,7 @@ var App = function () {
|
|
|
96
93
|
};
|
|
97
94
|
var getQRCodeData = function () {
|
|
98
95
|
// On renvoie les données pour le QR Code, l'url change selon l'environnement (variables d'environnement)
|
|
96
|
+
return 'https://www.instagram.com/delightnord/';
|
|
99
97
|
return "https://localhost:3001/#/garage/1?redirect=garage";
|
|
100
98
|
};
|
|
101
99
|
var handleScheduleChange = function (schedule) {
|
package/dist/src/MovaDialog.js
CHANGED
|
@@ -52,7 +52,7 @@ var MovaDialog = function (_a) {
|
|
|
52
52
|
}
|
|
53
53
|
};
|
|
54
54
|
return ((0, jsx_runtime_1.jsxs)(material_1.Dialog, __assign({ fullScreen: fullScreen, fullWidth: true, TransitionComponent: getTransition(), open: open, "aria-labelledby": "garage-dialog-title", "aria-describedby": "garage-dialog-description", onClose: handleOnClose, sx: { textAlign: 'center' } }, { children: [(0, jsx_runtime_1.jsx)("img", { src: getLeafImage(), style: {
|
|
55
|
-
position: '
|
|
55
|
+
position: 'absolute',
|
|
56
56
|
float: 'left',
|
|
57
57
|
width: '150px',
|
|
58
58
|
height: '350px',
|
package/dist/src/QRCode.js
CHANGED
|
@@ -16,7 +16,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
18
18
|
var react_1 = require("react");
|
|
19
|
-
var leaf_yellow_small_png_1 = __importDefault(require("./assets/images/leaf_yellow_small.png"));
|
|
20
19
|
var material_1 = require("@mui/material");
|
|
21
20
|
var qr_code_styling_1 = __importDefault(require("qr-code-styling"));
|
|
22
21
|
require("./QRCode.css");
|
|
@@ -40,7 +39,7 @@ var QRCode = function (_a) {
|
|
|
40
39
|
height: 600,
|
|
41
40
|
type: 'canvas',
|
|
42
41
|
data: data !== null && data !== void 0 ? data : defaultData,
|
|
43
|
-
image:
|
|
42
|
+
//image: QRCodeImage,
|
|
44
43
|
margin: 10,
|
|
45
44
|
qrOptions: {
|
|
46
45
|
typeNumber: 0,
|
|
@@ -53,13 +52,14 @@ var QRCode = function (_a) {
|
|
|
53
52
|
margin: 15
|
|
54
53
|
},
|
|
55
54
|
dotsOptions: {
|
|
56
|
-
color:
|
|
55
|
+
color: 'black',
|
|
56
|
+
//color: darken(theme.palette.primary.main, 0.3),
|
|
57
57
|
// gradient: {
|
|
58
58
|
// type: 'linear', // 'radial'
|
|
59
59
|
// rotation: 0,
|
|
60
60
|
// colorStops: [{ offset: 0, color: theme.palette.primary.main }, { offset: 1, color: theme.palette.secondary.main }]
|
|
61
61
|
// },
|
|
62
|
-
type: '
|
|
62
|
+
type: 'rounded' // "dots" | "rounded" | "classy" | "classy-rounded" | "square" | "extra-rounded";
|
|
63
63
|
},
|
|
64
64
|
backgroundOptions: {
|
|
65
65
|
color: 'white',
|
|
@@ -70,8 +70,9 @@ var QRCode = function (_a) {
|
|
|
70
70
|
// },
|
|
71
71
|
},
|
|
72
72
|
cornersSquareOptions: {
|
|
73
|
-
color:
|
|
74
|
-
|
|
73
|
+
color: '#de007dff',
|
|
74
|
+
//color: darken(theme.palette.secondary.main, 0.1),
|
|
75
|
+
type: 'extra-rounded',
|
|
75
76
|
// gradient: {
|
|
76
77
|
// type: 'linear', // 'radial'
|
|
77
78
|
// rotation: 180,
|
|
@@ -79,8 +80,9 @@ var QRCode = function (_a) {
|
|
|
79
80
|
// },
|
|
80
81
|
},
|
|
81
82
|
cornersDotOptions: {
|
|
82
|
-
color:
|
|
83
|
-
|
|
83
|
+
color: '#de007dff',
|
|
84
|
+
//color: darken(theme.palette.secondary.main, 0.1),
|
|
85
|
+
type: 'dot',
|
|
84
86
|
// gradient: {
|
|
85
87
|
// type: 'linear', // 'radial'
|
|
86
88
|
// rotation: 180,
|
|
@@ -89,7 +91,7 @@ var QRCode = function (_a) {
|
|
|
89
91
|
}
|
|
90
92
|
}), options = _c[0], setOptions = _c[1];
|
|
91
93
|
// Format de téléchargement par défaut
|
|
92
|
-
var _d = (0, react_1.useState)("
|
|
94
|
+
var _d = (0, react_1.useState)("svg"), fileExt = _d[0], setFileExt = _d[1];
|
|
93
95
|
var qrCode = (0, react_1.useState)(new qr_code_styling_1.default(options))[0];
|
|
94
96
|
var ref = (0, react_1.useRef)(null);
|
|
95
97
|
(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/MovaDialog.tsx
CHANGED
package/src/QRCode.tsx
CHANGED
|
@@ -43,7 +43,7 @@ const QRCode: FC<QRCodeProps> = ({ data, showDownload=false }) => {
|
|
|
43
43
|
height: 600,
|
|
44
44
|
type: 'canvas' as DrawType,
|
|
45
45
|
data: data ?? defaultData,
|
|
46
|
-
image: QRCodeImage,
|
|
46
|
+
//image: QRCodeImage,
|
|
47
47
|
margin: 10,
|
|
48
48
|
qrOptions: {
|
|
49
49
|
typeNumber: 0 as TypeNumber,
|
|
@@ -56,13 +56,14 @@ const QRCode: FC<QRCodeProps> = ({ data, showDownload=false }) => {
|
|
|
56
56
|
margin: 15
|
|
57
57
|
},
|
|
58
58
|
dotsOptions: {
|
|
59
|
-
color:
|
|
59
|
+
color: 'black',
|
|
60
|
+
//color: darken(theme.palette.primary.main, 0.3),
|
|
60
61
|
// gradient: {
|
|
61
62
|
// type: 'linear', // 'radial'
|
|
62
63
|
// rotation: 0,
|
|
63
64
|
// colorStops: [{ offset: 0, color: theme.palette.primary.main }, { offset: 1, color: theme.palette.secondary.main }]
|
|
64
65
|
// },
|
|
65
|
-
type: '
|
|
66
|
+
type: 'rounded' as DotType // "dots" | "rounded" | "classy" | "classy-rounded" | "square" | "extra-rounded";
|
|
66
67
|
},
|
|
67
68
|
backgroundOptions: {
|
|
68
69
|
color: 'white',
|
|
@@ -73,8 +74,9 @@ const QRCode: FC<QRCodeProps> = ({ data, showDownload=false }) => {
|
|
|
73
74
|
// },
|
|
74
75
|
},
|
|
75
76
|
cornersSquareOptions: {
|
|
76
|
-
color:
|
|
77
|
-
|
|
77
|
+
color: '#de007dff',
|
|
78
|
+
//color: darken(theme.palette.secondary.main, 0.1),
|
|
79
|
+
type: 'extra-rounded' as CornerSquareType,
|
|
78
80
|
// gradient: {
|
|
79
81
|
// type: 'linear', // 'radial'
|
|
80
82
|
// rotation: 180,
|
|
@@ -82,8 +84,9 @@ const QRCode: FC<QRCodeProps> = ({ data, showDownload=false }) => {
|
|
|
82
84
|
// },
|
|
83
85
|
},
|
|
84
86
|
cornersDotOptions: {
|
|
85
|
-
color:
|
|
86
|
-
|
|
87
|
+
color: '#de007dff',
|
|
88
|
+
//color: darken(theme.palette.secondary.main, 0.1),
|
|
89
|
+
type: 'dot' as CornerDotType,
|
|
87
90
|
// gradient: {
|
|
88
91
|
// type: 'linear', // 'radial'
|
|
89
92
|
// rotation: 180,
|
|
@@ -93,7 +96,7 @@ const QRCode: FC<QRCodeProps> = ({ data, showDownload=false }) => {
|
|
|
93
96
|
});
|
|
94
97
|
|
|
95
98
|
// Format de téléchargement par défaut
|
|
96
|
-
const [fileExt, setFileExt] = useState<Extension>("
|
|
99
|
+
const [fileExt, setFileExt] = useState<Extension>("svg");
|
|
97
100
|
const [qrCode] = useState<QRCodeStyling>(new QRCodeStyling(options));
|
|
98
101
|
const ref = useRef<HTMLDivElement>(null);
|
|
99
102
|
|
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
|
};
|