@movalib/movalib-commons 1.0.66 → 1.0.67
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 +16 -10
- package/dist/devIndex.js +10 -7
- package/dist/src/MovaLogin.js +10 -1
- package/dist/src/MovaSignUp.d.ts +1 -1
- package/dist/src/MovaSignUp.js +41 -9
- package/package.json +2 -1
- package/public/index.html +1 -1
- package/src/MovaLogin.tsx +22 -3
- package/src/MovaSignUp.tsx +70 -14
package/devIndex.tsx
CHANGED
|
@@ -7,21 +7,27 @@ import { MovaAppType } from './src/helpers/Enums';
|
|
|
7
7
|
import { ThemeProvider } from '@mui/material/styles';
|
|
8
8
|
import theme from './theme'; // Import du thème personnalisé
|
|
9
9
|
import MovaSignUp from './src/MovaSignUp';
|
|
10
|
+
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
|
|
11
|
+
import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns';
|
|
12
|
+
import DatePicker from '@mui/lab/DatePicker';
|
|
13
|
+
import frLocale from 'date-fns/locale/fr';
|
|
10
14
|
|
|
11
15
|
const App = () => {
|
|
12
16
|
return (
|
|
13
17
|
<div>
|
|
14
|
-
<
|
|
15
|
-
<
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
<LocalizationProvider dateAdapter={AdapterDateFns} adapterLocale={frLocale}>
|
|
19
|
+
<ThemeProvider theme={theme}>
|
|
20
|
+
<MovaLogin movaAppType={MovaAppType.GARAGE} onSubmit={function (form: MovaLoginForm): void {
|
|
21
|
+
alert('Form Submitted !');
|
|
22
|
+
} } onSubmitForgotPassword={function (email: string): void {
|
|
23
|
+
throw new Error('Function not implemented.');
|
|
24
|
+
} } />
|
|
20
25
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
26
|
+
<MovaSignUp movaAppType={MovaAppType.USER} onSubmit={function (form: MovaLoginForm): void {
|
|
27
|
+
alert('Form Submitted !');
|
|
28
|
+
} } />
|
|
29
|
+
</ThemeProvider>
|
|
30
|
+
</LocalizationProvider>
|
|
25
31
|
</div>
|
|
26
32
|
);
|
|
27
33
|
};
|
package/dist/devIndex.js
CHANGED
|
@@ -23,14 +23,17 @@ var Enums_1 = require("./src/helpers/Enums");
|
|
|
23
23
|
var styles_1 = require("@mui/material/styles");
|
|
24
24
|
var theme_1 = __importDefault(require("./theme")); // Import du thème personnalisé
|
|
25
25
|
var MovaSignUp_1 = __importDefault(require("./src/MovaSignUp"));
|
|
26
|
+
var LocalizationProvider_1 = require("@mui/x-date-pickers/LocalizationProvider");
|
|
27
|
+
var AdapterDateFns_1 = require("@mui/x-date-pickers/AdapterDateFns");
|
|
28
|
+
var fr_1 = __importDefault(require("date-fns/locale/fr"));
|
|
26
29
|
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
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
return ((0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(LocalizationProvider_1.LocalizationProvider, __assign({ dateAdapter: AdapterDateFns_1.AdapterDateFns, adapterLocale: fr_1.default }, { 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) {
|
|
31
|
+
alert('Form Submitted !');
|
|
32
|
+
}, onSubmitForgotPassword: function (email) {
|
|
33
|
+
throw new Error('Function not implemented.');
|
|
34
|
+
} }), (0, jsx_runtime_1.jsx)(MovaSignUp_1.default, { movaAppType: Enums_1.MovaAppType.USER, onSubmit: function (form) {
|
|
35
|
+
alert('Form Submitted !');
|
|
36
|
+
} })] })) })) }));
|
|
34
37
|
};
|
|
35
38
|
var root = (0, client_1.createRoot)(document.getElementById('root'));
|
|
36
39
|
root.render((0, jsx_runtime_1.jsx)(react_1.default.StrictMode, { children: (0, jsx_runtime_1.jsx)(App, {}) }));
|
package/dist/src/MovaLogin.js
CHANGED
|
@@ -63,6 +63,9 @@ var Enums_1 = require("./helpers/Enums");
|
|
|
63
63
|
var Validator_1 = require("./helpers/Validator");
|
|
64
64
|
var Tools_1 = require("./helpers/Tools");
|
|
65
65
|
var react_router_dom_1 = require("react-router-dom");
|
|
66
|
+
var InputAdornment_1 = __importDefault(require("@mui/material/InputAdornment"));
|
|
67
|
+
var Visibility_1 = __importDefault(require("@mui/icons-material/Visibility"));
|
|
68
|
+
var VisibilityOff_1 = __importDefault(require("@mui/icons-material/VisibilityOff"));
|
|
66
69
|
// Permet de centrer le contenu de l'application
|
|
67
70
|
var styles = {
|
|
68
71
|
display: 'flex',
|
|
@@ -85,6 +88,7 @@ var MovaLogin = function (_a) {
|
|
|
85
88
|
var _c = (0, react_1.useState)(""), message = _c[0], setMessage = _c[1];
|
|
86
89
|
var history = (0, react_router_dom_1.useHistory)();
|
|
87
90
|
var _d = (0, react_1.useState)(false), openForgotPassword = _d[0], setOpenForgotPassword = _d[1];
|
|
91
|
+
var _e = (0, react_1.useState)(false), showPassword = _e[0], setShowPassword = _e[1];
|
|
88
92
|
var handleInputChange = function (e) {
|
|
89
93
|
var _a;
|
|
90
94
|
var fieldName = e.target.name;
|
|
@@ -143,6 +147,9 @@ var MovaLogin = function (_a) {
|
|
|
143
147
|
onSubmitForgotPassword(form.email.value);
|
|
144
148
|
}
|
|
145
149
|
};
|
|
150
|
+
var handleClickShowPassword = function () {
|
|
151
|
+
setShowPassword(function (prev) { return !prev; });
|
|
152
|
+
};
|
|
146
153
|
/**
|
|
147
154
|
* Boite de diaogue pour la perte du mot de passe
|
|
148
155
|
*/
|
|
@@ -162,7 +169,9 @@ var MovaLogin = function (_a) {
|
|
|
162
169
|
display: 'flex',
|
|
163
170
|
flexDirection: 'column',
|
|
164
171
|
alignItems: 'center',
|
|
165
|
-
} }, { 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:
|
|
172
|
+
} }, { 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: showPassword ? 'text' : 'password', id: "password", autoComplete: "current-password", onChange: function (e) { return handleInputChange(e); }, value: form.password.value, error: !form.password.isValid, helperText: form.password.error, InputProps: {
|
|
173
|
+
endAdornment: ((0, jsx_runtime_1.jsx)(InputAdornment_1.default, __assign({ position: "end" }, { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, __assign({ edge: "end", onClick: handleClickShowPassword }, { children: showPassword ? (0, jsx_runtime_1.jsx)(VisibilityOff_1.default, {}) : (0, jsx_runtime_1.jsx)(Visibility_1.default, {}) })) }))),
|
|
174
|
+
} }), (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({ variant: "body2", color: "text.secondary", onClick: function (e) { return handleOnClickForgotPassword(e); } }, { 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\u00E9er mon compte" })) }))] }))] })), (0, jsx_runtime_1.jsx)(MovaCopyright_1.default, { sx: { mt: 8, mb: 4 } }), openForgotPassword && dialogForgotPassword()] })), (0, jsx_runtime_1.jsx)("img", { src: leaf_pink_large_png_1.default, style: { position: 'fixed',
|
|
166
175
|
float: 'right',
|
|
167
176
|
width: '250px',
|
|
168
177
|
height: '400px',
|
package/dist/src/MovaSignUp.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { MovaAppType } from "./helpers/Enums";
|
|
|
5
5
|
/**
|
|
6
6
|
* Propriétés du composant
|
|
7
7
|
* movaAppType : type d'application Movalib au sein de laquelle le composant est injectée
|
|
8
|
-
* onSubmit :
|
|
8
|
+
* onSubmit : callback invoquée en cas de formulaire valide
|
|
9
9
|
* alertMessage : éventuel message à afficher
|
|
10
10
|
* alertSeverity : niveau d'alerte pour le message à afficher
|
|
11
11
|
* loading : permet de mettre éventuellement le bouton de soumission en état de chargement
|
package/dist/src/MovaSignUp.js
CHANGED
|
@@ -53,6 +53,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
53
53
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
54
54
|
var react_1 = require("react");
|
|
55
55
|
var lab_1 = require("@mui/lab");
|
|
56
|
+
var DatePicker_1 = require("@mui/x-date-pickers/DatePicker");
|
|
56
57
|
var logo_large_png_1 = __importDefault(require("./assets/images/logo/logo_large.png"));
|
|
57
58
|
var logo_pro_large_png_1 = __importDefault(require("./assets/images/logo/logo_pro_large.png"));
|
|
58
59
|
var leaf_green_large_png_1 = __importDefault(require("./assets/images/leaf_green_large.png"));
|
|
@@ -64,6 +65,10 @@ var Validator_1 = require("./helpers/Validator");
|
|
|
64
65
|
var GenderSelector_1 = __importDefault(require("./GenderSelector"));
|
|
65
66
|
var Tools_1 = require("./helpers/Tools");
|
|
66
67
|
var react_router_dom_1 = require("react-router-dom");
|
|
68
|
+
var InputAdornment_1 = __importDefault(require("@mui/material/InputAdornment"));
|
|
69
|
+
var Visibility_1 = __importDefault(require("@mui/icons-material/Visibility"));
|
|
70
|
+
var VisibilityOff_1 = __importDefault(require("@mui/icons-material/VisibilityOff"));
|
|
71
|
+
var isValid_1 = __importDefault(require("date-fns/isValid"));
|
|
67
72
|
// Permet de centrer le contenu de l'application
|
|
68
73
|
var styles = {
|
|
69
74
|
display: 'flex',
|
|
@@ -76,7 +81,7 @@ var initialUserFormState = {
|
|
|
76
81
|
email: { value: '', isValid: true },
|
|
77
82
|
password: { value: '', isValid: true },
|
|
78
83
|
gender: { value: '', isValid: true },
|
|
79
|
-
birthDate: { value:
|
|
84
|
+
birthDate: { value: null, isValid: true },
|
|
80
85
|
acceptsTerms: { value: false, isValid: true },
|
|
81
86
|
};
|
|
82
87
|
/**
|
|
@@ -88,12 +93,25 @@ var MovaLogin = function (_a) {
|
|
|
88
93
|
var _b = (0, react_1.useState)(initialUserFormState), userForm = _b[0], setUserForm = _b[1];
|
|
89
94
|
var history = (0, react_router_dom_1.useHistory)();
|
|
90
95
|
var _c = (0, react_1.useState)(""), message = _c[0], setMessage = _c[1];
|
|
96
|
+
var _d = (0, react_1.useState)(false), showPassword = _d[0], setShowPassword = _d[1];
|
|
97
|
+
var handleDateChange = function (name, date) {
|
|
98
|
+
var _a;
|
|
99
|
+
console.log(date);
|
|
100
|
+
if (name && date) {
|
|
101
|
+
var fieldName = name;
|
|
102
|
+
var fieldValue = date;
|
|
103
|
+
var newField = (_a = {}, _a[fieldName] = { value: fieldValue, isValid: true }, _a);
|
|
104
|
+
setUserForm(__assign(__assign({}, userForm), newField));
|
|
105
|
+
}
|
|
106
|
+
};
|
|
91
107
|
var handleInputChange = function (e) {
|
|
92
108
|
var _a;
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
109
|
+
if (e) {
|
|
110
|
+
var fieldName = e.target.name;
|
|
111
|
+
var fieldValue = e.target.value;
|
|
112
|
+
var newField = (_a = {}, _a[fieldName] = { value: fieldValue, isValid: true }, _a);
|
|
113
|
+
setUserForm(__assign(__assign({}, userForm), newField));
|
|
114
|
+
}
|
|
97
115
|
};
|
|
98
116
|
var handleCheckboxChange = function (e, checked) {
|
|
99
117
|
var _a;
|
|
@@ -132,7 +150,7 @@ var MovaLogin = function (_a) {
|
|
|
132
150
|
newForm.email = (0, Tools_1.validateField)(userForm.email, function (value) { return !!value; }, 'Champ obligatoire');
|
|
133
151
|
newForm.password = (0, Tools_1.validateField)(userForm.password, function (value) { return !!value; }, 'Champ obligatoire');
|
|
134
152
|
newForm.gender = (0, Tools_1.validateField)(userForm.gender, function (value) { return !!value; }, 'Champ obligatoire');
|
|
135
|
-
newForm.birthDate = (0, Tools_1.validateField)(userForm.birthDate, function (value) { return !!value; }, 'Champ obligatoire');
|
|
153
|
+
newForm.birthDate = (0, Tools_1.validateField)(userForm.birthDate, function (value) { return !!value && (0, isValid_1.default)(value); }, 'Champ obligatoire');
|
|
136
154
|
// Validator pour l'email
|
|
137
155
|
newForm.email = (0, Tools_1.validateField)(userForm.email, Validator_1.validateEmail, 'Adresse email invalide');
|
|
138
156
|
// Validator pour le mot de passe
|
|
@@ -155,6 +173,9 @@ var MovaLogin = function (_a) {
|
|
|
155
173
|
history.push('/login');
|
|
156
174
|
}
|
|
157
175
|
};
|
|
176
|
+
var handleClickShowPassword = function () {
|
|
177
|
+
setShowPassword(function (prev) { return !prev; });
|
|
178
|
+
};
|
|
158
179
|
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',
|
|
159
180
|
float: 'left',
|
|
160
181
|
width: '250px',
|
|
@@ -167,9 +188,20 @@ var MovaLogin = function (_a) {
|
|
|
167
188
|
display: 'flex',
|
|
168
189
|
flexDirection: 'column',
|
|
169
190
|
alignItems: 'center',
|
|
170
|
-
} }, { 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:
|
|
171
|
-
|
|
172
|
-
}
|
|
191
|
+
} }, { 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: showPassword ? 'text' : '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 : "10 caractères minimum, 1 majuscule, 1 minuscule", InputProps: {
|
|
192
|
+
endAdornment: ((0, jsx_runtime_1.jsx)(InputAdornment_1.default, __assign({ position: "end" }, { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, __assign({ edge: "end", onClick: handleClickShowPassword }, { children: showPassword ? (0, jsx_runtime_1.jsx)(VisibilityOff_1.default, {}) : (0, jsx_runtime_1.jsx)(Visibility_1.default, {}) })) }))),
|
|
193
|
+
} }), (0, jsx_runtime_1.jsx)(GenderSelector_1.default, { handleSelectChange: handleSelectChange, form: userForm, required: true, sx: { width: '40%', mr: 2 } }), (0, jsx_runtime_1.jsx)(DatePicker_1.DatePicker, { label: "Date de naissance", value: userForm.birthDate.value, format: 'dd / MM / yyyy', formatDensity: 'dense',
|
|
194
|
+
//views={['day']}
|
|
195
|
+
displayWeekNumber: true, onChange: function (newValue) { return handleDateChange('birthDate', newValue); }, slotProps: {
|
|
196
|
+
textField: {
|
|
197
|
+
required: true,
|
|
198
|
+
error: !userForm.birthDate.isValid,
|
|
199
|
+
sx: {
|
|
200
|
+
width: '50%', mt: 2, float: 'right',
|
|
201
|
+
padding: 0,
|
|
202
|
+
},
|
|
203
|
+
},
|
|
204
|
+
} }), (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)(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({ variant: "body2", color: "text.secondary", onClick: function (e) { return handleOnClickLogin(e); } }, { children: "Se connecter" })) })) }))] })), (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',
|
|
173
205
|
float: 'right',
|
|
174
206
|
width: '250px',
|
|
175
207
|
height: '400px',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@movalib/movalib-commons",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.67",
|
|
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",
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"@emotion/styled": "^11.11.0",
|
|
21
21
|
"@mui/icons-material": "^5.11.16",
|
|
22
22
|
"@mui/lab": "^5.0.0-alpha.134",
|
|
23
|
+
"@mui/x-date-pickers": "^6.9.1",
|
|
23
24
|
"@mui/material": "^5.13.5",
|
|
24
25
|
"@types/react": "^18.2.22",
|
|
25
26
|
"@types/react-dom": "^18.2.7",
|
package/public/index.html
CHANGED
package/src/MovaLogin.tsx
CHANGED
|
@@ -5,13 +5,16 @@ import LogoProLarge from './assets/images/logo/logo_pro_large.png';
|
|
|
5
5
|
import GreenLeafImage from "./assets/images/leaf_green_large.png";
|
|
6
6
|
import PinkLeafImage from "./assets/images/leaf_pink_large.png";
|
|
7
7
|
import { Alert, AlertColor, Box, Button, Checkbox, Container, CssBaseline, Dialog, DialogActions, DialogContent, DialogContentText,
|
|
8
|
-
DialogTitle, FormControlLabel, Grid, Link, TextField } from "@mui/material";
|
|
8
|
+
DialogTitle, FormControlLabel, Grid, IconButton, Link, TextField } from "@mui/material";
|
|
9
9
|
import MovaCopyright from "./MovaCopyright";
|
|
10
10
|
import { MovaLoginForm, MovaFormField } from "./helpers/Types";
|
|
11
11
|
import { MovaAppType } from "./helpers/Enums";
|
|
12
12
|
import { validateEmail } from "./helpers/Validator";
|
|
13
13
|
import { validateField } from "./helpers/Tools";
|
|
14
14
|
import { useHistory } from "react-router-dom";
|
|
15
|
+
import InputAdornment from '@mui/material/InputAdornment';
|
|
16
|
+
import Visibility from '@mui/icons-material/Visibility';
|
|
17
|
+
import VisibilityOff from '@mui/icons-material/VisibilityOff';
|
|
15
18
|
|
|
16
19
|
// Permet de centrer le contenu de l'application
|
|
17
20
|
const styles: CSSProperties = {
|
|
@@ -54,6 +57,7 @@ const MovaLogin: FunctionComponent<MovaLoginProps> = ({ loading, movaAppType, on
|
|
|
54
57
|
const [message, setMessage] = useState<string>("");
|
|
55
58
|
const history = useHistory();
|
|
56
59
|
const [openForgotPassword, setOpenForgotPassword] = useState(false);
|
|
60
|
+
const [showPassword, setShowPassword] = useState(false);
|
|
57
61
|
|
|
58
62
|
const handleInputChange = (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>): void => {
|
|
59
63
|
const fieldName: string = e.target.name;
|
|
@@ -126,6 +130,9 @@ const MovaLogin: FunctionComponent<MovaLoginProps> = ({ loading, movaAppType, on
|
|
|
126
130
|
}
|
|
127
131
|
}
|
|
128
132
|
|
|
133
|
+
const handleClickShowPassword = () => {
|
|
134
|
+
setShowPassword((prev) => !prev);
|
|
135
|
+
};
|
|
129
136
|
|
|
130
137
|
/**
|
|
131
138
|
* Boite de diaogue pour la perte du mot de passe
|
|
@@ -219,13 +226,25 @@ const MovaLogin: FunctionComponent<MovaLoginProps> = ({ loading, movaAppType, on
|
|
|
219
226
|
fullWidth
|
|
220
227
|
name="password"
|
|
221
228
|
label="Mot de passe"
|
|
222
|
-
type=
|
|
229
|
+
type={showPassword ? 'text' : 'password'}
|
|
223
230
|
id="password"
|
|
224
231
|
autoComplete="current-password"
|
|
225
232
|
onChange={e => handleInputChange(e)}
|
|
226
233
|
value={form.password.value}
|
|
227
234
|
error={!form.password.isValid}
|
|
228
|
-
helperText={form.password.error}
|
|
235
|
+
helperText={form.password.error}
|
|
236
|
+
InputProps={{
|
|
237
|
+
endAdornment: (
|
|
238
|
+
<InputAdornment position="end">
|
|
239
|
+
<IconButton
|
|
240
|
+
edge="end"
|
|
241
|
+
onClick={handleClickShowPassword}
|
|
242
|
+
>
|
|
243
|
+
{showPassword ? <VisibilityOff /> : <Visibility />}
|
|
244
|
+
</IconButton>
|
|
245
|
+
</InputAdornment>
|
|
246
|
+
),
|
|
247
|
+
}}
|
|
229
248
|
/>
|
|
230
249
|
<FormControlLabel control={<Checkbox value="remember" color="primary" />}
|
|
231
250
|
label="Se souvenir de moi"
|
package/src/MovaSignUp.tsx
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { CSSProperties, FormEvent, FunctionComponent, useState } from "react";
|
|
2
2
|
import { LoadingButton } from '@mui/lab';
|
|
3
|
+
import { DatePicker } from '@mui/x-date-pickers/DatePicker';
|
|
3
4
|
import LogoLarge from './assets/images/logo/logo_large.png';
|
|
4
5
|
import LogoProLarge from './assets/images/logo/logo_pro_large.png';
|
|
5
6
|
import GreenLeafImage from "./assets/images/leaf_green_large.png";
|
|
6
7
|
import PinkLeafImage from "./assets/images/leaf_pink_large.png";
|
|
7
|
-
import { Alert, AlertColor, Box, Checkbox, Container, CssBaseline, FormControl, FormControlLabel, FormHelperText, Grid,
|
|
8
|
+
import { Alert, AlertColor, Box, Checkbox, Container, CssBaseline, FormControl, FormControlLabel, FormHelperText, Grid,
|
|
9
|
+
IconButton, Link, SelectChangeEvent, TextField, Typography, TextFieldProps } from "@mui/material";
|
|
8
10
|
import MovaCopyright from "./MovaCopyright";
|
|
9
11
|
import { MovaFormField, MovaUserSignUpForm } from "./helpers/Types";
|
|
10
12
|
import { MovaAppType } from "./helpers/Enums";
|
|
@@ -12,6 +14,10 @@ import { validateEmail } from "./helpers/Validator";
|
|
|
12
14
|
import GenderSelector from "./GenderSelector";
|
|
13
15
|
import { validateField } from "./helpers/Tools";
|
|
14
16
|
import { useHistory } from "react-router-dom";
|
|
17
|
+
import InputAdornment from '@mui/material/InputAdornment';
|
|
18
|
+
import Visibility from '@mui/icons-material/Visibility';
|
|
19
|
+
import VisibilityOff from '@mui/icons-material/VisibilityOff';
|
|
20
|
+
import isValid from 'date-fns/isValid';
|
|
15
21
|
|
|
16
22
|
// Permet de centrer le contenu de l'application
|
|
17
23
|
const styles: CSSProperties = {
|
|
@@ -26,14 +32,14 @@ const initialUserFormState = {
|
|
|
26
32
|
email: { value: '', isValid: true },
|
|
27
33
|
password: { value: '', isValid: true },
|
|
28
34
|
gender: { value: '', isValid: true },
|
|
29
|
-
birthDate: { value:
|
|
35
|
+
birthDate: { value: null, isValid: true },
|
|
30
36
|
acceptsTerms: { value: false, isValid: true },
|
|
31
37
|
};
|
|
32
38
|
|
|
33
39
|
/**
|
|
34
40
|
* Propriétés du composant
|
|
35
41
|
* movaAppType : type d'application Movalib au sein de laquelle le composant est injectée
|
|
36
|
-
* onSubmit :
|
|
42
|
+
* onSubmit : callback invoquée en cas de formulaire valide
|
|
37
43
|
* alertMessage : éventuel message à afficher
|
|
38
44
|
* alertSeverity : niveau d'alerte pour le message à afficher
|
|
39
45
|
* loading : permet de mettre éventuellement le bouton de soumission en état de chargement
|
|
@@ -55,14 +61,27 @@ const MovaLogin: FunctionComponent<MovaSignUpProps> = ({ loading, movaAppType, o
|
|
|
55
61
|
const [userForm, setUserForm] = useState<MovaUserSignUpForm>(initialUserFormState);
|
|
56
62
|
const history = useHistory();
|
|
57
63
|
const [message, setMessage] = useState<string>("");
|
|
64
|
+
const [showPassword, setShowPassword] = useState(false);
|
|
65
|
+
|
|
66
|
+
const handleDateChange = (name: string, date: Date | null) => {
|
|
67
|
+
console.log(date)
|
|
68
|
+
if(name && date){
|
|
69
|
+
const fieldName: string = name;
|
|
70
|
+
const fieldValue: Date = date;
|
|
71
|
+
const newField: MovaFormField = { [fieldName]: { value: fieldValue, isValid: true } };
|
|
72
|
+
|
|
73
|
+
setUserForm({ ...userForm, ...newField});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
58
76
|
|
|
59
|
-
const handleInputChange = (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>): void => {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
77
|
+
const handleInputChange = (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement> | null): void => {
|
|
78
|
+
if(e){
|
|
79
|
+
const fieldName: string = e.target.name;
|
|
80
|
+
const fieldValue: string = e.target.value;
|
|
81
|
+
const newField: MovaFormField = { [fieldName]: { value: fieldValue, isValid: true } };
|
|
82
|
+
|
|
83
|
+
setUserForm({ ...userForm, ...newField});
|
|
84
|
+
}
|
|
66
85
|
}
|
|
67
86
|
|
|
68
87
|
const handleCheckboxChange = (e: SelectChangeEvent<string>, checked: boolean): void => {
|
|
@@ -104,7 +123,7 @@ const MovaLogin: FunctionComponent<MovaSignUpProps> = ({ loading, movaAppType, o
|
|
|
104
123
|
newForm.email = validateField(userForm.email, value => !!value, 'Champ obligatoire');
|
|
105
124
|
newForm.password = validateField(userForm.password, value => !!value, 'Champ obligatoire');
|
|
106
125
|
newForm.gender = validateField(userForm.gender, value => !!value, 'Champ obligatoire');
|
|
107
|
-
newForm.birthDate = validateField(userForm.birthDate, value => !!value, 'Champ obligatoire');
|
|
126
|
+
newForm.birthDate = validateField(userForm.birthDate, value => !!value && isValid(value), 'Champ obligatoire');
|
|
108
127
|
|
|
109
128
|
// Validator pour l'email
|
|
110
129
|
newForm.email = validateField(userForm.email, validateEmail, 'Adresse email invalide');
|
|
@@ -138,6 +157,10 @@ const MovaLogin: FunctionComponent<MovaSignUpProps> = ({ loading, movaAppType, o
|
|
|
138
157
|
}
|
|
139
158
|
}
|
|
140
159
|
|
|
160
|
+
const handleClickShowPassword = () => {
|
|
161
|
+
setShowPassword((prev) => !prev);
|
|
162
|
+
};
|
|
163
|
+
|
|
141
164
|
return (
|
|
142
165
|
<div style={styles}>
|
|
143
166
|
<img src={GreenLeafImage} style={{position: 'fixed',
|
|
@@ -211,18 +234,30 @@ const MovaLogin: FunctionComponent<MovaSignUpProps> = ({ loading, movaAppType, o
|
|
|
211
234
|
fullWidth
|
|
212
235
|
name="password"
|
|
213
236
|
label="Mot de passe"
|
|
214
|
-
type=
|
|
237
|
+
type={showPassword ? 'text' : 'password'}
|
|
215
238
|
id="password"
|
|
216
239
|
autoComplete="current-password"
|
|
217
240
|
onChange={e => handleInputChange(e)}
|
|
218
241
|
value={userForm.password.value}
|
|
219
242
|
error={!userForm.password.isValid}
|
|
220
|
-
helperText={Boolean(userForm.password.error) ? userForm.password.error : "
|
|
243
|
+
helperText={Boolean(userForm.password.error) ? userForm.password.error : "10 caractères minimum, 1 majuscule, 1 minuscule"}
|
|
244
|
+
InputProps={{
|
|
245
|
+
endAdornment: (
|
|
246
|
+
<InputAdornment position="end">
|
|
247
|
+
<IconButton
|
|
248
|
+
edge="end"
|
|
249
|
+
onClick={handleClickShowPassword}
|
|
250
|
+
>
|
|
251
|
+
{showPassword ? <VisibilityOff /> : <Visibility />}
|
|
252
|
+
</IconButton>
|
|
253
|
+
</InputAdornment>
|
|
254
|
+
),
|
|
255
|
+
}}
|
|
221
256
|
/>
|
|
222
257
|
|
|
223
258
|
<GenderSelector handleSelectChange={handleSelectChange} form={userForm} required sx={{ width:'40%', mr: 2}} />
|
|
224
259
|
|
|
225
|
-
<TextField
|
|
260
|
+
{/* <TextField
|
|
226
261
|
margin="normal"
|
|
227
262
|
required
|
|
228
263
|
name="birthDate"
|
|
@@ -237,7 +272,28 @@ const MovaLogin: FunctionComponent<MovaSignUpProps> = ({ loading, movaAppType, o
|
|
|
237
272
|
helperText={userForm.birthDate.error}
|
|
238
273
|
onChange={(e) => handleInputChange(e)}
|
|
239
274
|
sx={{ width:'50%', float: 'right'}}
|
|
275
|
+
/> */}
|
|
276
|
+
|
|
277
|
+
<DatePicker
|
|
278
|
+
label="Date de naissance"
|
|
279
|
+
value={userForm.birthDate.value}
|
|
280
|
+
format='dd / MM / yyyy'
|
|
281
|
+
formatDensity='dense'
|
|
282
|
+
//views={['day']}
|
|
283
|
+
displayWeekNumber
|
|
284
|
+
onChange={(newValue) => handleDateChange('birthDate', newValue)}
|
|
285
|
+
slotProps={{
|
|
286
|
+
textField: {
|
|
287
|
+
required: true,
|
|
288
|
+
error:!userForm.birthDate.isValid,
|
|
289
|
+
sx: {
|
|
290
|
+
width:'50%', mt: 2, float: 'right',
|
|
291
|
+
padding: 0,
|
|
292
|
+
},
|
|
293
|
+
},
|
|
294
|
+
}}
|
|
240
295
|
/>
|
|
296
|
+
|
|
241
297
|
<FormControl error={!userForm.acceptsTerms.isValid}>
|
|
242
298
|
<FormControlLabel
|
|
243
299
|
control={
|