@movalib/movalib-commons 1.0.15 → 1.0.16
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 +33 -0
- package/dist/devIndex.js +34 -0
- package/dist/{GenderSelector.d.ts → src/GenderSelector.d.ts} +2 -1
- package/dist/src/GenderSelector.js +20 -0
- package/dist/{MovaCopyright.js → src/MovaCopyright.js} +1 -1
- package/dist/{MovaLogin.js → src/MovaLogin.js} +10 -23
- package/dist/{MovaSignUp.js → src/MovaSignUp.js} +19 -25
- package/dist/src/helpers/Tools.d.ts +10 -0
- package/dist/src/helpers/Tools.js +18 -0
- package/dist/theme.d.ts +2 -0
- package/dist/theme.js +95 -0
- package/package.json +7 -8
- package/public/favicon.ico +0 -0
- package/public/index.html +9 -0
- package/src/GenderSelector.tsx +6 -4
- package/src/MovaCopyright.tsx +1 -1
- package/src/MovaLogin.tsx +16 -26
- package/src/MovaSignUp.tsx +37 -34
- package/src/helpers/Tools.ts +17 -1
- package/theme.ts +95 -0
- package/tsconfig.json +1 -1
- package/webpack.config.js +35 -0
- package/dist/GenderSelector.js +0 -20
- package/dist/helpers/Tools.js +0 -2
- /package/dist/{helpers/Tools.d.ts → devIndex.d.ts} +0 -0
- /package/dist/{MovaCopyright.d.ts → src/MovaCopyright.d.ts} +0 -0
- /package/dist/{MovaLogin.d.ts → src/MovaLogin.d.ts} +0 -0
- /package/dist/{MovaSignUp.d.ts → src/MovaSignUp.d.ts} +0 -0
- /package/dist/{MovaSnackbar.d.ts → src/MovaSnackbar.d.ts} +0 -0
- /package/dist/{MovaSnackbar.js → src/MovaSnackbar.js} +0 -0
- /package/dist/{TestButton.d.ts → src/TestButton.d.ts} +0 -0
- /package/dist/{TestButton.js → src/TestButton.js} +0 -0
- /package/dist/{helpers → src/helpers}/Enums.d.ts +0 -0
- /package/dist/{helpers → src/helpers}/Enums.js +0 -0
- /package/dist/{helpers → src/helpers}/Types.d.ts +0 -0
- /package/dist/{helpers → src/helpers}/Types.js +0 -0
- /package/dist/{helpers → src/helpers}/Validator.d.ts +0 -0
- /package/dist/{helpers → src/helpers}/Validator.js +0 -0
- /package/dist/{index.d.ts → src/index.d.ts} +0 -0
- /package/dist/{index.js → src/index.js} +0 -0
- /package/dist/{models → src/models}/Address.d.ts +0 -0
- /package/dist/{models → src/models}/Address.js +0 -0
- /package/dist/{models → src/models}/Role.d.ts +0 -0
- /package/dist/{models → src/models}/Role.js +0 -0
- /package/dist/{models → src/models}/User.d.ts +0 -0
- /package/dist/{models → src/models}/User.js +0 -0
package/devIndex.tsx
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { createRoot } from 'react-dom/client';
|
|
3
|
+
// Import des composants de la bibliothèque
|
|
4
|
+
import MovaLogin from './src/MovaLogin';
|
|
5
|
+
import { MovaLoginForm } from './src/helpers/Types';
|
|
6
|
+
import { MovaAppType } from './src/helpers/Enums';
|
|
7
|
+
import { ThemeProvider } from '@mui/material/styles';
|
|
8
|
+
import theme from './theme'; // Import du thème personnalisé
|
|
9
|
+
import MovaSignUp from './src/MovaSignUp';
|
|
10
|
+
|
|
11
|
+
const App = () => {
|
|
12
|
+
return (
|
|
13
|
+
<div>
|
|
14
|
+
<ThemeProvider theme={theme}>
|
|
15
|
+
<MovaLogin movaAppType={MovaAppType.GARAGE} onSubmit={function (form: MovaLoginForm): void {
|
|
16
|
+
alert('Form Submitted !');
|
|
17
|
+
} } />
|
|
18
|
+
|
|
19
|
+
<MovaSignUp movaAppType={MovaAppType.USER} onSubmit={function (form: MovaLoginForm): void {
|
|
20
|
+
alert('Form Submitted !');
|
|
21
|
+
} } />
|
|
22
|
+
</ThemeProvider>
|
|
23
|
+
</div>
|
|
24
|
+
);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const root = createRoot(document.getElementById('root')!);
|
|
28
|
+
|
|
29
|
+
root.render(
|
|
30
|
+
<React.StrictMode>
|
|
31
|
+
<App />
|
|
32
|
+
</React.StrictMode>
|
|
33
|
+
);
|
package/dist/devIndex.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
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 = __importDefault(require("react"));
|
|
19
|
+
var client_1 = require("react-dom/client");
|
|
20
|
+
// Import des composants de la bibliothèque
|
|
21
|
+
var MovaLogin_1 = __importDefault(require("./src/MovaLogin"));
|
|
22
|
+
var Enums_1 = require("./src/helpers/Enums");
|
|
23
|
+
var styles_1 = require("@mui/material/styles");
|
|
24
|
+
var theme_1 = __importDefault(require("./theme")); // Import du thème personnalisé
|
|
25
|
+
var MovaSignUp_1 = __importDefault(require("./src/MovaSignUp"));
|
|
26
|
+
var App = function () {
|
|
27
|
+
return ((0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsxs)(styles_1.ThemeProvider, __assign({ theme: theme_1.default }, { children: [(0, jsx_runtime_1.jsx)(MovaLogin_1.default, { movaAppType: Enums_1.MovaAppType.GARAGE, onSubmit: function (form) {
|
|
28
|
+
alert('Form Submitted !');
|
|
29
|
+
} }), (0, jsx_runtime_1.jsx)(MovaSignUp_1.default, { movaAppType: Enums_1.MovaAppType.USER, onSubmit: function (form) {
|
|
30
|
+
alert('Form Submitted !');
|
|
31
|
+
} })] })) }));
|
|
32
|
+
};
|
|
33
|
+
var root = (0, client_1.createRoot)(document.getElementById('root'));
|
|
34
|
+
root.render((0, jsx_runtime_1.jsx)(react_1.default.StrictMode, { children: (0, jsx_runtime_1.jsx)(App, {}) }));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { SelectChangeEvent } from '@mui/material';
|
|
2
|
+
import { SelectChangeEvent, SxProps, Theme } from '@mui/material';
|
|
3
3
|
import { MovaFormField } from './helpers/Types';
|
|
4
4
|
interface GenderSelectorProps {
|
|
5
5
|
handleSelectChange: (event: SelectChangeEvent<string>) => void;
|
|
@@ -7,6 +7,7 @@ interface GenderSelectorProps {
|
|
|
7
7
|
gender: MovaFormField;
|
|
8
8
|
};
|
|
9
9
|
required?: boolean;
|
|
10
|
+
sx?: SxProps<Theme>;
|
|
10
11
|
}
|
|
11
12
|
declare const GenderSelector: React.FC<GenderSelectorProps>;
|
|
12
13
|
export default GenderSelector;
|
|
@@ -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 GenderSelector = function (_a) {
|
|
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 })] })));
|
|
19
|
+
};
|
|
20
|
+
exports.default = GenderSelector;
|
|
@@ -14,6 +14,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
14
14
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
15
15
|
var material_1 = require("@mui/material");
|
|
16
16
|
function MovaCopyright(props) {
|
|
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(), '.'] })));
|
|
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", target: "_blank", rel: "noopener noreferrer" }, { children: "Movalib.com" })), ' ', new Date().getFullYear(), '.'] })));
|
|
18
18
|
}
|
|
19
19
|
exports.default = MovaCopyright;
|
|
@@ -61,6 +61,7 @@ var material_1 = require("@mui/material");
|
|
|
61
61
|
var MovaCopyright_1 = __importDefault(require("./MovaCopyright"));
|
|
62
62
|
var Enums_1 = require("./helpers/Enums");
|
|
63
63
|
var Validator_1 = require("./helpers/Validator");
|
|
64
|
+
var Tools_1 = require("./helpers/Tools");
|
|
64
65
|
// Permet de centrer le contenu de l'application
|
|
65
66
|
var styles = {
|
|
66
67
|
display: 'flex',
|
|
@@ -76,7 +77,6 @@ var MovaLogin = function (_a) {
|
|
|
76
77
|
var loading = _a.loading, movaAppType = _a.movaAppType, onSubmit = _a.onSubmit, alertMessage = _a.alertMessage, alertSeverity = _a.alertSeverity;
|
|
77
78
|
var _b = (0, react_1.useState)(initialFormState), form = _b[0], setForm = _b[1];
|
|
78
79
|
var _c = (0, react_1.useState)(""), message = _c[0], setMessage = _c[1];
|
|
79
|
-
//const [loading, setLoading] = useState(false);
|
|
80
80
|
var handleInputChange = function (e) {
|
|
81
81
|
var _a;
|
|
82
82
|
var fieldName = e.target.name;
|
|
@@ -100,27 +100,14 @@ var MovaLogin = function (_a) {
|
|
|
100
100
|
});
|
|
101
101
|
}); };
|
|
102
102
|
var validateForm = function () {
|
|
103
|
-
var newForm = form;
|
|
104
|
-
// Validator
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
var newField = { value: form.email.value, error: '', isValid: true };
|
|
112
|
-
newForm = __assign(__assign({}, newForm), { email: newField });
|
|
113
|
-
}
|
|
114
|
-
// Validator password
|
|
115
|
-
if (form.password.value.length < 8) {
|
|
116
|
-
var errorMsg = 'Votre mot de passe doit faire au moins 8 caractères de long.';
|
|
117
|
-
var newField = { value: form.password.value, error: errorMsg, isValid: false };
|
|
118
|
-
newForm = __assign(__assign({}, newForm), { password: newField });
|
|
119
|
-
}
|
|
120
|
-
else {
|
|
121
|
-
var newField = { value: form.password.value, error: '', isValid: true };
|
|
122
|
-
newForm = __assign(__assign({}, newForm), { password: newField });
|
|
123
|
-
}
|
|
103
|
+
var newForm = __assign({}, form);
|
|
104
|
+
// Validator pour les champs obligatoires
|
|
105
|
+
newForm.email = (0, Tools_1.validateField)(form.email, function (value) { return !!value; }, 'Champ obligatoire');
|
|
106
|
+
newForm.password = (0, Tools_1.validateField)(form.password, function (value) { return !!value; }, 'Champ obligatoire');
|
|
107
|
+
// Validator pour l'email
|
|
108
|
+
newForm.email = (0, Tools_1.validateField)(form.email, Validator_1.validateEmail, 'Adresse email invalide');
|
|
109
|
+
// Validator pour le mot de passe
|
|
110
|
+
newForm.password = (0, Tools_1.validateField)(form.password, function (value) { return value.length >= 8; }, 'Votre mot de passe doit faire au moins 8 caractères de long');
|
|
124
111
|
setForm(newForm);
|
|
125
112
|
return newForm.email.isValid && newForm.password.isValid;
|
|
126
113
|
};
|
|
@@ -141,7 +128,7 @@ var MovaLogin = function (_a) {
|
|
|
141
128
|
display: 'flex',
|
|
142
129
|
flexDirection: 'column',
|
|
143
130
|
alignItems: 'center',
|
|
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" }) })), 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: "
|
|
131
|
+
} }, { 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({ href: "/signup", 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',
|
|
145
132
|
float: 'right',
|
|
146
133
|
width: '250px',
|
|
147
134
|
height: '400px',
|
|
@@ -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 GenderSelector_1 = __importDefault(require("./GenderSelector"));
|
|
65
|
+
var Tools_1 = require("./helpers/Tools");
|
|
65
66
|
// Permet de centrer le contenu de l'application
|
|
66
67
|
var styles = {
|
|
67
68
|
display: 'flex',
|
|
@@ -82,7 +83,6 @@ 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)(initialUserFormState), userForm = _b[0], setUserForm = _b[1];
|
|
84
85
|
var _c = (0, react_1.useState)(""), message = _c[0], setMessage = _c[1];
|
|
85
|
-
//const [loading, setLoading] = useState(false);
|
|
86
86
|
var handleInputChange = function (e) {
|
|
87
87
|
var _a;
|
|
88
88
|
var fieldName = e.target.name;
|
|
@@ -120,29 +120,23 @@ var MovaLogin = function (_a) {
|
|
|
120
120
|
});
|
|
121
121
|
}); };
|
|
122
122
|
var validateForm = function () {
|
|
123
|
-
var newForm = userForm;
|
|
124
|
-
// Validator
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
var newField = { value: userForm.password.value, error: errorMsg, isValid: false };
|
|
138
|
-
newForm = __assign(__assign({}, newForm), { password: newField });
|
|
139
|
-
}
|
|
140
|
-
else {
|
|
141
|
-
var newField = { value: userForm.password.value, error: '', isValid: true };
|
|
142
|
-
newForm = __assign(__assign({}, newForm), { password: newField });
|
|
143
|
-
}
|
|
123
|
+
var newForm = __assign({}, userForm);
|
|
124
|
+
// Validator pour les champs obligatoires
|
|
125
|
+
newForm.firstname = (0, Tools_1.validateField)(userForm.firstname, function (value) { return !!value; }, 'Champ obligatoire');
|
|
126
|
+
newForm.lastname = (0, Tools_1.validateField)(userForm.lastname, function (value) { return !!value; }, 'Champ obligatoire');
|
|
127
|
+
newForm.email = (0, Tools_1.validateField)(userForm.email, function (value) { return !!value; }, 'Champ obligatoire');
|
|
128
|
+
newForm.password = (0, Tools_1.validateField)(userForm.password, function (value) { return !!value; }, 'Champ obligatoire');
|
|
129
|
+
newForm.gender = (0, Tools_1.validateField)(userForm.gender, function (value) { return !!value; }, 'Champ obligatoire');
|
|
130
|
+
newForm.birthDate = (0, Tools_1.validateField)(userForm.birthDate, function (value) { return !!value; }, 'Champ obligatoire');
|
|
131
|
+
// Validator pour l'email
|
|
132
|
+
newForm.email = (0, Tools_1.validateField)(userForm.email, Validator_1.validateEmail, 'Adresse email invalide');
|
|
133
|
+
// Validator pour le mot de passe
|
|
134
|
+
newForm.password = (0, Tools_1.validateField)(userForm.password, function (value) { return value.length >= 8; }, 'Votre mot de passe doit faire au moins 8 caractères de long');
|
|
135
|
+
// Validator pour les CGU
|
|
136
|
+
newForm.acceptsTerms = (0, Tools_1.validateField)(userForm.acceptsTerms, function (value) { return Boolean(value); }, 'Vous devez accepter les termes de nos CGU');
|
|
144
137
|
setUserForm(newForm);
|
|
145
|
-
return newForm.
|
|
138
|
+
return newForm.firstname.isValid && newForm.lastname.isValid && newForm.email.isValid
|
|
139
|
+
&& newForm.password.isValid && newForm.gender.isValid && newForm.birthDate.isValid;
|
|
146
140
|
};
|
|
147
141
|
var getMovaLogo = function () {
|
|
148
142
|
return movaAppType === Enums_1.MovaAppType.GARAGE ? logo_pro_large_png_1.default :
|
|
@@ -161,9 +155,9 @@ var MovaLogin = function (_a) {
|
|
|
161
155
|
display: 'flex',
|
|
162
156
|
flexDirection: 'column',
|
|
163
157
|
alignItems: 'center',
|
|
164
|
-
} }, { children: [(0, jsx_runtime_1.jsx)("img", { src: getMovaLogo(), style: { width: '50%' } }), (0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "
|
|
158
|
+
} }, { children: [(0, jsx_runtime_1.jsx)("img", { src: getMovaLogo(), style: { width: '50%' } }), (0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "button", sx: { pt: 2 } }, { children: "Nouveau compte utilisateur" }))] })), (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, autoFocus: true, fullWidth: true, id: "firstname", label: "Pr\u00E9nom", name: "firstname", autoComplete: "given-name", onChange: function (e) { return handleInputChange(e); }, value: userForm.firstname.value, error: Boolean(userForm.firstname.error), helperText: userForm.firstname.error }), (0, jsx_runtime_1.jsx)(material_1.TextField, { margin: "normal", required: true, fullWidth: true, id: "lastname", label: "Nom", name: "lastname", autoComplete: "family-name", onChange: function (e) { return handleInputChange(e); }, value: userForm.lastname.value, error: Boolean(userForm.lastname.error), helperText: userForm.lastname.error }), (0, jsx_runtime_1.jsx)(material_1.TextField, { margin: "normal", required: true, fullWidth: true, id: "email", label: "Adresse email", name: "email", autoComplete: "email", onChange: function (e) { return handleInputChange(e); }, value: userForm.email.value, error: !userForm.email.isValid, helperText: userForm.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: userForm.password.value, error: !userForm.password.isValid, helperText: Boolean(userForm.password.error) ? userForm.password.error : "8 caractères minimum" }), (0, jsx_runtime_1.jsx)(GenderSelector_1.default, { handleSelectChange: handleSelectChange, form: userForm, required: true, sx: { width: '40%', mr: 2 } }), (0, jsx_runtime_1.jsx)(material_1.TextField, { margin: "normal", required: true, name: "birthDate", label: "Date de naissance", type: "date", InputLabelProps: {
|
|
165
159
|
shrink: true,
|
|
166
|
-
}, autoComplete: "bday", value: userForm.
|
|
160
|
+
}, autoComplete: "bday", value: userForm.birthDate.value, error: !userForm.birthDate.isValid, helperText: userForm.birthDate.error, onChange: function (e) { return handleInputChange(e); }, sx: { width: '50%', float: 'right' } }), (0, jsx_runtime_1.jsxs)(material_1.FormControl, __assign({ error: !userForm.acceptsTerms.isValid }, { children: [(0, jsx_runtime_1.jsx)(material_1.FormControlLabel, { control: (0, jsx_runtime_1.jsx)(material_1.Checkbox, { name: "acceptsTerms", color: "primary", checked: userForm.acceptsTerms.value, onChange: function (e, checked) { return handleCheckboxChange(e, checked); } }), label: (0, jsx_runtime_1.jsxs)("span", { children: ["J'accepte les", ' ', (0, jsx_runtime_1.jsx)(material_1.Link, __assign({ href: "/terms-and-conditions", target: "_blank" }, { children: "Conditions G\u00E9n\u00E9rales d'Utilisation" }))] }) }), (0, jsx_runtime_1.jsx)(material_1.FormHelperText, { children: userForm.acceptsTerms.error })] })), alertMessage && alertSeverity && (0, jsx_runtime_1.jsx)(material_1.Alert, __assign({ severity: alertSeverity, sx: { mb: 2 } }, { children: alertMessage })), (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: "Cr\u00E9er 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',
|
|
167
161
|
float: 'right',
|
|
168
162
|
width: '250px',
|
|
169
163
|
height: '400px',
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { MovaFormField } from "./Types";
|
|
2
|
+
/**
|
|
3
|
+
* Valide un champ de formulaire en utilisant une fonction de validation personnalisée.
|
|
4
|
+
*
|
|
5
|
+
* @param {MovaFormField} field - Le champ de formulaire à valider.
|
|
6
|
+
* @param {(value: string) => boolean} validator - La fonction de validation à utiliser pour le champ.
|
|
7
|
+
* @param {string} errorMsg - Le message d'erreur à associer au champ si la validation échoue.
|
|
8
|
+
* @returns {MovaFormField} - Le champ de formulaire avec les propriétés `error` et `isValid` mises à jour.
|
|
9
|
+
*/
|
|
10
|
+
export declare const validateField: (field: MovaFormField, validator: (value: string) => boolean, errorMsg: string) => MovaFormField;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateField = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Valide un champ de formulaire en utilisant une fonction de validation personnalisée.
|
|
6
|
+
*
|
|
7
|
+
* @param {MovaFormField} field - Le champ de formulaire à valider.
|
|
8
|
+
* @param {(value: string) => boolean} validator - La fonction de validation à utiliser pour le champ.
|
|
9
|
+
* @param {string} errorMsg - Le message d'erreur à associer au champ si la validation échoue.
|
|
10
|
+
* @returns {MovaFormField} - Le champ de formulaire avec les propriétés `error` et `isValid` mises à jour.
|
|
11
|
+
*/
|
|
12
|
+
var validateField = function (field, validator, errorMsg) {
|
|
13
|
+
if (!validator(field.value)) {
|
|
14
|
+
return { value: field.value, error: errorMsg, isValid: false };
|
|
15
|
+
}
|
|
16
|
+
return { value: field.value, error: '', isValid: true };
|
|
17
|
+
};
|
|
18
|
+
exports.validateField = validateField;
|
package/dist/theme.d.ts
ADDED
package/dist/theme.js
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var styles_1 = require("@mui/material/styles");
|
|
4
|
+
var theme = (0, styles_1.createTheme)({
|
|
5
|
+
palette: {
|
|
6
|
+
background: {
|
|
7
|
+
paper: '#F0F0F0',
|
|
8
|
+
},
|
|
9
|
+
primary: {
|
|
10
|
+
main: '#BCD46C',
|
|
11
|
+
light: '#D2EDAB'
|
|
12
|
+
},
|
|
13
|
+
secondary: {
|
|
14
|
+
main: '#FFD25C',
|
|
15
|
+
light: '#FEE08E' //'#F1C0D9'
|
|
16
|
+
},
|
|
17
|
+
success: {
|
|
18
|
+
main: '#A8DB5EFF'
|
|
19
|
+
},
|
|
20
|
+
warning: {
|
|
21
|
+
main: '#FFD25C'
|
|
22
|
+
}
|
|
23
|
+
/* text: {
|
|
24
|
+
//light: '#E4E4E4',
|
|
25
|
+
} */
|
|
26
|
+
},
|
|
27
|
+
typography: {
|
|
28
|
+
fontFamily: 'Outfit, sans-serif', // Police de caractère par défaut
|
|
29
|
+
},
|
|
30
|
+
components: {
|
|
31
|
+
MuiAutocomplete: {
|
|
32
|
+
styleOverrides: {
|
|
33
|
+
noOptions: {
|
|
34
|
+
//display: 'none'
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
MuiSelect: {
|
|
39
|
+
styleOverrides: {
|
|
40
|
+
select: {
|
|
41
|
+
display: 'flex',
|
|
42
|
+
alignItems: 'center'
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
MuiTooltip: {
|
|
47
|
+
styleOverrides: {
|
|
48
|
+
// Name of the slot
|
|
49
|
+
tooltip: {
|
|
50
|
+
fontSize: 14,
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
MuiIconButton: {
|
|
55
|
+
styleOverrides: {
|
|
56
|
+
root: {
|
|
57
|
+
color: '#5f6368',
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
MuiDialog: {
|
|
62
|
+
styleOverrides: {
|
|
63
|
+
// Name of the slot
|
|
64
|
+
paper: {
|
|
65
|
+
backgroundColor: 'white',
|
|
66
|
+
margin: '18px'
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
MuiDialogActions: {
|
|
71
|
+
styleOverrides: {
|
|
72
|
+
root: {
|
|
73
|
+
margin: '8px'
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
MuiCard: {
|
|
78
|
+
styleOverrides: {
|
|
79
|
+
root: {
|
|
80
|
+
backgroundColor: 'white'
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
MuiTab: {
|
|
85
|
+
styleOverrides: {
|
|
86
|
+
root: {
|
|
87
|
+
"&.Mui-selected": {
|
|
88
|
+
"backgroundColor": "#BCD46C"
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
exports.default = theme;
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@movalib/movalib-commons",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.16",
|
|
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",
|
|
7
7
|
"private": false,
|
|
8
8
|
"scripts": {
|
|
9
|
+
"start": "webpack-dev-server --entry ./devIndex.tsx --open",
|
|
9
10
|
"build": "rm -rf dist && tsc && npm run copy-assets",
|
|
10
11
|
"copy-assets": "cp -r src/assets/ dist/assets/",
|
|
11
12
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
@@ -16,6 +17,7 @@
|
|
|
16
17
|
"license": "ISC",
|
|
17
18
|
"dependencies": {
|
|
18
19
|
"@types/node": "^16.18.53",
|
|
20
|
+
"@types/react": "^18.2.22",
|
|
19
21
|
"react": "^18.2.0",
|
|
20
22
|
"react-dom": "^18.2.0",
|
|
21
23
|
"react-scripts": "5.0.1"
|
|
@@ -33,13 +35,10 @@
|
|
|
33
35
|
"@mui/material": "^5.13.5",
|
|
34
36
|
"@types/react": "^18.2.22",
|
|
35
37
|
"@types/react-dom": "^18.2.7",
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
+
"file-loader": "^6.2.0",
|
|
39
|
+
"html-webpack-plugin": "^5.5.3",
|
|
40
|
+
"ts-loader": "^9.4.4",
|
|
38
41
|
"typescript": "^4.9.5",
|
|
39
|
-
"webpack": "^5.
|
|
40
|
-
},
|
|
41
|
-
"peerDependencies": {
|
|
42
|
-
"react": "^18.2.0",
|
|
43
|
-
"react-dom": "^18.2.0"
|
|
42
|
+
"webpack-cli": "^5.1.4"
|
|
44
43
|
}
|
|
45
44
|
}
|
|
Binary file
|
package/src/GenderSelector.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { ChangeEvent } from 'react';
|
|
2
|
-
import { FormControl, InputLabel, Select, MenuItem, SelectChangeEvent } from '@mui/material';
|
|
2
|
+
import { FormControl, InputLabel, Select, MenuItem, SelectChangeEvent, SxProps, Theme, FormHelperText } from '@mui/material';
|
|
3
3
|
import { MovaFormField } from './helpers/Types';
|
|
4
4
|
|
|
5
5
|
interface GenderSelectorProps {
|
|
@@ -7,12 +7,13 @@ interface GenderSelectorProps {
|
|
|
7
7
|
form: {
|
|
8
8
|
gender: MovaFormField
|
|
9
9
|
};
|
|
10
|
-
required?: boolean
|
|
10
|
+
required?: boolean,
|
|
11
|
+
sx?: SxProps<Theme>;
|
|
11
12
|
}
|
|
12
13
|
|
|
13
|
-
const GenderSelector: React.FC<GenderSelectorProps> = ({ handleSelectChange, form, required }) => {
|
|
14
|
+
const GenderSelector: React.FC<GenderSelectorProps> = ({ handleSelectChange, form, required, sx }) => {
|
|
14
15
|
return (
|
|
15
|
-
<FormControl fullWidth margin="normal" required={required}>
|
|
16
|
+
<FormControl fullWidth margin="normal" required={required} sx={{ ...sx }} error={!form.gender.isValid}>
|
|
16
17
|
<InputLabel id="gender-label">Sexe</InputLabel>
|
|
17
18
|
<Select
|
|
18
19
|
labelId="gender-label"
|
|
@@ -25,6 +26,7 @@ const GenderSelector: React.FC<GenderSelectorProps> = ({ handleSelectChange, for
|
|
|
25
26
|
<MenuItem value="FEMALE">Femme</MenuItem>
|
|
26
27
|
<MenuItem value="OTHER">Autre</MenuItem>
|
|
27
28
|
</Select>
|
|
29
|
+
<FormHelperText>{form.gender.error}</FormHelperText>
|
|
28
30
|
</FormControl>
|
|
29
31
|
);
|
|
30
32
|
};
|
package/src/MovaCopyright.tsx
CHANGED
|
@@ -5,7 +5,7 @@ function MovaCopyright(props: any) {
|
|
|
5
5
|
return (
|
|
6
6
|
<Typography variant="body2" color="text.secondary" align="center" {...props}>
|
|
7
7
|
{'Copyright © '}
|
|
8
|
-
<Link color="inherit" href="https://www.movalib.com">
|
|
8
|
+
<Link color="inherit" href="https://www.movalib.com" target="_blank" rel="noopener noreferrer">
|
|
9
9
|
Movalib.com
|
|
10
10
|
</Link>{' '}
|
|
11
11
|
{new Date().getFullYear()}
|
package/src/MovaLogin.tsx
CHANGED
|
@@ -9,6 +9,7 @@ import MovaCopyright from "./MovaCopyright";
|
|
|
9
9
|
import { MovaLoginForm, MovaFormField } from "./helpers/Types";
|
|
10
10
|
import { MovaAppType } from "./helpers/Enums";
|
|
11
11
|
import { validateEmail } from "./helpers/Validator";
|
|
12
|
+
import { validateField } from "./helpers/Tools";
|
|
12
13
|
|
|
13
14
|
// Permet de centrer le contenu de l'application
|
|
14
15
|
const styles: CSSProperties = {
|
|
@@ -42,8 +43,7 @@ interface MovaLoginProps {
|
|
|
42
43
|
const MovaLogin: FunctionComponent<MovaLoginProps> = ({ loading, movaAppType, onSubmit, alertMessage, alertSeverity }) => {
|
|
43
44
|
|
|
44
45
|
const [form, setForm] = useState<MovaLoginForm>(initialFormState);
|
|
45
|
-
const [message, setMessage] = useState<string>("");
|
|
46
|
-
//const [loading, setLoading] = useState(false);
|
|
46
|
+
const [message, setMessage] = useState<string>("");
|
|
47
47
|
|
|
48
48
|
const handleInputChange = (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>): void => {
|
|
49
49
|
const fieldName: string = e.target.name;
|
|
@@ -67,27 +67,17 @@ const MovaLogin: FunctionComponent<MovaLoginProps> = ({ loading, movaAppType, on
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
const validateForm = () => {
|
|
70
|
-
let newForm: MovaLoginForm = form;
|
|
71
|
-
|
|
72
|
-
// Validator
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
const newField: MovaFormField = { value: form.email.value, error: errorMsg, isValid: false };
|
|
76
|
-
newForm = { ...newForm, ...{ email: newField } };
|
|
77
|
-
} else {
|
|
78
|
-
const newField: MovaFormField = { value: form.email.value, error: '', isValid: true };
|
|
79
|
-
newForm = { ...newForm, ...{ email: newField } };
|
|
80
|
-
}
|
|
70
|
+
let newForm: MovaLoginForm = { ...form };
|
|
71
|
+
|
|
72
|
+
// Validator pour les champs obligatoires
|
|
73
|
+
newForm.email = validateField(form.email, value => !!value, 'Champ obligatoire');
|
|
74
|
+
newForm.password = validateField(form.password, value => !!value, 'Champ obligatoire');
|
|
81
75
|
|
|
82
|
-
// Validator
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
} else {
|
|
88
|
-
const newField: MovaFormField = { value: form.password.value, error: '', isValid: true };
|
|
89
|
-
newForm = { ...newForm, ...{ password: newField } };
|
|
90
|
-
}
|
|
76
|
+
// Validator pour l'email
|
|
77
|
+
newForm.email = validateField(form.email, validateEmail, 'Adresse email invalide');
|
|
78
|
+
|
|
79
|
+
// Validator pour le mot de passe
|
|
80
|
+
newForm.password = validateField(form.password, value => value.length >= 8, 'Votre mot de passe doit faire au moins 8 caractères de long');
|
|
91
81
|
|
|
92
82
|
setForm(newForm);
|
|
93
83
|
|
|
@@ -173,15 +163,15 @@ const MovaLogin: FunctionComponent<MovaLoginProps> = ({ loading, movaAppType, on
|
|
|
173
163
|
|
|
174
164
|
<Grid container>
|
|
175
165
|
<Grid item xs>
|
|
176
|
-
<Link href="
|
|
166
|
+
<Link href="/forgot-password" variant="body2" color="text.secondary">
|
|
177
167
|
Mot de passe oublié ?
|
|
178
168
|
</Link>
|
|
179
169
|
</Grid>
|
|
180
|
-
<Grid item>
|
|
181
|
-
<Link href="
|
|
170
|
+
{movaAppType === MovaAppType.USER && <Grid item>
|
|
171
|
+
<Link href="/signup" variant="body2" color="text.secondary">
|
|
182
172
|
{"Créer un compte"}
|
|
183
173
|
</Link>
|
|
184
|
-
</Grid>
|
|
174
|
+
</Grid>}
|
|
185
175
|
</Grid>
|
|
186
176
|
</Box>
|
|
187
177
|
<MovaCopyright sx={{ mt: 8, mb: 4 }} />
|
package/src/MovaSignUp.tsx
CHANGED
|
@@ -10,6 +10,7 @@ import { MovaLoginForm, MovaFormField, MovaUserSignUpForm } from "./helpers/Type
|
|
|
10
10
|
import { MovaAppType } from "./helpers/Enums";
|
|
11
11
|
import { validateEmail } from "./helpers/Validator";
|
|
12
12
|
import GenderSelector from "./GenderSelector";
|
|
13
|
+
import { validateField } from "./helpers/Tools";
|
|
13
14
|
|
|
14
15
|
// Permet de centrer le contenu de l'application
|
|
15
16
|
const styles: CSSProperties = {
|
|
@@ -49,10 +50,10 @@ const MovaLogin: FunctionComponent<MovaSignUpProps> = ({ loading, movaAppType, o
|
|
|
49
50
|
|
|
50
51
|
const [userForm, setUserForm] = useState<MovaUserSignUpForm>(initialUserFormState);
|
|
51
52
|
|
|
52
|
-
const [message, setMessage] = useState<string>("");
|
|
53
|
-
//const [loading, setLoading] = useState(false);
|
|
53
|
+
const [message, setMessage] = useState<string>("");
|
|
54
54
|
|
|
55
55
|
const handleInputChange = (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>): void => {
|
|
56
|
+
|
|
56
57
|
const fieldName: string = e.target.name;
|
|
57
58
|
const fieldValue: string = e.target.value;
|
|
58
59
|
const newField: MovaFormField = { [fieldName]: { value: fieldValue, isValid: true } };
|
|
@@ -61,10 +62,11 @@ const MovaLogin: FunctionComponent<MovaSignUpProps> = ({ loading, movaAppType, o
|
|
|
61
62
|
}
|
|
62
63
|
|
|
63
64
|
const handleCheckboxChange = (e: SelectChangeEvent<string>, checked: boolean): void => {
|
|
65
|
+
|
|
64
66
|
const fieldName: string = e.target.name;
|
|
65
67
|
const fieldValue: boolean = checked;
|
|
66
68
|
const newField: MovaFormField = { [fieldName]: { value: fieldValue, isValid: true } };
|
|
67
|
-
|
|
69
|
+
|
|
68
70
|
setUserForm({ ...userForm, ...newField});
|
|
69
71
|
}
|
|
70
72
|
|
|
@@ -90,33 +92,31 @@ const MovaLogin: FunctionComponent<MovaSignUpProps> = ({ loading, movaAppType, o
|
|
|
90
92
|
}
|
|
91
93
|
|
|
92
94
|
const validateForm = () => {
|
|
93
|
-
let newForm: MovaUserSignUpForm = userForm;
|
|
94
|
-
|
|
95
|
-
// Validator email
|
|
96
|
-
if(!validateEmail(userForm.email.value)) {
|
|
97
|
-
const errorMsg: string = 'Adresse email invalide';
|
|
98
|
-
const newField: MovaFormField = { value: userForm.email.value, error: errorMsg, isValid: false };
|
|
99
|
-
newForm = { ...newForm, ...{ email: newField } };
|
|
100
|
-
} else {
|
|
101
|
-
const newField: MovaFormField = { value: userForm.email.value, error: '', isValid: true };
|
|
102
|
-
newForm = { ...newForm, ...{ email: newField } };
|
|
103
|
-
}
|
|
95
|
+
let newForm: MovaUserSignUpForm = { ...userForm };
|
|
104
96
|
|
|
105
|
-
// Validator
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
newForm = { ...newForm, ...{ password: newField } };
|
|
113
|
-
}
|
|
97
|
+
// Validator pour les champs obligatoires
|
|
98
|
+
newForm.firstname = validateField(userForm.firstname, value => !!value, 'Champ obligatoire');
|
|
99
|
+
newForm.lastname = validateField(userForm.lastname, value => !!value, 'Champ obligatoire');
|
|
100
|
+
newForm.email = validateField(userForm.email, value => !!value, 'Champ obligatoire');
|
|
101
|
+
newForm.password = validateField(userForm.password, value => !!value, 'Champ obligatoire');
|
|
102
|
+
newForm.gender = validateField(userForm.gender, value => !!value, 'Champ obligatoire');
|
|
103
|
+
newForm.birthDate = validateField(userForm.birthDate, value => !!value, 'Champ obligatoire');
|
|
114
104
|
|
|
115
|
-
|
|
105
|
+
// Validator pour l'email
|
|
106
|
+
newForm.email = validateField(userForm.email, validateEmail, 'Adresse email invalide');
|
|
116
107
|
|
|
117
|
-
|
|
118
|
-
|
|
108
|
+
// Validator pour le mot de passe
|
|
109
|
+
newForm.password = validateField(userForm.password, value => value.length >= 8, 'Votre mot de passe doit faire au moins 8 caractères de long');
|
|
119
110
|
|
|
111
|
+
// Validator pour les CGU
|
|
112
|
+
newForm.acceptsTerms = validateField(userForm.acceptsTerms, value => Boolean(value), 'Vous devez accepter les termes de nos CGU');
|
|
113
|
+
|
|
114
|
+
setUserForm(newForm);
|
|
115
|
+
|
|
116
|
+
return newForm.firstname.isValid && newForm.lastname.isValid && newForm.email.isValid
|
|
117
|
+
&& newForm.password.isValid && newForm.gender.isValid && newForm.birthDate.isValid;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
120
|
const getMovaLogo = () => {
|
|
121
121
|
|
|
122
122
|
return movaAppType === MovaAppType.GARAGE ? LogoProLarge :
|
|
@@ -148,7 +148,7 @@ const MovaLogin: FunctionComponent<MovaSignUpProps> = ({ loading, movaAppType, o
|
|
|
148
148
|
>
|
|
149
149
|
<img src={getMovaLogo()} style={{width:'50%'}}/>
|
|
150
150
|
<br />
|
|
151
|
-
<Typography variant="
|
|
151
|
+
<Typography variant="button" sx={{ pt: 2 }}>Nouveau compte utilisateur</Typography>
|
|
152
152
|
</Box>
|
|
153
153
|
|
|
154
154
|
<Box component="form" onSubmit={handleSubmit} noValidate sx={{ mt: 1 }}>
|
|
@@ -187,7 +187,6 @@ const MovaLogin: FunctionComponent<MovaSignUpProps> = ({ loading, movaAppType, o
|
|
|
187
187
|
label="Adresse email"
|
|
188
188
|
name="email"
|
|
189
189
|
autoComplete="email"
|
|
190
|
-
autoFocus
|
|
191
190
|
onChange={e => handleInputChange(e)}
|
|
192
191
|
value={userForm.email.value}
|
|
193
192
|
error={!userForm.email.isValid}
|
|
@@ -205,27 +204,32 @@ const MovaLogin: FunctionComponent<MovaSignUpProps> = ({ loading, movaAppType, o
|
|
|
205
204
|
onChange={e => handleInputChange(e)}
|
|
206
205
|
value={userForm.password.value}
|
|
207
206
|
error={!userForm.password.isValid}
|
|
208
|
-
helperText={userForm.password.error}
|
|
207
|
+
helperText={Boolean(userForm.password.error) ? userForm.password.error : "8 caractères minimum"}
|
|
209
208
|
/>
|
|
210
|
-
|
|
209
|
+
|
|
210
|
+
<GenderSelector handleSelectChange={handleSelectChange} form={userForm} required sx={{ width:'40%', mr: 2}} />
|
|
211
|
+
|
|
211
212
|
<TextField
|
|
212
213
|
margin="normal"
|
|
213
214
|
required
|
|
215
|
+
name="birthDate"
|
|
214
216
|
label="Date de naissance"
|
|
215
217
|
type="date"
|
|
216
218
|
InputLabelProps={{
|
|
217
219
|
shrink: true,
|
|
218
220
|
}}
|
|
219
221
|
autoComplete="bday"
|
|
220
|
-
value={userForm.
|
|
221
|
-
error={!userForm.
|
|
222
|
-
helperText={userForm.
|
|
222
|
+
value={userForm.birthDate.value}
|
|
223
|
+
error={!userForm.birthDate.isValid}
|
|
224
|
+
helperText={userForm.birthDate.error}
|
|
223
225
|
onChange={(e) => handleInputChange(e)}
|
|
226
|
+
sx={{ width:'50%', float: 'right'}}
|
|
224
227
|
/>
|
|
225
228
|
<FormControl error={!userForm.acceptsTerms.isValid}>
|
|
226
229
|
<FormControlLabel
|
|
227
230
|
control={
|
|
228
231
|
<Checkbox
|
|
232
|
+
name="acceptsTerms"
|
|
229
233
|
color="primary"
|
|
230
234
|
checked={userForm.acceptsTerms.value}
|
|
231
235
|
onChange={(e, checked) => handleCheckboxChange(e, checked)}
|
|
@@ -245,7 +249,6 @@ const MovaLogin: FunctionComponent<MovaSignUpProps> = ({ loading, movaAppType, o
|
|
|
245
249
|
|
|
246
250
|
{alertMessage && alertSeverity && <Alert severity={alertSeverity} sx={{ mb: 2 }}>{alertMessage}</Alert>}
|
|
247
251
|
|
|
248
|
-
|
|
249
252
|
<LoadingButton
|
|
250
253
|
loading={loading}
|
|
251
254
|
type="submit"
|
package/src/helpers/Tools.ts
CHANGED
|
@@ -1 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
import { MovaFormField } from "./Types";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Valide un champ de formulaire en utilisant une fonction de validation personnalisée.
|
|
5
|
+
*
|
|
6
|
+
* @param {MovaFormField} field - Le champ de formulaire à valider.
|
|
7
|
+
* @param {(value: string) => boolean} validator - La fonction de validation à utiliser pour le champ.
|
|
8
|
+
* @param {string} errorMsg - Le message d'erreur à associer au champ si la validation échoue.
|
|
9
|
+
* @returns {MovaFormField} - Le champ de formulaire avec les propriétés `error` et `isValid` mises à jour.
|
|
10
|
+
*/
|
|
11
|
+
export const validateField = (field: MovaFormField, validator: (value: string) => boolean, errorMsg: string): MovaFormField => {
|
|
12
|
+
if (!validator(field.value)) {
|
|
13
|
+
return { value: field.value, error: errorMsg, isValid: false };
|
|
14
|
+
}
|
|
15
|
+
return { value: field.value, error: '', isValid: true };
|
|
16
|
+
};
|
|
17
|
+
|
package/theme.ts
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { createTheme } from '@mui/material/styles';
|
|
2
|
+
|
|
3
|
+
const theme = createTheme({
|
|
4
|
+
palette: {
|
|
5
|
+
background: {
|
|
6
|
+
paper: '#F0F0F0',
|
|
7
|
+
},
|
|
8
|
+
primary: {
|
|
9
|
+
main: '#BCD46C', // Définissez votre couleur primaire
|
|
10
|
+
light: '#D2EDAB'
|
|
11
|
+
},
|
|
12
|
+
secondary: {
|
|
13
|
+
main: '#FFD25C',//'#F29ABA', // Définissez votre couleur secondaire // FFC700
|
|
14
|
+
light: '#FEE08E'//'#F1C0D9'
|
|
15
|
+
},
|
|
16
|
+
success: {
|
|
17
|
+
main: '#A8DB5EFF'
|
|
18
|
+
},
|
|
19
|
+
warning: {
|
|
20
|
+
main: '#FFD25C'
|
|
21
|
+
}
|
|
22
|
+
/* text: {
|
|
23
|
+
//light: '#E4E4E4',
|
|
24
|
+
} */
|
|
25
|
+
},
|
|
26
|
+
typography: {
|
|
27
|
+
fontFamily: 'Outfit, sans-serif', // Police de caractère par défaut
|
|
28
|
+
},
|
|
29
|
+
components: {
|
|
30
|
+
MuiAutocomplete: {
|
|
31
|
+
styleOverrides: {
|
|
32
|
+
noOptions: {
|
|
33
|
+
//display: 'none'
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
MuiSelect: {
|
|
38
|
+
styleOverrides: {
|
|
39
|
+
select: {
|
|
40
|
+
display: 'flex',
|
|
41
|
+
alignItems: 'center'
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
MuiTooltip: {
|
|
46
|
+
styleOverrides: {
|
|
47
|
+
// Name of the slot
|
|
48
|
+
tooltip: {
|
|
49
|
+
fontSize: 14,
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
MuiIconButton: {
|
|
54
|
+
styleOverrides: {
|
|
55
|
+
root: {
|
|
56
|
+
color: '#5f6368',
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
MuiDialog: {
|
|
61
|
+
styleOverrides: {
|
|
62
|
+
// Name of the slot
|
|
63
|
+
paper: {
|
|
64
|
+
backgroundColor: 'white',
|
|
65
|
+
margin: '18px'
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
MuiDialogActions: {
|
|
70
|
+
styleOverrides: {
|
|
71
|
+
root: {
|
|
72
|
+
margin: '8px'
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
MuiCard: {
|
|
77
|
+
styleOverrides: {
|
|
78
|
+
root: {
|
|
79
|
+
backgroundColor: 'white'
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
MuiTab: {
|
|
84
|
+
styleOverrides: {
|
|
85
|
+
root: {
|
|
86
|
+
"&.Mui-selected": {
|
|
87
|
+
"backgroundColor": "#BCD46C"
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
export default theme;
|
package/tsconfig.json
CHANGED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
|
|
4
|
+
module.exports = {
|
|
5
|
+
mode: 'development', // ou 'production' ou 'none'
|
|
6
|
+
module: {
|
|
7
|
+
rules: [
|
|
8
|
+
{
|
|
9
|
+
test: /\.tsx?$/,
|
|
10
|
+
use: 'ts-loader',
|
|
11
|
+
exclude: /node_modules/,
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
test: /\.(png|jpg|gif|svg)$/,
|
|
15
|
+
use: [
|
|
16
|
+
{
|
|
17
|
+
loader: 'file-loader',
|
|
18
|
+
options: {
|
|
19
|
+
name: '[name].[ext]',
|
|
20
|
+
outputPath: 'images/',
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
},
|
|
27
|
+
resolve: {
|
|
28
|
+
extensions: ['.tsx', '.ts', '.js'],
|
|
29
|
+
},
|
|
30
|
+
plugins: [
|
|
31
|
+
new HtmlWebpackPlugin({
|
|
32
|
+
template: path.resolve(__dirname, 'public', 'index.html'), // Chemin vers votre fichier HTML de base
|
|
33
|
+
}),
|
|
34
|
+
],
|
|
35
|
+
};
|
package/dist/GenderSelector.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
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 GenderSelector = function (_a) {
|
|
17
|
-
var handleSelectChange = _a.handleSelectChange, form = _a.form, required = _a.required;
|
|
18
|
-
return ((0, jsx_runtime_1.jsxs)(material_1.FormControl, __assign({ fullWidth: true, margin: "normal", required: required }, { 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" }))] }))] })));
|
|
19
|
-
};
|
|
20
|
-
exports.default = GenderSelector;
|
package/dist/helpers/Tools.js
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|