@movalib/movalib-commons 1.0.47 → 1.0.49
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 +2 -0
- package/dist/index.js +7 -1
- package/dist/src/GenderSelector.js +1 -1
- package/dist/src/MovaLogin.js +10 -1
- package/dist/src/QRCode.d.ts +7 -0
- package/dist/src/QRCode.js +122 -0
- package/dist/src/assets/images/leaf_green_small.png +0 -0
- package/dist/src/assets/images/leaf_pink_small.png.png +0 -0
- package/dist/src/assets/images/leaf_yellow_small.png +0 -0
- package/index.ts +5 -2
- package/package.json +4 -1
- package/src/GenderSelector.tsx +1 -0
- package/src/MovaLogin.tsx +11 -1
- package/src/QRCode.tsx +146 -0
- package/src/assets/images/leaf_green_small.png +0 -0
- package/src/assets/images/leaf_pink_small.png.png +0 -0
- package/src/assets/images/leaf_yellow_small.png +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { default as QRCode } from './src/QRCode';
|
|
1
2
|
export { default as VehiclePlateField } from './src/VehiclePlateField';
|
|
2
3
|
export { default as TestButton } from './src/TestButton';
|
|
3
4
|
export { default as MovaSnackbar } from './src/MovaSnackbar';
|
|
@@ -18,4 +19,5 @@ export { default as Event } from './src/models/Event';
|
|
|
18
19
|
export { default as VehicleTire } from './src/models/VehicleTire';
|
|
19
20
|
export type { MovaFormField, MovaLoginForm, MovaUserSignUpForm, MovaInterval } from './src/helpers/Types';
|
|
20
21
|
export { validateField } from './src/helpers/Tools';
|
|
22
|
+
export { validatePhoneNumber, validateText, validateEmail } from './src/helpers/Validator';
|
|
21
23
|
export { RoleType, MovaAppType, DayOfWeek, EventState, EventType, DocumentType, DigitalPassportIndex, DocumentState, Gender } from './src/helpers/Enums';
|
package/dist/index.js
CHANGED
|
@@ -4,8 +4,10 @@ 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.Gender = exports.DocumentState = exports.DigitalPassportIndex = exports.DocumentType = exports.EventType = exports.EventState = exports.DayOfWeek = exports.MovaAppType = exports.RoleType = exports.validateField = exports.VehicleTire = exports.Event = exports.Schedule = exports.Garage = exports.Document = exports.Vehicle = exports.Address = exports.Role = exports.User = exports.GenderSelector = exports.ConfirmationDialog = exports.MovaVehicleTireField = exports.MovaCopyright = exports.MovaSignUp = exports.MovaLogin = exports.MovaSnackbar = exports.TestButton = exports.VehiclePlateField = void 0;
|
|
7
|
+
exports.Gender = exports.DocumentState = exports.DigitalPassportIndex = exports.DocumentType = exports.EventType = exports.EventState = exports.DayOfWeek = exports.MovaAppType = exports.RoleType = exports.validateEmail = exports.validateText = exports.validatePhoneNumber = exports.validateField = exports.VehicleTire = exports.Event = exports.Schedule = exports.Garage = exports.Document = exports.Vehicle = exports.Address = exports.Role = exports.User = exports.GenderSelector = exports.ConfirmationDialog = exports.MovaVehicleTireField = exports.MovaCopyright = exports.MovaSignUp = exports.MovaLogin = exports.MovaSnackbar = exports.TestButton = exports.VehiclePlateField = exports.QRCode = void 0;
|
|
8
8
|
// Export des composants
|
|
9
|
+
var QRCode_1 = require("./src/QRCode");
|
|
10
|
+
Object.defineProperty(exports, "QRCode", { enumerable: true, get: function () { return __importDefault(QRCode_1).default; } });
|
|
9
11
|
var VehiclePlateField_1 = require("./src/VehiclePlateField");
|
|
10
12
|
Object.defineProperty(exports, "VehiclePlateField", { enumerable: true, get: function () { return __importDefault(VehiclePlateField_1).default; } });
|
|
11
13
|
var TestButton_1 = require("./src/TestButton");
|
|
@@ -46,6 +48,10 @@ Object.defineProperty(exports, "VehicleTire", { enumerable: true, get: function
|
|
|
46
48
|
// Export des méthodes utilitaires
|
|
47
49
|
var Tools_1 = require("./src/helpers/Tools");
|
|
48
50
|
Object.defineProperty(exports, "validateField", { enumerable: true, get: function () { return Tools_1.validateField; } });
|
|
51
|
+
var Validator_1 = require("./src/helpers/Validator");
|
|
52
|
+
Object.defineProperty(exports, "validatePhoneNumber", { enumerable: true, get: function () { return Validator_1.validatePhoneNumber; } });
|
|
53
|
+
Object.defineProperty(exports, "validateText", { enumerable: true, get: function () { return Validator_1.validateText; } });
|
|
54
|
+
Object.defineProperty(exports, "validateEmail", { enumerable: true, get: function () { return Validator_1.validateEmail; } });
|
|
49
55
|
// Export des enums
|
|
50
56
|
var Enums_1 = require("./src/helpers/Enums");
|
|
51
57
|
Object.defineProperty(exports, "RoleType", { enumerable: true, get: function () { return Enums_1.RoleType; } });
|
|
@@ -15,6 +15,6 @@ var jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
15
15
|
var material_1 = require("@mui/material");
|
|
16
16
|
var GenderSelector = function (_a) {
|
|
17
17
|
var handleSelectChange = _a.handleSelectChange, form = _a.form, required = _a.required, sx = _a.sx;
|
|
18
|
-
return ((0, jsx_runtime_1.jsxs)(material_1.FormControl, __assign({ fullWidth: true, margin: "normal", required: required, sx: __assign({}, sx), error: !form.gender.isValid }, { children: [(0, jsx_runtime_1.jsx)(material_1.InputLabel, __assign({ id: "gender-label" }, { children: "Sexe" })), (0, jsx_runtime_1.jsxs)(material_1.Select, __assign({ labelId: "gender-label", id: "gender", name: "gender", value: form.gender.value, onChange: function (e) { return handleSelectChange(e); } }, { children: [(0, jsx_runtime_1.jsx)(material_1.MenuItem, __assign({ value: "MALE" }, { children: "Homme" })), (0, jsx_runtime_1.jsx)(material_1.MenuItem, __assign({ value: "FEMALE" }, { children: "Femme" })), (0, jsx_runtime_1.jsx)(material_1.MenuItem, __assign({ value: "OTHER" }, { children: "Autre" }))] })), (0, jsx_runtime_1.jsx)(material_1.FormHelperText, { children: form.gender.error })] })));
|
|
18
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.FormControl, __assign({ fullWidth: true, margin: "normal", required: required, sx: __assign({}, sx), error: !form.gender.isValid }, { children: [(0, jsx_runtime_1.jsx)(material_1.InputLabel, __assign({ id: "gender-label" }, { children: "Sexe" })), (0, jsx_runtime_1.jsxs)(material_1.Select, __assign({ labelId: "gender-label", id: "gender", name: "gender", label: "Sexe", value: form.gender.value, onChange: function (e) { return handleSelectChange(e); } }, { children: [(0, jsx_runtime_1.jsx)(material_1.MenuItem, __assign({ value: "MALE" }, { children: "Homme" })), (0, jsx_runtime_1.jsx)(material_1.MenuItem, __assign({ value: "FEMALE" }, { children: "Femme" })), (0, jsx_runtime_1.jsx)(material_1.MenuItem, __assign({ value: "OTHER" }, { children: "Autre" }))] })), (0, jsx_runtime_1.jsx)(material_1.FormHelperText, { children: form.gender.error })] })));
|
|
19
19
|
};
|
|
20
20
|
exports.default = GenderSelector;
|
package/dist/src/MovaLogin.js
CHANGED
|
@@ -62,6 +62,7 @@ var MovaCopyright_1 = __importDefault(require("./MovaCopyright"));
|
|
|
62
62
|
var Enums_1 = require("./helpers/Enums");
|
|
63
63
|
var Validator_1 = require("./helpers/Validator");
|
|
64
64
|
var Tools_1 = require("./helpers/Tools");
|
|
65
|
+
var react_router_dom_1 = require("react-router-dom");
|
|
65
66
|
// Permet de centrer le contenu de l'application
|
|
66
67
|
var styles = {
|
|
67
68
|
display: 'flex',
|
|
@@ -82,6 +83,7 @@ var MovaLogin = function (_a) {
|
|
|
82
83
|
var loading = _a.loading, movaAppType = _a.movaAppType, onSubmit = _a.onSubmit, alertMessage = _a.alertMessage, alertSeverity = _a.alertSeverity;
|
|
83
84
|
var _b = (0, react_1.useState)(initialFormState), form = _b[0], setForm = _b[1];
|
|
84
85
|
var _c = (0, react_1.useState)(""), message = _c[0], setMessage = _c[1];
|
|
86
|
+
var history = (0, react_router_dom_1.useHistory)();
|
|
85
87
|
var handleInputChange = function (e) {
|
|
86
88
|
var _a;
|
|
87
89
|
var fieldName = e.target.name;
|
|
@@ -121,6 +123,13 @@ var MovaLogin = function (_a) {
|
|
|
121
123
|
movaAppType === Enums_1.MovaAppType.USER ? logo_large_png_1.default :
|
|
122
124
|
movaAppType === Enums_1.MovaAppType.ADMIN ? logo_large_png_1.default : logo_large_png_1.default;
|
|
123
125
|
};
|
|
126
|
+
var handleOnClickSignUp = function (e) {
|
|
127
|
+
e.preventDefault();
|
|
128
|
+
if (history) {
|
|
129
|
+
// On redirige l'utilisateur vers la page par défaut (accueil)
|
|
130
|
+
history.push('/signup');
|
|
131
|
+
}
|
|
132
|
+
};
|
|
124
133
|
return ((0, jsx_runtime_1.jsxs)("div", __assign({ style: styles }, { children: [(0, jsx_runtime_1.jsx)("img", { src: leaf_green_large_png_1.default, style: { position: 'fixed',
|
|
125
134
|
float: 'left',
|
|
126
135
|
width: '250px',
|
|
@@ -133,7 +142,7 @@ var MovaLogin = function (_a) {
|
|
|
133
142
|
display: 'flex',
|
|
134
143
|
flexDirection: 'column',
|
|
135
144
|
alignItems: 'center',
|
|
136
|
-
} }, { children: [(0, jsx_runtime_1.jsx)("img", { src: getMovaLogo(), style: { width: '80%' } }), (0, jsx_runtime_1.jsx)("br", {})] })), (0, jsx_runtime_1.jsxs)(material_1.Box, __assign({ component: "form", onSubmit: handleSubmit, noValidate: true, sx: { mt: 1 } }, { children: [(0, jsx_runtime_1.jsx)(material_1.TextField, { margin: "normal", required: true, fullWidth: true, id: "email", label: "Adresse email", name: "email", autoComplete: "email", autoFocus: true, onChange: function (e) { return handleInputChange(e); }, value: form.email.value, error: !form.email.isValid, helperText: form.email.error }), (0, jsx_runtime_1.jsx)(material_1.TextField, { margin: "normal", required: true, fullWidth: true, name: "password", label: "Mot de passe", type: "password", id: "password", autoComplete: "current-password", onChange: function (e) { return handleInputChange(e); }, value: form.password.value, error: !form.password.isValid, helperText: form.password.error }), (0, jsx_runtime_1.jsx)(material_1.FormControlLabel, { control: (0, jsx_runtime_1.jsx)(material_1.Checkbox, { value: "remember", color: "primary" }), label: "Se souvenir de moi" }), (0, jsx_runtime_1.jsx)(lab_1.LoadingButton, __assign({ loading: loading, type: "submit", fullWidth: true, variant: "contained", sx: { mt: 3, mb: 2 } }, { children: (0, jsx_runtime_1.jsx)("span", { children: "Se connecter" }) })), alertMessage && alertSeverity && (0, jsx_runtime_1.jsx)(material_1.Alert, __assign({ severity: alertSeverity, sx: { mb: 2 } }, { children: alertMessage })), (0, jsx_runtime_1.jsxs)(material_1.Grid, __assign({ container: true }, { children: [(0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: true }, { children: (0, jsx_runtime_1.jsx)(material_1.Link, __assign({ href: "/forgot-password", variant: "body2", color: "text.secondary" }, { children: "Mot de passe oubli\u00E9 ?" })) })), movaAppType === Enums_1.MovaAppType.USER && (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true }, { children: (0, jsx_runtime_1.jsx)(material_1.Link, __assign({
|
|
145
|
+
} }, { children: [(0, jsx_runtime_1.jsx)("img", { src: getMovaLogo(), style: { width: '80%' } }), (0, jsx_runtime_1.jsx)("br", {})] })), (0, jsx_runtime_1.jsxs)(material_1.Box, __assign({ component: "form", onSubmit: handleSubmit, noValidate: true, sx: { mt: 1 } }, { children: [(0, jsx_runtime_1.jsx)(material_1.TextField, { margin: "normal", required: true, fullWidth: true, id: "email", label: "Adresse email", name: "email", autoComplete: "email", autoFocus: true, onChange: function (e) { return handleInputChange(e); }, value: form.email.value, error: !form.email.isValid, helperText: form.email.error }), (0, jsx_runtime_1.jsx)(material_1.TextField, { margin: "normal", required: true, fullWidth: true, name: "password", label: "Mot de passe", type: "password", id: "password", autoComplete: "current-password", onChange: function (e) { return handleInputChange(e); }, value: form.password.value, error: !form.password.isValid, helperText: form.password.error }), (0, jsx_runtime_1.jsx)(material_1.FormControlLabel, { control: (0, jsx_runtime_1.jsx)(material_1.Checkbox, { value: "remember", color: "primary" }), label: "Se souvenir de moi" }), (0, jsx_runtime_1.jsx)(lab_1.LoadingButton, __assign({ loading: loading, type: "submit", fullWidth: true, variant: "contained", sx: { mt: 3, mb: 2 } }, { children: (0, jsx_runtime_1.jsx)("span", { children: "Se connecter" }) })), alertMessage && alertSeverity && (0, jsx_runtime_1.jsx)(material_1.Alert, __assign({ severity: alertSeverity, sx: { mb: 2 } }, { children: alertMessage })), (0, jsx_runtime_1.jsxs)(material_1.Grid, __assign({ container: true }, { children: [(0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: true }, { children: (0, jsx_runtime_1.jsx)(material_1.Link, __assign({ href: "/forgot-password", variant: "body2", color: "text.secondary" }, { children: "Mot de passe oubli\u00E9 ?" })) })), movaAppType === Enums_1.MovaAppType.USER && (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true }, { children: (0, jsx_runtime_1.jsx)(material_1.Link, __assign({ variant: "body2", color: "text.secondary", onClick: function (e) { return handleOnClickSignUp(e); } }, { children: "Créer mon compte" })) }))] }))] })), (0, jsx_runtime_1.jsx)(MovaCopyright_1.default, { sx: { mt: 8, mb: 4 } })] })), (0, jsx_runtime_1.jsx)("img", { src: leaf_pink_large_png_1.default, style: { position: 'fixed',
|
|
137
146
|
float: 'right',
|
|
138
147
|
width: '250px',
|
|
139
148
|
height: '400px',
|
|
@@ -0,0 +1,122 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
18
|
+
var react_1 = require("react");
|
|
19
|
+
var leaf_yellow_small_png_1 = __importDefault(require("../assets/images/leaf_yellow_small.png"));
|
|
20
|
+
var qr_code_styling_1 = __importDefault(require("qr-code-styling"));
|
|
21
|
+
var material_1 = require("@mui/material");
|
|
22
|
+
var styles = {
|
|
23
|
+
inputWrapper: {
|
|
24
|
+
margin: "20px 0",
|
|
25
|
+
display: "flex",
|
|
26
|
+
alignItems: 'center',
|
|
27
|
+
justifyContent: "center",
|
|
28
|
+
width: '100%'
|
|
29
|
+
},
|
|
30
|
+
inputBox: {
|
|
31
|
+
flexGrow: 1,
|
|
32
|
+
marginRight: 20
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
var QRCode = function (_a) {
|
|
36
|
+
var data = _a.data, _b = _a.showDownload, showDownload = _b === void 0 ? false : _b;
|
|
37
|
+
var theme = (0, material_1.useTheme)();
|
|
38
|
+
// Le contenu du QR Code est transmis en props, sinon redirection vers ls site vitrine
|
|
39
|
+
var defaultData = 'https://movalib.com';
|
|
40
|
+
var _c = (0, react_1.useState)({
|
|
41
|
+
width: 300,
|
|
42
|
+
height: 300,
|
|
43
|
+
type: 'svg',
|
|
44
|
+
data: data !== null && data !== void 0 ? data : defaultData,
|
|
45
|
+
image: leaf_yellow_small_png_1.default,
|
|
46
|
+
margin: 10,
|
|
47
|
+
qrOptions: {
|
|
48
|
+
typeNumber: 0,
|
|
49
|
+
mode: 'Byte',
|
|
50
|
+
errorCorrectionLevel: 'Q'
|
|
51
|
+
},
|
|
52
|
+
imageOptions: {
|
|
53
|
+
hideBackgroundDots: true,
|
|
54
|
+
imageSize: 0.4,
|
|
55
|
+
margin: 15,
|
|
56
|
+
crossOrigin: 'anonymous',
|
|
57
|
+
},
|
|
58
|
+
dotsOptions: {
|
|
59
|
+
color: (0, material_1.darken)(theme.palette.primary.main, 0.3),
|
|
60
|
+
// gradient: {
|
|
61
|
+
// type: 'linear', // 'radial'
|
|
62
|
+
// rotation: 0,
|
|
63
|
+
// colorStops: [{ offset: 0, color: theme.palette.primary.main }, { offset: 1, color: theme.palette.secondary.main }]
|
|
64
|
+
// },
|
|
65
|
+
type: 'square' // "dots" | "rounded" | "classy" | "classy-rounded" | "square" | "extra-rounded";
|
|
66
|
+
},
|
|
67
|
+
backgroundOptions: {
|
|
68
|
+
color: 'white',
|
|
69
|
+
// gradient: {
|
|
70
|
+
// type: 'linear', // 'radial'
|
|
71
|
+
// rotation: 0,
|
|
72
|
+
// colorStops: [{ offset: 0, color: '#ededff' }, { offset: 1, color: '#e6e7ff' }]
|
|
73
|
+
// },
|
|
74
|
+
},
|
|
75
|
+
cornersSquareOptions: {
|
|
76
|
+
color: (0, material_1.darken)(theme.palette.secondary.main, 0.1),
|
|
77
|
+
type: 'square',
|
|
78
|
+
// gradient: {
|
|
79
|
+
// type: 'linear', // 'radial'
|
|
80
|
+
// rotation: 180,
|
|
81
|
+
// colorStops: [{ offset: 0, color: '#25456e' }, { offset: 1, color: '#4267b2' }]
|
|
82
|
+
// },
|
|
83
|
+
},
|
|
84
|
+
cornersDotOptions: {
|
|
85
|
+
color: (0, material_1.darken)(theme.palette.secondary.main, 0.1),
|
|
86
|
+
type: 'square',
|
|
87
|
+
// gradient: {
|
|
88
|
+
// type: 'linear', // 'radial'
|
|
89
|
+
// rotation: 180,
|
|
90
|
+
// colorStops: [{ offset: 0, color: '#00266e' }, { offset: 1, color: '#4060b3' }]
|
|
91
|
+
// },
|
|
92
|
+
}
|
|
93
|
+
}), options = _c[0], setOptions = _c[1];
|
|
94
|
+
// Format de téléchargement par défaut
|
|
95
|
+
var _d = (0, react_1.useState)("png"), fileExt = _d[0], setFileExt = _d[1];
|
|
96
|
+
var qrCode = (0, react_1.useState)(new qr_code_styling_1.default(options))[0];
|
|
97
|
+
var ref = (0, react_1.useRef)(null);
|
|
98
|
+
(0, react_1.useEffect)(function () {
|
|
99
|
+
if (ref.current) {
|
|
100
|
+
qrCode.append(ref.current);
|
|
101
|
+
}
|
|
102
|
+
}, [qrCode, ref]);
|
|
103
|
+
(0, react_1.useEffect)(function () {
|
|
104
|
+
if (!qrCode)
|
|
105
|
+
return;
|
|
106
|
+
qrCode.update(options);
|
|
107
|
+
}, [qrCode, options]);
|
|
108
|
+
/* const onExtensionChange = (event: ChangeEvent<HTMLSelectElement>) => {
|
|
109
|
+
setFileExt(event.target.value as Extension);
|
|
110
|
+
}; */
|
|
111
|
+
var onDownloadClick = function () {
|
|
112
|
+
if (!qrCode)
|
|
113
|
+
return;
|
|
114
|
+
qrCode.download({
|
|
115
|
+
extension: fileExt,
|
|
116
|
+
name: "movalib-qr-code"
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.Box, { children: [(0, jsx_runtime_1.jsx)("div", { ref: ref, style: styles.inputWrapper }), showDownload &&
|
|
120
|
+
(0, jsx_runtime_1.jsx)(material_1.Box, __assign({ sx: { display: 'flex', justifyContent: 'center' } }, { children: (0, jsx_runtime_1.jsx)(material_1.Button, __assign({ variant: 'outlined', onClick: onDownloadClick, sx: { color: (0, material_1.darken)(theme.palette.primary.main, 0.2) } }, { children: "T\u00E9l\u00E9charger" })) }))] }));
|
|
121
|
+
};
|
|
122
|
+
exports.default = QRCode;
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
2
|
|
|
3
3
|
// Export des composants
|
|
4
|
+
export { default as QRCode } from './src/QRCode';
|
|
4
5
|
export { default as VehiclePlateField } from './src/VehiclePlateField';
|
|
5
6
|
export { default as TestButton } from './src/TestButton';
|
|
6
7
|
export { default as MovaSnackbar } from './src/MovaSnackbar';
|
|
@@ -26,8 +27,10 @@ export { default as VehicleTire } from './src/models/VehicleTire';
|
|
|
26
27
|
export type { MovaFormField, MovaLoginForm, MovaUserSignUpForm, MovaInterval } from './src/helpers/Types';
|
|
27
28
|
|
|
28
29
|
// Export des méthodes utilitaires
|
|
29
|
-
export { validateField }
|
|
30
|
+
export { validateField } from './src/helpers/Tools';
|
|
31
|
+
export { validatePhoneNumber, validateText, validateEmail } from './src/helpers/Validator';
|
|
30
32
|
|
|
31
33
|
// Export des enums
|
|
32
34
|
export { RoleType, MovaAppType, DayOfWeek, EventState, EventType, DocumentType,
|
|
33
|
-
DigitalPassportIndex, DocumentState, Gender } from './src/helpers/Enums';
|
|
35
|
+
DigitalPassportIndex, DocumentState, Gender } from './src/helpers/Enums';
|
|
36
|
+
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@movalib/movalib-commons",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.49",
|
|
4
4
|
"description": "Bibliothèque d'objets communs à l'ensemble des projets React de Movalib",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -18,8 +18,10 @@
|
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@types/node": "^16.18.53",
|
|
20
20
|
"@types/react": "^18.2.22",
|
|
21
|
+
"@types/react-router-dom": "^5.3.0",
|
|
21
22
|
"react": "^18.2.0",
|
|
22
23
|
"react-dom": "^18.2.0",
|
|
24
|
+
"react-router-dom": "^5.1.2",
|
|
23
25
|
"react-scripts": "5.0.1"
|
|
24
26
|
},
|
|
25
27
|
"eslintConfig": {
|
|
@@ -37,6 +39,7 @@
|
|
|
37
39
|
"@types/react-dom": "^18.2.7",
|
|
38
40
|
"file-loader": "^6.2.0",
|
|
39
41
|
"html-webpack-plugin": "^5.5.3",
|
|
42
|
+
"qr-code-styling": "^1.4.4",
|
|
40
43
|
"ts-loader": "^9.4.4",
|
|
41
44
|
"typescript": "^4.9.5",
|
|
42
45
|
"webpack-cli": "^5.1.4"
|
package/src/GenderSelector.tsx
CHANGED
package/src/MovaLogin.tsx
CHANGED
|
@@ -10,6 +10,7 @@ import { MovaLoginForm, MovaFormField } from "./helpers/Types";
|
|
|
10
10
|
import { MovaAppType } from "./helpers/Enums";
|
|
11
11
|
import { validateEmail } from "./helpers/Validator";
|
|
12
12
|
import { validateField } from "./helpers/Tools";
|
|
13
|
+
import { useHistory } from "react-router-dom";
|
|
13
14
|
|
|
14
15
|
// Permet de centrer le contenu de l'application
|
|
15
16
|
const styles: CSSProperties = {
|
|
@@ -49,6 +50,7 @@ const MovaLogin: FunctionComponent<MovaLoginProps> = ({ loading, movaAppType, on
|
|
|
49
50
|
|
|
50
51
|
const [form, setForm] = useState<MovaLoginForm>(initialFormState);
|
|
51
52
|
const [message, setMessage] = useState<string>("");
|
|
53
|
+
const history = useHistory();
|
|
52
54
|
|
|
53
55
|
const handleInputChange = (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>): void => {
|
|
54
56
|
const fieldName: string = e.target.name;
|
|
@@ -98,6 +100,14 @@ const MovaLogin: FunctionComponent<MovaLoginProps> = ({ loading, movaAppType, on
|
|
|
98
100
|
movaAppType === MovaAppType.ADMIN ? LogoLarge : LogoLarge;
|
|
99
101
|
}
|
|
100
102
|
|
|
103
|
+
const handleOnClickSignUp = (e: React.MouseEvent<HTMLAnchorElement, MouseEvent>) => {
|
|
104
|
+
e.preventDefault();
|
|
105
|
+
if(history){
|
|
106
|
+
// On redirige l'utilisateur vers la page par défaut (accueil)
|
|
107
|
+
history.push('/signup');
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
101
111
|
|
|
102
112
|
return (
|
|
103
113
|
<div style={styles}>
|
|
@@ -175,7 +185,7 @@ const MovaLogin: FunctionComponent<MovaLoginProps> = ({ loading, movaAppType, on
|
|
|
175
185
|
</Link>
|
|
176
186
|
</Grid>
|
|
177
187
|
{movaAppType === MovaAppType.USER && <Grid item>
|
|
178
|
-
<Link
|
|
188
|
+
<Link variant="body2" color="text.secondary" onClick={(e) => handleOnClickSignUp(e)}>
|
|
179
189
|
{"Créer mon compte"}
|
|
180
190
|
</Link>
|
|
181
191
|
</Grid>}
|
package/src/QRCode.tsx
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { useState, type FC, useRef, useEffect, ChangeEvent } from 'react';
|
|
2
|
+
import QRCodeImage from "../assets/images/leaf_yellow_small.png";
|
|
3
|
+
import QRCodeStyling, {
|
|
4
|
+
DrawType,
|
|
5
|
+
TypeNumber,
|
|
6
|
+
Mode,
|
|
7
|
+
ErrorCorrectionLevel,
|
|
8
|
+
DotType,
|
|
9
|
+
CornerSquareType,
|
|
10
|
+
CornerDotType,
|
|
11
|
+
Extension,
|
|
12
|
+
Options
|
|
13
|
+
} from "qr-code-styling";
|
|
14
|
+
import { Box, Button, darken, useTheme } from '@mui/material';
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
interface QRCodeProps {
|
|
18
|
+
data?:string,
|
|
19
|
+
showDownload?:boolean
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
const styles = {
|
|
24
|
+
inputWrapper: {
|
|
25
|
+
margin: "20px 0",
|
|
26
|
+
display: "flex",
|
|
27
|
+
alignItems: 'center',
|
|
28
|
+
justifyContent: "center",
|
|
29
|
+
width: '100%'
|
|
30
|
+
},
|
|
31
|
+
inputBox: {
|
|
32
|
+
flexGrow: 1,
|
|
33
|
+
marginRight: 20
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const QRCode: FC<QRCodeProps> = ({ data, showDownload=false }) => {
|
|
38
|
+
|
|
39
|
+
const theme = useTheme();
|
|
40
|
+
|
|
41
|
+
// Le contenu du QR Code est transmis en props, sinon redirection vers ls site vitrine
|
|
42
|
+
const defaultData:string = 'https://movalib.com';
|
|
43
|
+
|
|
44
|
+
const [options, setOptions] = useState<Options>({
|
|
45
|
+
width: 300,
|
|
46
|
+
height: 300,
|
|
47
|
+
type: 'svg' as DrawType,
|
|
48
|
+
data: data ?? defaultData,
|
|
49
|
+
image: QRCodeImage,
|
|
50
|
+
margin: 10,
|
|
51
|
+
qrOptions: {
|
|
52
|
+
typeNumber: 0 as TypeNumber,
|
|
53
|
+
mode: 'Byte' as Mode,
|
|
54
|
+
errorCorrectionLevel: 'Q' as ErrorCorrectionLevel
|
|
55
|
+
},
|
|
56
|
+
imageOptions: {
|
|
57
|
+
hideBackgroundDots: true,
|
|
58
|
+
imageSize: 0.4,
|
|
59
|
+
margin: 15,
|
|
60
|
+
crossOrigin: 'anonymous',
|
|
61
|
+
},
|
|
62
|
+
dotsOptions: {
|
|
63
|
+
color: darken(theme.palette.primary.main, 0.3),
|
|
64
|
+
// gradient: {
|
|
65
|
+
// type: 'linear', // 'radial'
|
|
66
|
+
// rotation: 0,
|
|
67
|
+
// colorStops: [{ offset: 0, color: theme.palette.primary.main }, { offset: 1, color: theme.palette.secondary.main }]
|
|
68
|
+
// },
|
|
69
|
+
type: 'square' as DotType // "dots" | "rounded" | "classy" | "classy-rounded" | "square" | "extra-rounded";
|
|
70
|
+
},
|
|
71
|
+
backgroundOptions: {
|
|
72
|
+
color: 'white',
|
|
73
|
+
// gradient: {
|
|
74
|
+
// type: 'linear', // 'radial'
|
|
75
|
+
// rotation: 0,
|
|
76
|
+
// colorStops: [{ offset: 0, color: '#ededff' }, { offset: 1, color: '#e6e7ff' }]
|
|
77
|
+
// },
|
|
78
|
+
},
|
|
79
|
+
cornersSquareOptions: {
|
|
80
|
+
color: darken(theme.palette.secondary.main, 0.1),
|
|
81
|
+
type: 'square' as CornerSquareType,
|
|
82
|
+
// gradient: {
|
|
83
|
+
// type: 'linear', // 'radial'
|
|
84
|
+
// rotation: 180,
|
|
85
|
+
// colorStops: [{ offset: 0, color: '#25456e' }, { offset: 1, color: '#4267b2' }]
|
|
86
|
+
// },
|
|
87
|
+
},
|
|
88
|
+
cornersDotOptions: {
|
|
89
|
+
color: darken(theme.palette.secondary.main, 0.1),
|
|
90
|
+
type: 'square' as CornerDotType,
|
|
91
|
+
// gradient: {
|
|
92
|
+
// type: 'linear', // 'radial'
|
|
93
|
+
// rotation: 180,
|
|
94
|
+
// colorStops: [{ offset: 0, color: '#00266e' }, { offset: 1, color: '#4060b3' }]
|
|
95
|
+
// },
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
// Format de téléchargement par défaut
|
|
100
|
+
const [fileExt, setFileExt] = useState<Extension>("png");
|
|
101
|
+
const [qrCode] = useState<QRCodeStyling>(new QRCodeStyling(options));
|
|
102
|
+
const ref = useRef<HTMLDivElement>(null);
|
|
103
|
+
|
|
104
|
+
useEffect(() => {
|
|
105
|
+
if (ref.current) {
|
|
106
|
+
qrCode.append(ref.current);
|
|
107
|
+
}
|
|
108
|
+
}, [qrCode, ref]);
|
|
109
|
+
|
|
110
|
+
useEffect(() => {
|
|
111
|
+
if (!qrCode) return;
|
|
112
|
+
qrCode.update(options);
|
|
113
|
+
}, [qrCode, options]);
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
/* const onExtensionChange = (event: ChangeEvent<HTMLSelectElement>) => {
|
|
117
|
+
setFileExt(event.target.value as Extension);
|
|
118
|
+
}; */
|
|
119
|
+
|
|
120
|
+
const onDownloadClick = () => {
|
|
121
|
+
if (!qrCode) return;
|
|
122
|
+
qrCode.download({
|
|
123
|
+
extension: fileExt,
|
|
124
|
+
name:"movalib-qr-code"
|
|
125
|
+
});
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
return (
|
|
129
|
+
<Box>
|
|
130
|
+
<div ref={ref} style={styles.inputWrapper} />
|
|
131
|
+
{/* <select onChange={onExtensionChange} value={fileExt}>
|
|
132
|
+
<option value="svg">SVG</option>
|
|
133
|
+
<option value="png">PNG</option>
|
|
134
|
+
<option value="jpeg">JPEG</option>
|
|
135
|
+
<option value="webp">WEBP</option>
|
|
136
|
+
</select> */}
|
|
137
|
+
{showDownload &&
|
|
138
|
+
<Box sx={{ display:'flex', justifyContent:'center'}}>
|
|
139
|
+
<Button variant='outlined' onClick={onDownloadClick} sx={{ color: darken(theme.palette.primary.main, 0.2)}}>Télécharger</Button>
|
|
140
|
+
</Box>
|
|
141
|
+
}
|
|
142
|
+
</Box>
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export default QRCode;
|
|
Binary file
|
|
Binary file
|
|
Binary file
|