@movalib/movalib-commons 1.0.49 → 1.0.51
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 +2 -0
- package/dist/devIndex.js +2 -0
- package/dist/src/MovaLogin.d.ts +1 -0
- package/dist/src/MovaLogin.js +22 -2
- package/dist/src/MovaSignUp.js +10 -1
- package/dist/src/QRCode.js +2 -2
- package/package.json +1 -1
- package/src/MovaLogin.tsx +70 -4
- package/src/MovaSignUp.tsx +10 -2
- package/src/QRCode.tsx +2 -2
package/devIndex.tsx
CHANGED
|
@@ -14,6 +14,8 @@ const App = () => {
|
|
|
14
14
|
<ThemeProvider theme={theme}>
|
|
15
15
|
<MovaLogin movaAppType={MovaAppType.GARAGE} onSubmit={function (form: MovaLoginForm): void {
|
|
16
16
|
alert('Form Submitted !');
|
|
17
|
+
} } onSubmitForgotPassword={function (email: string): void {
|
|
18
|
+
throw new Error('Function not implemented.');
|
|
17
19
|
} } />
|
|
18
20
|
|
|
19
21
|
<MovaSignUp movaAppType={MovaAppType.USER} onSubmit={function (form: MovaLoginForm): void {
|
package/dist/devIndex.js
CHANGED
|
@@ -26,6 +26,8 @@ var MovaSignUp_1 = __importDefault(require("./src/MovaSignUp"));
|
|
|
26
26
|
var App = function () {
|
|
27
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
28
|
alert('Form Submitted !');
|
|
29
|
+
}, onSubmitForgotPassword: function (email) {
|
|
30
|
+
throw new Error('Function not implemented.');
|
|
29
31
|
} }), (0, jsx_runtime_1.jsx)(MovaSignUp_1.default, { movaAppType: Enums_1.MovaAppType.USER, onSubmit: function (form) {
|
|
30
32
|
alert('Form Submitted !');
|
|
31
33
|
} })] })) }));
|
package/dist/src/MovaLogin.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ import { MovaAppType } from "./helpers/Enums";
|
|
|
13
13
|
interface MovaLoginProps {
|
|
14
14
|
movaAppType: MovaAppType;
|
|
15
15
|
onSubmit: (form: MovaLoginForm) => void;
|
|
16
|
+
onSubmitForgotPassword: (email: string) => void;
|
|
16
17
|
alertMessage?: string;
|
|
17
18
|
alertSeverity?: AlertColor;
|
|
18
19
|
loading?: boolean;
|
package/dist/src/MovaLogin.js
CHANGED
|
@@ -80,10 +80,11 @@ var initialFormState = {
|
|
|
80
80
|
* ATTENTION : la page attendue pour le bouton "Créer mon compte" doit pointer vers "/signup"
|
|
81
81
|
*/
|
|
82
82
|
var MovaLogin = function (_a) {
|
|
83
|
-
var loading = _a.loading, movaAppType = _a.movaAppType, onSubmit = _a.onSubmit, alertMessage = _a.alertMessage, alertSeverity = _a.alertSeverity;
|
|
83
|
+
var loading = _a.loading, movaAppType = _a.movaAppType, onSubmit = _a.onSubmit, onSubmitForgotPassword = _a.onSubmitForgotPassword, alertMessage = _a.alertMessage, alertSeverity = _a.alertSeverity;
|
|
84
84
|
var _b = (0, react_1.useState)(initialFormState), form = _b[0], setForm = _b[1];
|
|
85
85
|
var _c = (0, react_1.useState)(""), message = _c[0], setMessage = _c[1];
|
|
86
86
|
var history = (0, react_router_dom_1.useHistory)();
|
|
87
|
+
var _d = (0, react_1.useState)(false), openForgotPassword = _d[0], setOpenForgotPassword = _d[1];
|
|
87
88
|
var handleInputChange = function (e) {
|
|
88
89
|
var _a;
|
|
89
90
|
var fieldName = e.target.name;
|
|
@@ -130,6 +131,25 @@ var MovaLogin = function (_a) {
|
|
|
130
131
|
history.push('/signup');
|
|
131
132
|
}
|
|
132
133
|
};
|
|
134
|
+
var handleOnClickForgotPassword = function (e) {
|
|
135
|
+
e.preventDefault();
|
|
136
|
+
setOpenForgotPassword(true);
|
|
137
|
+
};
|
|
138
|
+
var handleSubmitForgotPassword = function (e) {
|
|
139
|
+
e.preventDefault();
|
|
140
|
+
setOpenForgotPassword(false);
|
|
141
|
+
// On appel de callback de soumission de la demande de réinitialisation du mot de passe
|
|
142
|
+
if (onSubmitForgotPassword) {
|
|
143
|
+
onSubmitForgotPassword(form.email.value);
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
/**
|
|
147
|
+
* Boite de diaogue pour la perte du mot de passe
|
|
148
|
+
*/
|
|
149
|
+
var dialogForgotPassword = function () {
|
|
150
|
+
var defaultMessage = "Êtes-vous sûr de vouloir continuer ?";
|
|
151
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.Dialog, __assign({ open: openForgotPassword, onClose: function () { return setOpenForgotPassword(false); }, "aria-labelledby": "forgot-password-dialog-title", "aria-describedby": "forgot-password-dialog-description" }, { children: [(0, jsx_runtime_1.jsx)(material_1.DialogTitle, __assign({ id: "forgot-password-title" }, { children: "R\u00E9cup\u00E9ration du mot de passe" })), (0, jsx_runtime_1.jsxs)(material_1.DialogContent, { children: [(0, jsx_runtime_1.jsx)(material_1.DialogContentText, __assign({ id: "forgot-password-dialog-description", sx: { mb: 2 } }, { children: "Saisissez votre email pour proc\u00E9der \u00E0 la r\u00E9initialisation de votre mot de passe." })), (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, disabled: !(form.email.value && (0, Validator_1.validateEmail)(form.email.value)) })] }), (0, jsx_runtime_1.jsx)(material_1.DialogActions, { children: (0, jsx_runtime_1.jsx)(material_1.Button, __assign({ onClick: function (e) { return handleSubmitForgotPassword(e); }, color: "inherit", autoFocus: true, sx: { ml: 1 } }, { children: "Envoyer ma demande" })) })] })));
|
|
152
|
+
};
|
|
133
153
|
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',
|
|
134
154
|
float: 'left',
|
|
135
155
|
width: '250px',
|
|
@@ -142,7 +162,7 @@ var MovaLogin = function (_a) {
|
|
|
142
162
|
display: 'flex',
|
|
143
163
|
flexDirection: 'column',
|
|
144
164
|
alignItems: 'center',
|
|
145
|
-
} }, { children: [(0, jsx_runtime_1.jsx)("img", { src: getMovaLogo(), style: { width: '80%' } }), (0, jsx_runtime_1.jsx)("br", {})] })), (0, jsx_runtime_1.jsxs)(material_1.Box, __assign({ component: "form", onSubmit: handleSubmit, noValidate: true, sx: { mt: 1 } }, { children: [(0, jsx_runtime_1.jsx)(material_1.TextField, { margin: "normal", required: true, fullWidth: true, id: "email", label: "Adresse email", name: "email", autoComplete: "email", autoFocus: true, onChange: function (e) { return handleInputChange(e); }, value: form.email.value, error: !form.email.isValid, helperText: form.email.error }), (0, jsx_runtime_1.jsx)(material_1.TextField, { margin: "normal", required: true, fullWidth: true, name: "password", label: "Mot de passe", type: "password", id: "password", autoComplete: "current-password", onChange: function (e) { return handleInputChange(e); }, value: form.password.value, error: !form.password.isValid, helperText: form.password.error }), (0, jsx_runtime_1.jsx)(material_1.FormControlLabel, { control: (0, jsx_runtime_1.jsx)(material_1.Checkbox, { value: "remember", color: "primary" }), label: "Se souvenir de moi" }), (0, jsx_runtime_1.jsx)(lab_1.LoadingButton, __assign({ loading: loading, type: "submit", fullWidth: true, variant: "contained", sx: { mt: 3, mb: 2 } }, { children: (0, jsx_runtime_1.jsx)("span", { children: "Se connecter" }) })), alertMessage && alertSeverity && (0, jsx_runtime_1.jsx)(material_1.Alert, __assign({ severity: alertSeverity, sx: { mb: 2 } }, { children: alertMessage })), (0, jsx_runtime_1.jsxs)(material_1.Grid, __assign({ container: true }, { children: [(0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: true }, { children: (0, jsx_runtime_1.jsx)(material_1.Link, __assign({
|
|
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',
|
|
146
166
|
float: 'right',
|
|
147
167
|
width: '250px',
|
|
148
168
|
height: '400px',
|
package/dist/src/MovaSignUp.js
CHANGED
|
@@ -63,6 +63,7 @@ var Enums_1 = require("./helpers/Enums");
|
|
|
63
63
|
var Validator_1 = require("./helpers/Validator");
|
|
64
64
|
var GenderSelector_1 = __importDefault(require("./GenderSelector"));
|
|
65
65
|
var Tools_1 = require("./helpers/Tools");
|
|
66
|
+
var react_router_dom_1 = require("react-router-dom");
|
|
66
67
|
// Permet de centrer le contenu de l'application
|
|
67
68
|
var styles = {
|
|
68
69
|
display: 'flex',
|
|
@@ -85,6 +86,7 @@ var initialUserFormState = {
|
|
|
85
86
|
var MovaLogin = function (_a) {
|
|
86
87
|
var loading = _a.loading, movaAppType = _a.movaAppType, onSubmit = _a.onSubmit, alertMessage = _a.alertMessage, alertSeverity = _a.alertSeverity;
|
|
87
88
|
var _b = (0, react_1.useState)(initialUserFormState), userForm = _b[0], setUserForm = _b[1];
|
|
89
|
+
var history = (0, react_router_dom_1.useHistory)();
|
|
88
90
|
var _c = (0, react_1.useState)(""), message = _c[0], setMessage = _c[1];
|
|
89
91
|
var handleInputChange = function (e) {
|
|
90
92
|
var _a;
|
|
@@ -146,6 +148,13 @@ var MovaLogin = function (_a) {
|
|
|
146
148
|
movaAppType === Enums_1.MovaAppType.USER ? logo_large_png_1.default :
|
|
147
149
|
movaAppType === Enums_1.MovaAppType.ADMIN ? logo_large_png_1.default : logo_large_png_1.default;
|
|
148
150
|
};
|
|
151
|
+
var handleOnClickLogin = function (e) {
|
|
152
|
+
e.preventDefault();
|
|
153
|
+
if (history) {
|
|
154
|
+
// On redirige l'utilisateur vers la page par défaut (accueil)
|
|
155
|
+
history.push('/login');
|
|
156
|
+
}
|
|
157
|
+
};
|
|
149
158
|
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',
|
|
150
159
|
float: 'left',
|
|
151
160
|
width: '250px',
|
|
@@ -160,7 +169,7 @@ var MovaLogin = function (_a) {
|
|
|
160
169
|
alignItems: 'center',
|
|
161
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: {
|
|
162
171
|
shrink: true,
|
|
163
|
-
}, 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({
|
|
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',
|
|
164
173
|
float: 'right',
|
|
165
174
|
width: '250px',
|
|
166
175
|
height: '400px',
|
package/dist/src/QRCode.js
CHANGED
|
@@ -16,9 +16,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
18
18
|
var react_1 = require("react");
|
|
19
|
-
var leaf_yellow_small_png_1 = __importDefault(require("
|
|
20
|
-
var qr_code_styling_1 = __importDefault(require("qr-code-styling"));
|
|
19
|
+
var leaf_yellow_small_png_1 = __importDefault(require("./assets/images/leaf_yellow_small.png"));
|
|
21
20
|
var material_1 = require("@mui/material");
|
|
21
|
+
var qr_code_styling_1 = __importDefault(require("qr-code-styling"));
|
|
22
22
|
var styles = {
|
|
23
23
|
inputWrapper: {
|
|
24
24
|
margin: "20px 0",
|
package/package.json
CHANGED
package/src/MovaLogin.tsx
CHANGED
|
@@ -4,7 +4,8 @@ import LogoLarge from './assets/images/logo/logo_large.png';
|
|
|
4
4
|
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
|
-
import { Alert, AlertColor, Box, Checkbox, Container, CssBaseline,
|
|
7
|
+
import { Alert, AlertColor, Box, Button, Checkbox, Container, CssBaseline, Dialog, DialogActions, DialogContent, DialogContentText,
|
|
8
|
+
DialogTitle, FormControlLabel, Grid, Link, TextField } from "@mui/material";
|
|
8
9
|
import MovaCopyright from "./MovaCopyright";
|
|
9
10
|
import { MovaLoginForm, MovaFormField } from "./helpers/Types";
|
|
10
11
|
import { MovaAppType } from "./helpers/Enums";
|
|
@@ -36,6 +37,7 @@ const initialFormState = {
|
|
|
36
37
|
interface MovaLoginProps {
|
|
37
38
|
movaAppType: MovaAppType,
|
|
38
39
|
onSubmit: (form: MovaLoginForm) => void,
|
|
40
|
+
onSubmitForgotPassword: (email: string) => void,
|
|
39
41
|
alertMessage?: string,
|
|
40
42
|
alertSeverity?: AlertColor,
|
|
41
43
|
loading?: boolean
|
|
@@ -46,11 +48,12 @@ interface MovaLoginProps {
|
|
|
46
48
|
* ATTENTION : la page attendue pour le bouton "Mot de passe oublié" doit pointer vers "/forgot-password"
|
|
47
49
|
* ATTENTION : la page attendue pour le bouton "Créer mon compte" doit pointer vers "/signup"
|
|
48
50
|
*/
|
|
49
|
-
const MovaLogin: FunctionComponent<MovaLoginProps> = ({ loading, movaAppType, onSubmit, alertMessage, alertSeverity }) => {
|
|
51
|
+
const MovaLogin: FunctionComponent<MovaLoginProps> = ({ loading, movaAppType, onSubmit, onSubmitForgotPassword, alertMessage, alertSeverity }) => {
|
|
50
52
|
|
|
51
53
|
const [form, setForm] = useState<MovaLoginForm>(initialFormState);
|
|
52
54
|
const [message, setMessage] = useState<string>("");
|
|
53
55
|
const history = useHistory();
|
|
56
|
+
const [openForgotPassword, setOpenForgotPassword] = useState(false);
|
|
54
57
|
|
|
55
58
|
const handleInputChange = (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>): void => {
|
|
56
59
|
const fieldName: string = e.target.name;
|
|
@@ -108,6 +111,64 @@ const MovaLogin: FunctionComponent<MovaLoginProps> = ({ loading, movaAppType, on
|
|
|
108
111
|
}
|
|
109
112
|
}
|
|
110
113
|
|
|
114
|
+
const handleOnClickForgotPassword = (e: React.MouseEvent<HTMLAnchorElement, MouseEvent>) => {
|
|
115
|
+
e.preventDefault();
|
|
116
|
+
setOpenForgotPassword(true);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const handleSubmitForgotPassword = (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => {
|
|
120
|
+
e.preventDefault();
|
|
121
|
+
|
|
122
|
+
setOpenForgotPassword(false);
|
|
123
|
+
// On appel de callback de soumission de la demande de réinitialisation du mot de passe
|
|
124
|
+
if(onSubmitForgotPassword){
|
|
125
|
+
onSubmitForgotPassword(form.email.value);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Boite de diaogue pour la perte du mot de passe
|
|
132
|
+
*/
|
|
133
|
+
const dialogForgotPassword = () => {
|
|
134
|
+
const defaultMessage = "Êtes-vous sûr de vouloir continuer ?";
|
|
135
|
+
|
|
136
|
+
return (
|
|
137
|
+
<Dialog
|
|
138
|
+
open={openForgotPassword}
|
|
139
|
+
onClose={() => setOpenForgotPassword(false)}
|
|
140
|
+
aria-labelledby="forgot-password-dialog-title"
|
|
141
|
+
aria-describedby="forgot-password-dialog-description"
|
|
142
|
+
>
|
|
143
|
+
<DialogTitle id="forgot-password-title">Récupération du mot de passe</DialogTitle>
|
|
144
|
+
<DialogContent>
|
|
145
|
+
<DialogContentText id="forgot-password-dialog-description" sx={{ mb: 2 }}>
|
|
146
|
+
Saisissez votre email pour procéder à la réinitialisation de votre mot de passe.
|
|
147
|
+
</DialogContentText>
|
|
148
|
+
<TextField
|
|
149
|
+
margin="normal"
|
|
150
|
+
required
|
|
151
|
+
fullWidth
|
|
152
|
+
id="email"
|
|
153
|
+
label="Adresse email"
|
|
154
|
+
name="email"
|
|
155
|
+
autoComplete="email"
|
|
156
|
+
autoFocus
|
|
157
|
+
onChange={e => handleInputChange(e)}
|
|
158
|
+
value={form.email.value}
|
|
159
|
+
error={!form.email.isValid}
|
|
160
|
+
helperText={form.email.error}
|
|
161
|
+
disabled={!(form.email.value && validateEmail(form.email.value))}
|
|
162
|
+
/>
|
|
163
|
+
</DialogContent>
|
|
164
|
+
<DialogActions>
|
|
165
|
+
<Button onClick={(e) => handleSubmitForgotPassword(e)} color="inherit" autoFocus sx={{ ml: 1}}>
|
|
166
|
+
Envoyer ma demande
|
|
167
|
+
</Button>
|
|
168
|
+
</DialogActions>
|
|
169
|
+
</Dialog>
|
|
170
|
+
);
|
|
171
|
+
}
|
|
111
172
|
|
|
112
173
|
return (
|
|
113
174
|
<div style={styles}>
|
|
@@ -180,18 +241,23 @@ const MovaLogin: FunctionComponent<MovaLoginProps> = ({ loading, movaAppType, on
|
|
|
180
241
|
|
|
181
242
|
<Grid container>
|
|
182
243
|
<Grid item xs>
|
|
183
|
-
<Link
|
|
244
|
+
<Link variant="body2" color="text.secondary" onClick={(e) => handleOnClickForgotPassword(e)}>
|
|
184
245
|
Mot de passe oublié ?
|
|
185
246
|
</Link>
|
|
186
247
|
</Grid>
|
|
187
248
|
{movaAppType === MovaAppType.USER && <Grid item>
|
|
188
249
|
<Link variant="body2" color="text.secondary" onClick={(e) => handleOnClickSignUp(e)}>
|
|
189
|
-
|
|
250
|
+
Créer mon compte
|
|
190
251
|
</Link>
|
|
191
252
|
</Grid>}
|
|
192
253
|
</Grid>
|
|
193
254
|
</Box>
|
|
255
|
+
|
|
194
256
|
<MovaCopyright sx={{ mt: 8, mb: 4 }} />
|
|
257
|
+
|
|
258
|
+
{openForgotPassword && dialogForgotPassword()}
|
|
259
|
+
|
|
260
|
+
|
|
195
261
|
</Container>
|
|
196
262
|
|
|
197
263
|
<img src={PinkLeafImage} style={{position: 'fixed',
|
package/src/MovaSignUp.tsx
CHANGED
|
@@ -11,6 +11,7 @@ import { MovaAppType } from "./helpers/Enums";
|
|
|
11
11
|
import { validateEmail } from "./helpers/Validator";
|
|
12
12
|
import GenderSelector from "./GenderSelector";
|
|
13
13
|
import { validateField } from "./helpers/Tools";
|
|
14
|
+
import { useHistory } from "react-router-dom";
|
|
14
15
|
|
|
15
16
|
// Permet de centrer le contenu de l'application
|
|
16
17
|
const styles: CSSProperties = {
|
|
@@ -52,7 +53,7 @@ interface MovaSignUpProps {
|
|
|
52
53
|
const MovaLogin: FunctionComponent<MovaSignUpProps> = ({ loading, movaAppType, onSubmit, alertMessage, alertSeverity }) => {
|
|
53
54
|
|
|
54
55
|
const [userForm, setUserForm] = useState<MovaUserSignUpForm>(initialUserFormState);
|
|
55
|
-
|
|
56
|
+
const history = useHistory();
|
|
56
57
|
const [message, setMessage] = useState<string>("");
|
|
57
58
|
|
|
58
59
|
const handleInputChange = (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>): void => {
|
|
@@ -129,6 +130,13 @@ const MovaLogin: FunctionComponent<MovaSignUpProps> = ({ loading, movaAppType, o
|
|
|
129
130
|
movaAppType === MovaAppType.ADMIN ? LogoLarge : LogoLarge;
|
|
130
131
|
}
|
|
131
132
|
|
|
133
|
+
const handleOnClickLogin = (e: React.MouseEvent<HTMLAnchorElement, MouseEvent>) => {
|
|
134
|
+
e.preventDefault();
|
|
135
|
+
if(history){
|
|
136
|
+
// On redirige l'utilisateur vers la page par défaut (accueil)
|
|
137
|
+
history.push('/login');
|
|
138
|
+
}
|
|
139
|
+
}
|
|
132
140
|
|
|
133
141
|
return (
|
|
134
142
|
<div style={styles}>
|
|
@@ -265,7 +273,7 @@ const MovaLogin: FunctionComponent<MovaSignUpProps> = ({ loading, movaAppType, o
|
|
|
265
273
|
|
|
266
274
|
<Grid container>
|
|
267
275
|
<Grid item xs>
|
|
268
|
-
<Link
|
|
276
|
+
<Link variant="body2" color="text.secondary" onClick={(e) => handleOnClickLogin(e)}>
|
|
269
277
|
Se connecter
|
|
270
278
|
</Link>
|
|
271
279
|
</Grid>
|
package/src/QRCode.tsx
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useState, type FC, useRef, useEffect, ChangeEvent } from 'react';
|
|
2
|
-
import QRCodeImage from "
|
|
2
|
+
import QRCodeImage from "./assets/images/leaf_yellow_small.png";
|
|
3
|
+
import { Box, Button, darken, useTheme } from '@mui/material';
|
|
3
4
|
import QRCodeStyling, {
|
|
4
5
|
DrawType,
|
|
5
6
|
TypeNumber,
|
|
@@ -11,7 +12,6 @@ import QRCodeStyling, {
|
|
|
11
12
|
Extension,
|
|
12
13
|
Options
|
|
13
14
|
} from "qr-code-styling";
|
|
14
|
-
import { Box, Button, darken, useTheme } from '@mui/material';
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
interface QRCodeProps {
|