@movalib/movalib-commons 1.0.65 → 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 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
- <ThemeProvider theme={theme}>
15
- <MovaLogin movaAppType={MovaAppType.GARAGE} onSubmit={function (form: MovaLoginForm): void {
16
- alert('Form Submitted !');
17
- } } onSubmitForgotPassword={function (email: string): void {
18
- throw new Error('Function not implemented.');
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
- <MovaSignUp movaAppType={MovaAppType.USER} onSubmit={function (form: MovaLoginForm): void {
22
- alert('Form Submitted !');
23
- } } />
24
- </ThemeProvider>
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
- alert('Form Submitted !');
29
- }, onSubmitForgotPassword: function (email) {
30
- throw new Error('Function not implemented.');
31
- } }), (0, jsx_runtime_1.jsx)(MovaSignUp_1.default, { movaAppType: Enums_1.MovaAppType.USER, onSubmit: function (form) {
32
- alert('Form Submitted !');
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, {}) }));
@@ -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: "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({ 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',
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',
@@ -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 : callbakc invoquée en cas de formulaire valide
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
@@ -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: '', isValid: true },
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
- var fieldName = e.target.name;
94
- var fieldValue = e.target.value;
95
- var newField = (_a = {}, _a[fieldName] = { value: fieldValue, isValid: true }, _a);
96
- setUserForm(__assign(__assign({}, userForm), newField));
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: "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: {
171
- shrink: true,
172
- }, 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)(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',
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',
@@ -217,7 +217,7 @@ var VehicleFullCard = function (_a) {
217
217
  '& input': { textTransform: 'uppercase' } // CSS pour forcer les majuscules dans l'input
218
218
  }, helperText: Boolean(form.currentMileage.error && form.currentMileage.value > 0)
219
219
  ? form.currentMileage.error : "Sur ton tableau de bord 😉" }) })), !localEditMode && (0, jsx_runtime_1.jsxs)(material_1.Grid, __assign({ container: true, textAlign: 'justify', sx: { pt: 2 } }, { children: [(0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 8 }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "body1", color: "text.secondary" }, { children: "Km moyen annuel :" })) })), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 4, sx: { textAlign: 'right' } }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "body1", color: "text.secondary" }, { children: (0, jsx_runtime_1.jsxs)("b", { children: [vehicle.averageMileagePerYear, " km"] }) })) }))] })), localEditMode && (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 12 }, { children: (0, jsx_runtime_1.jsxs)(material_1.FormControl, __assign({ fullWidth: true, margin: "normal", error: Boolean(form.averageMileagePerYear.error) }, { children: [(0, jsx_runtime_1.jsx)(material_1.InputLabel, __assign({ id: "averageMileagePerYear-label" }, { children: "Kilom\u00E9trage moyen annuel" })), (0, jsx_runtime_1.jsxs)(material_1.Select, __assign({ labelId: "averageMileagePerYear-label", id: "averageMileagePerYear", name: "averageMileagePerYear", value: form.averageMileagePerYear.value ?
220
- String(form.averageMileagePerYear.value) : '', onChange: function (e) { return handleSelectChange(e); }, label: "Kilom\u00E9trage moyen annuel" }, { children: [(0, jsx_runtime_1.jsx)(material_1.MenuItem, __assign({ value: 5000 }, { children: "5 000" })), (0, jsx_runtime_1.jsx)(material_1.MenuItem, __assign({ value: 10000 }, { children: "10 000" })), (0, jsx_runtime_1.jsx)(material_1.MenuItem, __assign({ value: 15000 }, { children: "15 000" })), (0, jsx_runtime_1.jsx)(material_1.MenuItem, __assign({ value: 20000 }, { children: "20 000" })), (0, jsx_runtime_1.jsx)(material_1.MenuItem, __assign({ value: 25000 }, { children: "25 000" })), (0, jsx_runtime_1.jsx)(material_1.MenuItem, __assign({ value: 30000 }, { children: "30 000" })), (0, jsx_runtime_1.jsx)(material_1.MenuItem, __assign({ value: 50000 }, { children: "50 000" })), (0, jsx_runtime_1.jsx)(material_1.MenuItem, __assign({ value: 75000 }, { children: "75 000" })), (0, jsx_runtime_1.jsx)(material_1.MenuItem, __assign({ value: 100000 }, { children: "100 000" })), (0, jsx_runtime_1.jsx)(material_1.MenuItem, __assign({ value: 999999 }, { children: "+100 000" }))] })), (0, jsx_runtime_1.jsx)(material_1.FormHelperText, { children: form.averageMileagePerYear.error })] })) })), !localEditMode && (0, jsx_runtime_1.jsxs)(material_1.Grid, __assign({ container: true, textAlign: 'justify', sx: { pt: 2 } }, { children: [(0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 6 }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "body1", color: "text.secondary" }, { children: "Pneumatiques :" })) })), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 6, sx: { textAlign: 'right' } }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "body1", color: "text.secondary" }, { children: isVehicleTireSizeDefined(vehicle) ? (0, jsx_runtime_1.jsx)("b", { children: (0, Tools_1.formatVehicleTire)(vehicle.tireSize) }) : '-' })) }))] })), localEditMode && (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 12, sx: { mt: 1 } }, { children: (0, jsx_runtime_1.jsx)(MovaVehicleTireField_1.default, { vehicleTire: form.tireSize.value, onChangeVehicleTire: handleOnChangeVehicleTire }) }))] })), !localEditMode && (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 12 }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "h6", component: "div", align: "center", sx: { mt: 3, mb: 1 }, color: (0, material_1.darken)(theme.palette.primary.main, 0.2) }, { children: "CARNET DU V\u00C9HICULE" })) })), vehicle.documents && ((_b = vehicle.documents) === null || _b === void 0 ? void 0 : _b.filter(function (doc) { return doc.type === Enums_1.DocumentType.VEHICLE_MAINTENANCE_INVOICE; }).map(function (invoice, index) { return ((0, jsx_runtime_1.jsxs)(material_1.Grid, __assign({ container: true, sx: { justifyContent: 'center', alignItems: 'center' } }, { children: [(0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 11, sm: 6, md: 4, sx: { textAlign: 'left' } }, { children: (0, jsx_runtime_1.jsxs)(material_1.Link, __assign({ color: (0, material_1.darken)('#F29ABA', 0.2), href: invoice.fileSignedUrl, target: "_blank", rel: "noopener" }, { children: ["Facture du ", (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, DateUtils_1.formatDateByCountryCode)(invoice.creationDate, 'fr', Enums_1.DateFormatTypes.SHORT_FORMAT_DATE) })] })) }), (index + 1) * 50), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 1, sm: 1, md: 1, sx: { textAlign: 'right' } }, { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, __assign({ onClick: function (e) { return handleDeleteDocument(e, invoice.id); } }, { children: (0, jsx_runtime_1.jsx)(CloseRounded_2.default, {}) })) }), (index + 1) * 100)] }), index + 1)); })), vehicle.documents && ((_c = vehicle.documents) === null || _c === void 0 ? void 0 : _c.filter(function (doc) { return doc.type === Enums_1.DocumentType.VEHICLE_TIRE_PHOTO; }).map(function (tirePhoto, index) { return ((0, jsx_runtime_1.jsxs)(material_1.Grid, __assign({ container: true, sx: { justifyContent: 'center', alignItems: 'center' } }, { children: [(0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 11, sm: 6, md: 4, sx: { textAlign: 'left' } }, { children: (0, jsx_runtime_1.jsxs)(material_1.Link, __assign({ color: (0, material_1.darken)('#F29ABA', 0.2), href: tirePhoto.fileSignedUrl, target: "_blank", rel: "noopener" }, { children: ["Photo pneu du ", (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, DateUtils_1.formatDateByCountryCode)(tirePhoto.creationDate, 'fr', Enums_1.DateFormatTypes.SHORT_FORMAT_DATE) })] })) }), (index + 1) * 50), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 1, sm: 1, md: 1, sx: { textAlign: 'right' } }, { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, __assign({ onClick: function (e) { return handleDeleteDocument(e, tirePhoto.id); } }, { children: (0, jsx_runtime_1.jsx)(CloseRounded_2.default, {}) })) }), (index + 1) * 100)] }), index + 1)); })), (0, jsx_runtime_1.jsxs)(material_1.Grid, __assign({ container: true }, { children: [(0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 6, sx: { mt: 2 } }, { children: (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("input", { accept: "image/*, application/pdf", type: "file", style: { display: 'none' }, ref: invoiceInputRef, id: "raised-button-invoice", onChange: function (e) { return handleFileChange(e, Enums_1.DocumentType.VEHICLE_MAINTENANCE_INVOICE); } }), (0, jsx_runtime_1.jsx)("label", __assign({ htmlFor: "raised-button-invoice" }, { children: (0, jsx_runtime_1.jsx)(material_1.Button, __assign({ size: 'large', component: "span", variant: "outlined", sx: { alignItems: 'normal', width: '90%', mt: 2, mb: 1, height: '70px', p: 1,
220
+ String(form.averageMileagePerYear.value) : '', onChange: function (e) { return handleSelectChange(e); }, label: "Kilom\u00E9trage moyen annuel" }, { children: [(0, jsx_runtime_1.jsx)(material_1.MenuItem, __assign({ value: 5000 }, { children: "5 000" })), (0, jsx_runtime_1.jsx)(material_1.MenuItem, __assign({ value: 10000 }, { children: "10 000" })), (0, jsx_runtime_1.jsx)(material_1.MenuItem, __assign({ value: 15000 }, { children: "15 000" })), (0, jsx_runtime_1.jsx)(material_1.MenuItem, __assign({ value: 20000 }, { children: "20 000" })), (0, jsx_runtime_1.jsx)(material_1.MenuItem, __assign({ value: 25000 }, { children: "25 000" })), (0, jsx_runtime_1.jsx)(material_1.MenuItem, __assign({ value: 30000 }, { children: "30 000" })), (0, jsx_runtime_1.jsx)(material_1.MenuItem, __assign({ value: 50000 }, { children: "50 000" })), (0, jsx_runtime_1.jsx)(material_1.MenuItem, __assign({ value: 75000 }, { children: "75 000" })), (0, jsx_runtime_1.jsx)(material_1.MenuItem, __assign({ value: 100000 }, { children: "100 000" })), (0, jsx_runtime_1.jsx)(material_1.MenuItem, __assign({ value: 999999 }, { children: "+100 000" }))] })), (0, jsx_runtime_1.jsx)(material_1.FormHelperText, { children: form.averageMileagePerYear.error })] })) })), !localEditMode && (0, jsx_runtime_1.jsxs)(material_1.Grid, __assign({ container: true, textAlign: 'justify', sx: { pt: 2 } }, { children: [(0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 6 }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "body1", color: "text.secondary" }, { children: "Pneumatiques :" })) })), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 6, sx: { textAlign: 'right' } }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "body1", color: "text.secondary" }, { children: isVehicleTireSizeDefined(vehicle) ? (0, jsx_runtime_1.jsx)("b", { children: (0, Tools_1.formatVehicleTire)(vehicle.tireSize) }) : '-' })) }))] })), localEditMode && (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 12, sx: { mt: 1 } }, { children: (0, jsx_runtime_1.jsx)(MovaVehicleTireField_1.default, { vehicleTire: form.tireSize.value, onChangeVehicleTire: handleOnChangeVehicleTire }) }))] })), !localEditMode && (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 12 }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "h6", component: "div", align: "center", sx: { mt: 3, mb: 1 }, color: (0, material_1.darken)(theme.palette.primary.main, 0.2) }, { children: "CARNET DU V\u00C9HICULE" })) })), vehicle.documents && ((_b = vehicle.documents) === null || _b === void 0 ? void 0 : _b.filter(function (doc) { return doc.type === Enums_1.DocumentType.VEHICLE_MAINTENANCE_INVOICE; }).map(function (invoice, index) { return ((0, jsx_runtime_1.jsxs)(material_1.Grid, __assign({ container: true, sx: { justifyContent: 'space-between', alignItems: 'center' } }, { children: [(0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 11, sx: { textAlign: 'left' } }, { children: (0, jsx_runtime_1.jsx)(material_1.Link, __assign({ color: (0, material_1.darken)('#F29ABA', 0.2), href: invoice.fileSignedUrl, target: "_blank", rel: "noopener" }, { children: (0, jsx_runtime_1.jsxs)(material_1.Typography, __assign({ variant: "body1" }, { children: ["Facture du ", (0, DateUtils_1.formatDateByCountryCode)(invoice.creationDate, 'fr', Enums_1.DateFormatTypes.SHORT_FORMAT_DATE)] })) })) }), (index + 1) * 50), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 1, sx: { textAlign: 'right' } }, { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, __assign({ onClick: function (e) { return handleDeleteDocument(e, invoice.id); } }, { children: (0, jsx_runtime_1.jsx)(CloseRounded_2.default, {}) })) }), (index + 1) * 100)] }), index + 1)); })), vehicle.documents && ((_c = vehicle.documents) === null || _c === void 0 ? void 0 : _c.filter(function (doc) { return doc.type === Enums_1.DocumentType.VEHICLE_TIRE_PHOTO; }).map(function (tirePhoto, index) { return ((0, jsx_runtime_1.jsxs)(material_1.Grid, __assign({ container: true, sx: { justifyContent: 'space-between', alignItems: 'center' } }, { children: [(0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 11, sx: { textAlign: 'left' } }, { children: (0, jsx_runtime_1.jsx)(material_1.Link, __assign({ color: (0, material_1.darken)('#F29ABA', 0.2), href: tirePhoto.fileSignedUrl, target: "_blank", rel: "noopener" }, { children: (0, jsx_runtime_1.jsxs)(material_1.Typography, __assign({ variant: "body1" }, { children: ["Photo pneu du ", (0, DateUtils_1.formatDateByCountryCode)(tirePhoto.creationDate, 'fr', Enums_1.DateFormatTypes.SHORT_FORMAT_DATE)] })) })) }), (index + 1) * 50), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 1, sx: { textAlign: 'right' } }, { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, __assign({ onClick: function (e) { return handleDeleteDocument(e, tirePhoto.id); } }, { children: (0, jsx_runtime_1.jsx)(CloseRounded_2.default, {}) })) }), (index + 1) * 100)] }), index + 1)); })), (0, jsx_runtime_1.jsxs)(material_1.Grid, __assign({ container: true }, { children: [(0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 6, sx: { mt: 2, textAlign: 'center' } }, { children: (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("input", { accept: "image/*, application/pdf", type: "file", style: { display: 'none' }, ref: invoiceInputRef, id: "raised-button-invoice", onChange: function (e) { return handleFileChange(e, Enums_1.DocumentType.VEHICLE_MAINTENANCE_INVOICE); } }), (0, jsx_runtime_1.jsx)("label", __assign({ htmlFor: "raised-button-invoice" }, { children: (0, jsx_runtime_1.jsx)(material_1.Button, __assign({ size: 'large', component: "span", variant: "outlined", sx: { alignItems: 'normal', width: '90%', mt: 2, mb: 1, height: '70px', p: 1,
221
221
  color: (0, material_1.darken)(theme.palette.primary.main, 0.2) } }, { children: "Ajouter Facture" })) }))] }) })), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 6, sx: { mt: 2, textAlign: 'center' } }, { children: (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("input", { accept: "image/*", type: "file", style: { display: 'none' }, ref: tirePictureInputRef, id: "raised-button-tire", onChange: function (e) { return handleFileChange(e, Enums_1.DocumentType.VEHICLE_TIRE_PHOTO); } }), (0, jsx_runtime_1.jsx)("label", __assign({ htmlFor: "raised-button-tire" }, { children: (0, jsx_runtime_1.jsx)(material_1.Button, __assign({ component: "span", variant: "outlined", sx: { alignItems: 'normal', width: '90%', mt: 2, mb: 1, height: '70px', p: 1,
222
222
  color: (0, material_1.darken)(theme.palette.primary.main, 0.2) } }, { children: "Ajouter Photo Pneu" })) }))] }) }))] }))] })] })), (0, jsx_runtime_1.jsxs)(material_1.CardActions, __assign({ sx: { mt: 3, justifyContent: localEditMode ? 'center' : 'end' } }, { children: [!localEditMode &&
223
223
  (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsxs)(material_1.Button, __assign({ onClick: handleOnClickEdit, color: "inherit", sx: { width: '45%' }, variant: 'text' }, { children: [(0, jsx_runtime_1.jsx)(EditRounded_1.default, { sx: { mr: 1 } }), "MODIFIER"] })) }), localEditMode &&
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@movalib/movalib-commons",
3
- "version": "1.0.65",
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
@@ -1,7 +1,7 @@
1
1
  <!DOCTYPE html>
2
2
  <html>
3
3
  <head>
4
- <title>Movalib Commons App</title>
4
+ <title>Movalib Commons</title>
5
5
  </head>
6
6
  <body>
7
7
  <div id="root"></div>
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="password"
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"
@@ -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, Link, SelectChangeEvent, TextField, Typography } from "@mui/material";
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: '', isValid: true },
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 : callbakc invoquée en cas de formulaire valide
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
- const fieldName: string = e.target.name;
62
- const fieldValue: string = e.target.value;
63
- const newField: MovaFormField = { [fieldName]: { value: fieldValue, isValid: true } };
64
-
65
- setUserForm({ ...userForm, ...newField});
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="password"
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 : "8 caractères minimum"}
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={
@@ -367,13 +367,15 @@ const VehicleFullCard: FC<VehicleFullCardProps> = ({ vehicle, fullwidth, onError
367
367
  {/** Les FACTURES du véhicule */}
368
368
  {vehicle.documents && vehicle.documents?.filter(doc => doc.type === DocumentType.VEHICLE_MAINTENANCE_INVOICE)
369
369
  .map((invoice, index) => (
370
- <Grid container sx={{ justifyContent: 'center', alignItems: 'center' }} key={index+1}>
371
- <Grid item xs={11} sm={6} md={4} key={(index+1)*50} sx={{ textAlign: 'left' }} >
370
+ <Grid container sx={{ justifyContent: 'space-between', alignItems: 'center' }} key={index+1}>
371
+ <Grid item xs={11} key={(index+1)*50} sx={{ textAlign: 'left' }} >
372
372
  <Link color={darken('#F29ABA', 0.2)} href={invoice.fileSignedUrl} target="_blank" rel="noopener">
373
- Facture du <>{formatDateByCountryCode(invoice.creationDate, 'fr', DateFormatTypes.SHORT_FORMAT_DATE)}</>
373
+ <Typography variant="body1">
374
+ Facture du {formatDateByCountryCode(invoice.creationDate, 'fr', DateFormatTypes.SHORT_FORMAT_DATE)}
375
+ </Typography>
374
376
  </Link>
375
377
  </Grid>
376
- <Grid item xs={1} sm={1} md={1} key={(index+1)*100} sx={{ textAlign: 'right' }}>
378
+ <Grid item xs={1} key={(index+1)*100} sx={{ textAlign: 'right' }}>
377
379
  <IconButton onClick={(e) => handleDeleteDocument(e, invoice.id)}>
378
380
  <CloseIcon />
379
381
  </IconButton>
@@ -384,13 +386,15 @@ const VehicleFullCard: FC<VehicleFullCardProps> = ({ vehicle, fullwidth, onError
384
386
  {/** Les PHOTOS du véhicule */}
385
387
  {vehicle.documents && vehicle.documents?.filter(doc => doc.type === DocumentType.VEHICLE_TIRE_PHOTO)
386
388
  .map((tirePhoto, index) => (
387
- <Grid container sx={{ justifyContent: 'center', alignItems: 'center' }} key={index+1}>
388
- <Grid item xs={11} sm={6} md={4} key={(index+1)*50} sx={{ textAlign: 'left' }} >
389
+ <Grid container sx={{ justifyContent: 'space-between', alignItems: 'center' }} key={index+1}>
390
+ <Grid item xs={11} key={(index+1)*50} sx={{ textAlign: 'left' }} >
389
391
  <Link color={darken('#F29ABA', 0.2)} href={tirePhoto.fileSignedUrl} target="_blank" rel="noopener">
390
- Photo pneu du <>{formatDateByCountryCode(tirePhoto.creationDate, 'fr', DateFormatTypes.SHORT_FORMAT_DATE)}</>
392
+ <Typography variant="body1">
393
+ Photo pneu du {formatDateByCountryCode(tirePhoto.creationDate, 'fr', DateFormatTypes.SHORT_FORMAT_DATE)}
394
+ </Typography>
391
395
  </Link>
392
396
  </Grid>
393
- <Grid item xs={1} sm={1} md={1} key={(index+1)*100} sx={{ textAlign: 'right' }}>
397
+ <Grid item xs={1} key={(index+1)*100} sx={{ textAlign: 'right' }}>
394
398
  <IconButton onClick={(e) => handleDeleteDocument(e, tirePhoto.id)}>
395
399
  <CloseIcon />
396
400
  </IconButton>
@@ -399,7 +403,7 @@ const VehicleFullCard: FC<VehicleFullCardProps> = ({ vehicle, fullwidth, onError
399
403
  ))}
400
404
 
401
405
  <Grid container >
402
- <Grid item xs={6} sx={{ mt: 2 }} >
406
+ <Grid item xs={6} sx={{ mt: 2, textAlign: 'center' }} >
403
407
  {/* Input caché de type "file" */}
404
408
  <div>
405
409
  <input