@movalib/movalib-commons 1.0.19 → 1.0.21

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.
@@ -17,5 +17,10 @@ interface MovaLoginProps {
17
17
  alertSeverity?: AlertColor;
18
18
  loading?: boolean;
19
19
  }
20
+ /**
21
+ * Formulaire d'authentification Movalib (Garage / Utilisateur)
22
+ * ATTENTION : la page attendue pour le bouton "Mot de passe oublié" doit pointer vers "/forgot-password"
23
+ * ATTENTION : la page attendue pour le bouton "Créer mon compte" doit pointer vers "/signup"
24
+ */
20
25
  declare const MovaLogin: FunctionComponent<MovaLoginProps>;
21
26
  export default MovaLogin;
@@ -73,6 +73,11 @@ var initialFormState = {
73
73
  email: { value: '', isValid: true },
74
74
  password: { value: '', isValid: true },
75
75
  };
76
+ /**
77
+ * Formulaire d'authentification Movalib (Garage / Utilisateur)
78
+ * ATTENTION : la page attendue pour le bouton "Mot de passe oublié" doit pointer vers "/forgot-password"
79
+ * ATTENTION : la page attendue pour le bouton "Créer mon compte" doit pointer vers "/signup"
80
+ */
76
81
  var MovaLogin = function (_a) {
77
82
  var loading = _a.loading, movaAppType = _a.movaAppType, onSubmit = _a.onSubmit, alertMessage = _a.alertMessage, alertSeverity = _a.alertSeverity;
78
83
  var _b = (0, react_1.useState)(initialFormState), form = _b[0], setForm = _b[1];
@@ -128,7 +133,7 @@ var MovaLogin = function (_a) {
128
133
  display: 'flex',
129
134
  flexDirection: 'column',
130
135
  alignItems: 'center',
131
- } }, { children: [(0, jsx_runtime_1.jsx)("img", { src: getMovaLogo(), style: { width: '80%' } }), (0, jsx_runtime_1.jsx)("br", {})] })), (0, jsx_runtime_1.jsxs)(material_1.Box, __assign({ component: "form", onSubmit: handleSubmit, noValidate: true, sx: { mt: 1 } }, { children: [(0, jsx_runtime_1.jsx)(material_1.TextField, { margin: "normal", required: true, fullWidth: true, id: "email", label: "Adresse email", name: "email", autoComplete: "email", autoFocus: true, onChange: function (e) { return handleInputChange(e); }, value: form.email.value, error: !form.email.isValid, helperText: form.email.error }), (0, jsx_runtime_1.jsx)(material_1.TextField, { margin: "normal", required: true, fullWidth: true, name: "password", label: "Mot de passe", type: "password", id: "password", autoComplete: "current-password", onChange: function (e) { return handleInputChange(e); }, value: form.password.value, error: !form.password.isValid, helperText: form.password.error }), (0, jsx_runtime_1.jsx)(material_1.FormControlLabel, { control: (0, jsx_runtime_1.jsx)(material_1.Checkbox, { value: "remember", color: "primary" }), label: "Se souvenir de moi" }), (0, jsx_runtime_1.jsx)(lab_1.LoadingButton, __assign({ loading: loading, type: "submit", fullWidth: true, variant: "contained", sx: { mt: 3, mb: 2 } }, { children: (0, jsx_runtime_1.jsx)("span", { children: "Se connecter" }) })), alertMessage && alertSeverity && (0, jsx_runtime_1.jsx)(material_1.Alert, __assign({ severity: alertSeverity, sx: { mb: 2 } }, { children: alertMessage })), (0, jsx_runtime_1.jsxs)(material_1.Grid, __assign({ container: true }, { children: [(0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: true }, { children: (0, jsx_runtime_1.jsx)(material_1.Link, __assign({ href: "/forgot-password", variant: "body2", color: "text.secondary" }, { children: "Mot de passe oubli\u00E9 ?" })) })), movaAppType === Enums_1.MovaAppType.USER && (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true }, { children: (0, jsx_runtime_1.jsx)(material_1.Link, __assign({ href: "/signup", variant: "body2", color: "text.secondary" }, { children: "Créer un compte" })) }))] }))] })), (0, jsx_runtime_1.jsx)(MovaCopyright_1.default, { sx: { mt: 8, mb: 4 } })] })), (0, jsx_runtime_1.jsx)("img", { src: leaf_pink_large_png_1.default, style: { position: 'fixed',
136
+ } }, { children: [(0, jsx_runtime_1.jsx)("img", { src: getMovaLogo(), style: { width: '80%' } }), (0, jsx_runtime_1.jsx)("br", {})] })), (0, jsx_runtime_1.jsxs)(material_1.Box, __assign({ component: "form", onSubmit: handleSubmit, noValidate: true, sx: { mt: 1 } }, { children: [(0, jsx_runtime_1.jsx)(material_1.TextField, { margin: "normal", required: true, fullWidth: true, id: "email", label: "Adresse email", name: "email", autoComplete: "email", autoFocus: true, onChange: function (e) { return handleInputChange(e); }, value: form.email.value, error: !form.email.isValid, helperText: form.email.error }), (0, jsx_runtime_1.jsx)(material_1.TextField, { margin: "normal", required: true, fullWidth: true, name: "password", label: "Mot de passe", type: "password", id: "password", autoComplete: "current-password", onChange: function (e) { return handleInputChange(e); }, value: form.password.value, error: !form.password.isValid, helperText: form.password.error }), (0, jsx_runtime_1.jsx)(material_1.FormControlLabel, { control: (0, jsx_runtime_1.jsx)(material_1.Checkbox, { value: "remember", color: "primary" }), label: "Se souvenir de moi" }), (0, jsx_runtime_1.jsx)(lab_1.LoadingButton, __assign({ loading: loading, type: "submit", fullWidth: true, variant: "contained", sx: { mt: 3, mb: 2 } }, { children: (0, jsx_runtime_1.jsx)("span", { children: "Se connecter" }) })), alertMessage && alertSeverity && (0, jsx_runtime_1.jsx)(material_1.Alert, __assign({ severity: alertSeverity, sx: { mb: 2 } }, { children: alertMessage })), (0, jsx_runtime_1.jsxs)(material_1.Grid, __assign({ container: true }, { children: [(0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: true }, { children: (0, jsx_runtime_1.jsx)(material_1.Link, __assign({ href: "/forgot-password", variant: "body2", color: "text.secondary" }, { children: "Mot de passe oubli\u00E9 ?" })) })), movaAppType === Enums_1.MovaAppType.USER && (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true }, { children: (0, jsx_runtime_1.jsx)(material_1.Link, __assign({ href: "/signup", variant: "body2", color: "text.secondary" }, { children: "Créer mon compte" })) }))] }))] })), (0, jsx_runtime_1.jsx)(MovaCopyright_1.default, { sx: { mt: 8, mb: 4 } })] })), (0, jsx_runtime_1.jsx)("img", { src: leaf_pink_large_png_1.default, style: { position: 'fixed',
132
137
  float: 'right',
133
138
  width: '250px',
134
139
  height: '400px',
@@ -17,5 +17,9 @@ interface MovaSignUpProps {
17
17
  alertSeverity?: AlertColor;
18
18
  loading?: boolean;
19
19
  }
20
+ /**
21
+ * Formulaire de création d'un compte Movalib (Garage / Utilisateur)
22
+ * ATTENTION : le lien de consultation des CGU doit pointer vers "/terms-and-conditions"
23
+ */
20
24
  declare const MovaLogin: FunctionComponent<MovaSignUpProps>;
21
25
  export default MovaLogin;
@@ -79,6 +79,10 @@ var initialUserFormState = {
79
79
  birthDate: { value: '', isValid: true },
80
80
  acceptsTerms: { value: false, isValid: true },
81
81
  };
82
+ /**
83
+ * Formulaire de création d'un compte Movalib (Garage / Utilisateur)
84
+ * ATTENTION : le lien de consultation des CGU doit pointer vers "/terms-and-conditions"
85
+ */
82
86
  var MovaLogin = function (_a) {
83
87
  var loading = _a.loading, movaAppType = _a.movaAppType, onSubmit = _a.onSubmit, alertMessage = _a.alertMessage, alertSeverity = _a.alertSeverity;
84
88
  var _b = (0, react_1.useState)(initialUserFormState), userForm = _b[0], setUserForm = _b[1];
@@ -135,8 +139,8 @@ var MovaLogin = function (_a) {
135
139
  // Validator pour les CGU
136
140
  newForm.acceptsTerms = (0, Tools_1.validateField)(userForm.acceptsTerms, function (value) { return Boolean(value); }, 'Vous devez accepter les termes de nos CGU');
137
141
  setUserForm(newForm);
138
- return newForm.firstname.isValid && newForm.lastname.isValid && newForm.email.isValid
139
- && newForm.password.isValid && newForm.gender.isValid && newForm.birthDate.isValid;
142
+ return newForm.firstname.isValid && newForm.lastname.isValid && newForm.email.isValid && newForm.password.isValid
143
+ && newForm.gender.isValid && newForm.birthDate.isValid && newForm.acceptsTerms.isValid;
140
144
  };
141
145
  var getMovaLogo = function () {
142
146
  return movaAppType === Enums_1.MovaAppType.GARAGE ? logo_pro_large_png_1.default :
@@ -157,7 +161,7 @@ var MovaLogin = function (_a) {
157
161
  alignItems: 'center',
158
162
  } }, { 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: {
159
163
  shrink: true,
160
- }, autoComplete: "bday", value: userForm.birthDate.value, error: !userForm.birthDate.isValid, helperText: userForm.birthDate.error, onChange: function (e) { return handleInputChange(e); }, sx: { width: '50%', float: 'right' } }), (0, jsx_runtime_1.jsxs)(material_1.FormControl, __assign({ error: !userForm.acceptsTerms.isValid }, { children: [(0, jsx_runtime_1.jsx)(material_1.FormControlLabel, { control: (0, jsx_runtime_1.jsx)(material_1.Checkbox, { name: "acceptsTerms", color: "primary", checked: userForm.acceptsTerms.value, onChange: function (e, checked) { return handleCheckboxChange(e, checked); } }), label: (0, jsx_runtime_1.jsxs)("span", { children: ["J'accepte les", ' ', (0, jsx_runtime_1.jsx)(material_1.Link, __assign({ href: "/terms-and-conditions", target: "_blank" }, { children: "Conditions G\u00E9n\u00E9rales d'Utilisation" }))] }) }), (0, jsx_runtime_1.jsx)(material_1.FormHelperText, { children: userForm.acceptsTerms.error })] })), alertMessage && alertSeverity && (0, jsx_runtime_1.jsx)(material_1.Alert, __assign({ severity: alertSeverity, sx: { mb: 2 } }, { children: alertMessage })), (0, jsx_runtime_1.jsx)(lab_1.LoadingButton, __assign({ loading: loading, type: "submit", fullWidth: true, variant: "contained", sx: { mt: 3, mb: 2 } }, { children: (0, jsx_runtime_1.jsx)("span", { children: "Cr\u00E9er mon compte" }) }))] })), (0, jsx_runtime_1.jsx)(MovaCopyright_1.default, { sx: { mt: 8, mb: 4 } })] })), (0, jsx_runtime_1.jsx)("img", { src: leaf_pink_large_png_1.default, style: { position: 'fixed',
164
+ }, 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({ href: "/login", variant: "body2", color: "text.secondary" }, { 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',
161
165
  float: 'right',
162
166
  width: '250px',
163
167
  height: '400px',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@movalib/movalib-commons",
3
- "version": "1.0.19",
3
+ "version": "1.0.21",
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",
@@ -8,7 +8,7 @@
8
8
  "scripts": {
9
9
  "start": "webpack-dev-server --entry ./devIndex.tsx --open",
10
10
  "build": "rm -rf dist && tsc && npm run copy-assets",
11
- "copy-assets": "cp -r src/assets/ dist/assets/",
11
+ "copy-assets": "cp -r src/assets/ dist/src/assets/",
12
12
  "test": "echo \"Error: no test specified\" && exit 1",
13
13
  "clean": "rm -rf dist node_modules package-lock.json"
14
14
  },
package/src/MovaLogin.tsx CHANGED
@@ -40,6 +40,11 @@ interface MovaLoginProps {
40
40
  loading?: boolean
41
41
  }
42
42
 
43
+ /**
44
+ * Formulaire d'authentification Movalib (Garage / Utilisateur)
45
+ * ATTENTION : la page attendue pour le bouton "Mot de passe oublié" doit pointer vers "/forgot-password"
46
+ * ATTENTION : la page attendue pour le bouton "Créer mon compte" doit pointer vers "/signup"
47
+ */
43
48
  const MovaLogin: FunctionComponent<MovaLoginProps> = ({ loading, movaAppType, onSubmit, alertMessage, alertSeverity }) => {
44
49
 
45
50
  const [form, setForm] = useState<MovaLoginForm>(initialFormState);
@@ -169,7 +174,7 @@ const MovaLogin: FunctionComponent<MovaLoginProps> = ({ loading, movaAppType, on
169
174
  </Grid>
170
175
  {movaAppType === MovaAppType.USER && <Grid item>
171
176
  <Link href="/signup" variant="body2" color="text.secondary">
172
- {"Créer un compte"}
177
+ {"Créer mon compte"}
173
178
  </Link>
174
179
  </Grid>}
175
180
  </Grid>
@@ -46,6 +46,10 @@ interface MovaSignUpProps {
46
46
  loading?: boolean
47
47
  }
48
48
 
49
+ /**
50
+ * Formulaire de création d'un compte Movalib (Garage / Utilisateur)
51
+ * ATTENTION : le lien de consultation des CGU doit pointer vers "/terms-and-conditions"
52
+ */
49
53
  const MovaLogin: FunctionComponent<MovaSignUpProps> = ({ loading, movaAppType, onSubmit, alertMessage, alertSeverity }) => {
50
54
 
51
55
  const [userForm, setUserForm] = useState<MovaUserSignUpForm>(initialUserFormState);
@@ -113,8 +117,8 @@ const MovaLogin: FunctionComponent<MovaSignUpProps> = ({ loading, movaAppType, o
113
117
 
114
118
  setUserForm(newForm);
115
119
 
116
- return newForm.firstname.isValid && newForm.lastname.isValid && newForm.email.isValid
117
- && newForm.password.isValid && newForm.gender.isValid && newForm.birthDate.isValid;
120
+ return newForm.firstname.isValid && newForm.lastname.isValid && newForm.email.isValid && newForm.password.isValid
121
+ && newForm.gender.isValid && newForm.birthDate.isValid && newForm.acceptsTerms.isValid;
118
122
  }
119
123
 
120
124
  const getMovaLogo = () => {
@@ -258,6 +262,14 @@ const MovaLogin: FunctionComponent<MovaSignUpProps> = ({ loading, movaAppType, o
258
262
  <span>Créer mon compte</span>
259
263
  </LoadingButton>
260
264
 
265
+ <Grid container>
266
+ <Grid item xs>
267
+ <Link href="/login" variant="body2" color="text.secondary">
268
+ Se connecter
269
+ </Link>
270
+ </Grid>
271
+ </Grid>
272
+
261
273
  </Box>
262
274
  <MovaCopyright sx={{ mt: 8, mb: 4 }} />
263
275
  </Container>