@movalib/movalib-commons 1.0.4 → 1.0.6
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/MovaCopyright.js +6 -4
- package/dist/MovaLogin.d.ts +2 -1
- package/dist/MovaLogin.js +28 -27
- package/dist/MovaSnackbar.js +10 -5
- package/dist/TestButton.js +5 -3
- package/dist/helpers/Enums.js +5 -2
- package/dist/helpers/Tools.js +2 -1
- package/dist/helpers/Types.js +2 -1
- package/dist/helpers/Validator.js +9 -3
- package/dist/index.js +14 -4
- package/package.json +1 -1
- package/src/MovaLogin.tsx +5 -8
- package/tsconfig.json +1 -1
package/dist/MovaCopyright.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __assign = (this && this.__assign) || function () {
|
|
2
3
|
__assign = Object.assign || function(t) {
|
|
3
4
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
@@ -9,9 +10,10 @@ var __assign = (this && this.__assign) || function () {
|
|
|
9
10
|
};
|
|
10
11
|
return __assign.apply(this, arguments);
|
|
11
12
|
};
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
15
|
+
var material_1 = require("@mui/material");
|
|
14
16
|
function MovaCopyright(props) {
|
|
15
|
-
return (
|
|
17
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.Typography, __assign({ variant: "body2", color: "text.secondary", align: "center" }, props, { children: ['Copyright © ', (0, jsx_runtime_1.jsx)(material_1.Link, __assign({ color: "inherit", href: "https://www.movalib.com" }, { children: "Movalib.com" })), ' ', new Date().getFullYear(), '.'] })));
|
|
16
18
|
}
|
|
17
|
-
|
|
19
|
+
exports.default = MovaCopyright;
|
package/dist/MovaLogin.d.ts
CHANGED
|
@@ -2,8 +2,9 @@ import { FunctionComponent } from "react";
|
|
|
2
2
|
import { MovaLoginForm } from "./helpers/Types";
|
|
3
3
|
import { MovaAppType } from "./helpers/Enums";
|
|
4
4
|
interface MovaLoginProps {
|
|
5
|
-
movaAppType: MovaAppType;
|
|
5
|
+
movaAppType: MovaAppType | "GARAGE" | "USER" | "ADMIN";
|
|
6
6
|
onSubmit: (form: MovaLoginForm) => void;
|
|
7
|
+
loading?: boolean;
|
|
7
8
|
}
|
|
8
9
|
declare const MovaLogin: FunctionComponent<MovaLoginProps>;
|
|
9
10
|
export default MovaLogin;
|
package/dist/MovaLogin.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __assign = (this && this.__assign) || function () {
|
|
2
3
|
__assign = Object.assign || function(t) {
|
|
3
4
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
@@ -45,17 +46,21 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
45
46
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
47
|
}
|
|
47
48
|
};
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
49
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
|
+
};
|
|
52
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
54
|
+
var react_1 = require("react");
|
|
55
|
+
var lab_1 = require("@mui/lab");
|
|
56
|
+
var logo_large_png_1 = __importDefault(require("./assets/images/logo/logo_large.png"));
|
|
57
|
+
var logo_pro_large_png_1 = __importDefault(require("./assets/images/logo/logo_pro_large.png"));
|
|
58
|
+
var leaf_green_large_png_1 = __importDefault(require("./assets/images/logo/leaf_green_large.png"));
|
|
59
|
+
var leaf_pink_large_png_1 = __importDefault(require("./assets/images/logo/leaf_pink_large.png"));
|
|
60
|
+
var material_1 = require("@mui/material");
|
|
61
|
+
var MovaCopyright_1 = __importDefault(require("./MovaCopyright"));
|
|
62
|
+
var Enums_1 = require("./helpers/Enums");
|
|
63
|
+
var Validator_1 = require("./helpers/Validator");
|
|
59
64
|
// Permet de centrer le contenu de l'application
|
|
60
65
|
var styles = {
|
|
61
66
|
display: 'flex',
|
|
@@ -68,10 +73,10 @@ var initialFormState = {
|
|
|
68
73
|
password: { value: '', isValid: true },
|
|
69
74
|
};
|
|
70
75
|
var MovaLogin = function (_a) {
|
|
71
|
-
var movaAppType = _a.movaAppType, onSubmit = _a.onSubmit;
|
|
72
|
-
var _b = useState(initialFormState), form = _b[0], setForm = _b[1];
|
|
73
|
-
var _c = useState(""), message = _c[0], setMessage = _c[1];
|
|
74
|
-
|
|
76
|
+
var loading = _a.loading, movaAppType = _a.movaAppType, onSubmit = _a.onSubmit;
|
|
77
|
+
var _b = (0, react_1.useState)(initialFormState), form = _b[0], setForm = _b[1];
|
|
78
|
+
var _c = (0, react_1.useState)(""), message = _c[0], setMessage = _c[1];
|
|
79
|
+
//const [loading, setLoading] = useState(false);
|
|
75
80
|
var handleInputChange = function (e) {
|
|
76
81
|
var _a;
|
|
77
82
|
var fieldName = e.target.name;
|
|
@@ -82,7 +87,6 @@ var MovaLogin = function (_a) {
|
|
|
82
87
|
var handleSubmit = function (e) { return __awaiter(void 0, void 0, void 0, function () {
|
|
83
88
|
return __generator(this, function (_a) {
|
|
84
89
|
e.preventDefault();
|
|
85
|
-
setLoading(true);
|
|
86
90
|
try {
|
|
87
91
|
if (validateForm() && onSubmit) {
|
|
88
92
|
// Si le formulaire est valide, on appel la function callback transmise en props
|
|
@@ -92,16 +96,13 @@ var MovaLogin = function (_a) {
|
|
|
92
96
|
catch (error) {
|
|
93
97
|
console.error('Error occurred during submission:', error);
|
|
94
98
|
}
|
|
95
|
-
finally {
|
|
96
|
-
setLoading(false);
|
|
97
|
-
}
|
|
98
99
|
return [2 /*return*/];
|
|
99
100
|
});
|
|
100
101
|
}); };
|
|
101
102
|
var validateForm = function () {
|
|
102
103
|
var newForm = form;
|
|
103
104
|
// Validator email
|
|
104
|
-
if (!validateEmail(form.email.value.length)) {
|
|
105
|
+
if (!(0, Validator_1.validateEmail)(form.email.value.length)) {
|
|
105
106
|
var errorMsg = 'Adresse email invalide';
|
|
106
107
|
var newField = { value: form.email.value, error: errorMsg, isValid: false };
|
|
107
108
|
newForm = __assign(__assign({}, newForm), { email: newField });
|
|
@@ -124,23 +125,23 @@ var MovaLogin = function (_a) {
|
|
|
124
125
|
return newForm.email.isValid && newForm.password.isValid;
|
|
125
126
|
};
|
|
126
127
|
var getMovaLogo = function () {
|
|
127
|
-
return movaAppType === MovaAppType.GARAGE ?
|
|
128
|
-
movaAppType === MovaAppType.USER ?
|
|
129
|
-
movaAppType === MovaAppType.ADMIN ?
|
|
128
|
+
return movaAppType === Enums_1.MovaAppType.GARAGE ? logo_pro_large_png_1.default :
|
|
129
|
+
movaAppType === Enums_1.MovaAppType.USER ? logo_large_png_1.default :
|
|
130
|
+
movaAppType === Enums_1.MovaAppType.ADMIN ? logo_large_png_1.default : logo_large_png_1.default;
|
|
130
131
|
};
|
|
131
|
-
return (
|
|
132
|
+
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',
|
|
132
133
|
float: 'left',
|
|
133
134
|
width: '250px',
|
|
134
135
|
height: '400px',
|
|
135
136
|
top: '-20%',
|
|
136
137
|
left: '3%',
|
|
137
138
|
opacity: '0.3',
|
|
138
|
-
zIndex: -8 }, alt: 'Feuille Verte Movalib' }),
|
|
139
|
+
zIndex: -8 }, alt: 'Feuille Verte Movalib' }), (0, jsx_runtime_1.jsxs)(material_1.Container, __assign({ component: "main", maxWidth: "xs" }, { children: [(0, jsx_runtime_1.jsx)(material_1.CssBaseline, {}), (0, jsx_runtime_1.jsxs)(material_1.Box, __assign({ sx: {
|
|
139
140
|
marginTop: 6,
|
|
140
141
|
display: 'flex',
|
|
141
142
|
flexDirection: 'column',
|
|
142
143
|
alignItems: 'center',
|
|
143
|
-
} }, { children: [
|
|
144
|
+
} }, { 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" }) })), message && (0, jsx_runtime_1.jsx)(material_1.Alert, __assign({ severity: "error", sx: { mb: 2 } }, { children: message })), (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: "#", variant: "body2", color: "text.secondary" }, { children: "Mot de passe oubli\u00E9 ?" })) })), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true }, { children: (0, jsx_runtime_1.jsx)(material_1.Link, __assign({ href: "#", variant: "body2", color: "text.secondary" }, { children: "Créer un 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',
|
|
144
145
|
float: 'right',
|
|
145
146
|
width: '250px',
|
|
146
147
|
height: '400px',
|
|
@@ -149,4 +150,4 @@ var MovaLogin = function (_a) {
|
|
|
149
150
|
opacity: '0.3',
|
|
150
151
|
zIndex: '-10' }, alt: 'Feuille Rose Movalib' })] })));
|
|
151
152
|
};
|
|
152
|
-
|
|
153
|
+
exports.default = MovaLogin;
|
package/dist/MovaSnackbar.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __assign = (this && this.__assign) || function () {
|
|
2
3
|
__assign = Object.assign || function(t) {
|
|
3
4
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
@@ -9,9 +10,13 @@ var __assign = (this && this.__assign) || function () {
|
|
|
9
10
|
};
|
|
10
11
|
return __assign.apply(this, arguments);
|
|
11
12
|
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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 material_1 = require("@mui/material");
|
|
19
|
+
var CloseRounded_1 = __importDefault(require("@mui/icons-material/CloseRounded"));
|
|
15
20
|
var MovaSnackbar = function (_a) {
|
|
16
21
|
var snackbar = _a.snackbar, setSnackbar = _a.setSnackbar;
|
|
17
22
|
/**
|
|
@@ -29,6 +34,6 @@ var MovaSnackbar = function (_a) {
|
|
|
29
34
|
var handleCloseAlert = function (event) {
|
|
30
35
|
setSnackbar({ open: false, message: '', severity: undefined });
|
|
31
36
|
};
|
|
32
|
-
return (
|
|
37
|
+
return ((0, jsx_runtime_1.jsx)(material_1.Snackbar, __assign({ open: snackbar.open, autoHideDuration: 5000, onClose: handleClose }, { children: (0, jsx_runtime_1.jsx)(material_1.Alert, __assign({ severity: snackbar.severity, variant: "filled", sx: { width: '100%' }, action: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, __assign({ size: "small", "aria-label": "close", color: "inherit", onClick: handleCloseAlert }, { children: (0, jsx_runtime_1.jsx)(CloseRounded_1.default, { fontSize: "small" }) })) }) }, { children: snackbar.message })) })));
|
|
33
38
|
};
|
|
34
|
-
|
|
39
|
+
exports.default = MovaSnackbar;
|
package/dist/TestButton.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
2
4
|
var TestButton = function (_a) {
|
|
3
5
|
var label = _a.label;
|
|
4
|
-
return
|
|
6
|
+
return (0, jsx_runtime_1.jsx)("button", { children: label });
|
|
5
7
|
};
|
|
6
|
-
|
|
8
|
+
exports.default = TestButton;
|
package/dist/helpers/Enums.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MovaAppType = void 0;
|
|
4
|
+
var MovaAppType;
|
|
2
5
|
(function (MovaAppType) {
|
|
3
6
|
/**
|
|
4
7
|
* Application Garagiste
|
|
@@ -12,4 +15,4 @@ export var MovaAppType;
|
|
|
12
15
|
* Application Administrateur (MovaTeam)
|
|
13
16
|
*/
|
|
14
17
|
MovaAppType["ADMIN"] = "ADMIN";
|
|
15
|
-
})(MovaAppType || (MovaAppType = {}));
|
|
18
|
+
})(MovaAppType = exports.MovaAppType || (exports.MovaAppType = {}));
|
package/dist/helpers/Tools.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
package/dist/helpers/Types.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateEmail = exports.validateText = exports.validatePhoneNumber = void 0;
|
|
1
4
|
/**
|
|
2
5
|
* Un email valide
|
|
3
6
|
*/
|
|
@@ -27,21 +30,24 @@ var userNameRegex = /^[a-z0-9_-]{3,20}$/;
|
|
|
27
30
|
* Un texte pouvant contenir des lettres, chiffres et quelques caractères spéciaux
|
|
28
31
|
*/
|
|
29
32
|
var textRegex = /^[a-zA-Z0-9\s.,!?'"()+=-_-éèçà]+$/;
|
|
30
|
-
|
|
33
|
+
function validatePhoneNumber(phoneNumber) {
|
|
31
34
|
if (phoneNumber === null || phoneNumber === undefined) {
|
|
32
35
|
return false;
|
|
33
36
|
}
|
|
34
37
|
return phoneNumberRegex.test(phoneNumber);
|
|
35
38
|
}
|
|
36
|
-
|
|
39
|
+
exports.validatePhoneNumber = validatePhoneNumber;
|
|
40
|
+
function validateText(text) {
|
|
37
41
|
if (text === null || text === undefined) {
|
|
38
42
|
return false;
|
|
39
43
|
}
|
|
40
44
|
return textRegex.test(text);
|
|
41
45
|
}
|
|
42
|
-
|
|
46
|
+
exports.validateText = validateText;
|
|
47
|
+
function validateEmail(email) {
|
|
43
48
|
if (email === null || email === undefined) {
|
|
44
49
|
return false;
|
|
45
50
|
}
|
|
46
51
|
return emailRegex.test(email);
|
|
47
52
|
}
|
|
53
|
+
exports.validateEmail = validateEmail;
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
// src/index.ts
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.MovaCopyright = exports.MovaLogin = exports.MovaSnackbar = exports.TestButton = void 0;
|
|
8
|
+
var TestButton_1 = require("./TestButton");
|
|
9
|
+
Object.defineProperty(exports, "TestButton", { enumerable: true, get: function () { return __importDefault(TestButton_1).default; } });
|
|
10
|
+
var MovaSnackbar_1 = require("./MovaSnackbar");
|
|
11
|
+
Object.defineProperty(exports, "MovaSnackbar", { enumerable: true, get: function () { return __importDefault(MovaSnackbar_1).default; } });
|
|
12
|
+
var MovaLogin_1 = require("./MovaLogin");
|
|
13
|
+
Object.defineProperty(exports, "MovaLogin", { enumerable: true, get: function () { return __importDefault(MovaLogin_1).default; } });
|
|
14
|
+
var MovaCopyright_1 = require("./MovaCopyright");
|
|
15
|
+
Object.defineProperty(exports, "MovaCopyright", { enumerable: true, get: function () { return __importDefault(MovaCopyright_1).default; } });
|
package/package.json
CHANGED
package/src/MovaLogin.tsx
CHANGED
|
@@ -24,15 +24,16 @@ const initialFormState = {
|
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
interface MovaLoginProps {
|
|
27
|
-
movaAppType: MovaAppType,
|
|
28
|
-
onSubmit: (form: MovaLoginForm) => void
|
|
27
|
+
movaAppType: MovaAppType | "GARAGE" | "USER" | "ADMIN",
|
|
28
|
+
onSubmit: (form: MovaLoginForm) => void,
|
|
29
|
+
loading?: boolean
|
|
29
30
|
}
|
|
30
31
|
|
|
31
|
-
const MovaLogin: FunctionComponent<MovaLoginProps> = ({ movaAppType, onSubmit }) => {
|
|
32
|
+
const MovaLogin: FunctionComponent<MovaLoginProps> = ({ loading, movaAppType, onSubmit }) => {
|
|
32
33
|
|
|
33
34
|
const [form, setForm] = useState<MovaLoginForm>(initialFormState);
|
|
34
35
|
const [message, setMessage] = useState<string>("");
|
|
35
|
-
const [loading, setLoading] = useState(false);
|
|
36
|
+
//const [loading, setLoading] = useState(false);
|
|
36
37
|
|
|
37
38
|
const handleInputChange = (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>): void => {
|
|
38
39
|
const fieldName: string = e.target.name;
|
|
@@ -44,8 +45,6 @@ const MovaLogin: FunctionComponent<MovaLoginProps> = ({ movaAppType, onSubmit })
|
|
|
44
45
|
|
|
45
46
|
const handleSubmit = async (e: FormEvent) => {
|
|
46
47
|
e.preventDefault();
|
|
47
|
-
setLoading(true);
|
|
48
|
-
|
|
49
48
|
try {
|
|
50
49
|
if(validateForm() && onSubmit) {
|
|
51
50
|
// Si le formulaire est valide, on appel la function callback transmise en props
|
|
@@ -54,8 +53,6 @@ const MovaLogin: FunctionComponent<MovaLoginProps> = ({ movaAppType, onSubmit })
|
|
|
54
53
|
|
|
55
54
|
}catch (error){
|
|
56
55
|
console.error('Error occurred during submission:', error);
|
|
57
|
-
}finally {
|
|
58
|
-
setLoading(false);
|
|
59
56
|
}
|
|
60
57
|
}
|
|
61
58
|
|
package/tsconfig.json
CHANGED
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
|
|
30
30
|
|
|
31
31
|
/* Modules */
|
|
32
|
-
"module": "
|
|
32
|
+
"module": "CommonJS", /* Specify what module code is generated. */
|
|
33
33
|
// "rootDir": "./", /* Specify the root folder within your source files. */
|
|
34
34
|
"moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
|
|
35
35
|
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
|