@movalib/movalib-commons 1.1.66 → 1.1.68

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
@@ -2,7 +2,7 @@ import React, { CSSProperties, Fragment, useEffect, useState } from 'react';
2
2
  import { createRoot } from 'react-dom/client';
3
3
  // Import des composants de la bibliothèque
4
4
  import MovaLogin from './src/MovaLogin';
5
- import { AddressFieldName, MovaLoginForm } from './src/helpers/Types';
5
+ import { AddressFieldName, MovaLoginForm, MovaUserSignUpForm } from './src/helpers/Types';
6
6
  import { MovaAppType } from './src/helpers/Enums';
7
7
  import { ThemeProvider, darken } from '@mui/material/styles';
8
8
  import theme from './theme'; // Import du thème personnalisé
@@ -118,10 +118,8 @@ const App = () => {
118
118
 
119
119
 
120
120
  <MovaLogin
121
- headerText={<><Alert severity='warning' icon={<></>} style={flexCenter} sx={{width:'100%', textTransform: 'none', textAlign: 'center'}}><b>INSCRIPTION GARAGE</b>
122
- <br /><Typography variant="body2" style={flexCenter} sx={{mt: 1}}>Connexion obligatoire</Typography></Alert></>}
123
121
  darkMode={false}
124
- movaAppType={MovaAppType.GARAGE}
122
+ movaAppType={MovaAppType.INDIVIDUAL}
125
123
  version="0.1.3"
126
124
  onSubmit={function (form: MovaLoginForm): void {
127
125
  alert('Form Submitted !');
@@ -133,7 +131,7 @@ const App = () => {
133
131
  headerText={<><Alert severity='success' icon={<></>} style={flexCenter} sx={{width:'100%', textTransform: 'none', textAlign: 'center'}}>
134
132
  <b>NOUVEAU COMPTE UTILISATEUR</b></Alert></>}
135
133
  darkMode={false}
136
- movaAppType={MovaAppType.INDIVIDUAL} onSubmit={function (form: MovaLoginForm): void {
134
+ movaAppType={MovaAppType.INDIVIDUAL} onSubmit={function (form: MovaUserSignUpForm): void {
137
135
  alert('Form Submitted !');
138
136
  } } />
139
137
 
package/dist/devIndex.js CHANGED
@@ -124,7 +124,7 @@ var App = function () {
124
124
  };
125
125
  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.jsxs)(material_1.Box, __assign({ sx: { mb: 4 } }, { children: [(0, jsx_runtime_1.jsx)(material_1.Container, __assign({ style: Tools_1.flexCenter, sx: { width: '400px', mt: 2 } }, { children: (0, jsx_runtime_1.jsx)(VehiclePlateField_1.default, { onValidVehiclePlate: function (vehiclePlate) {
126
126
  alert('plaque valide');
127
- } }) })), (0, jsx_runtime_1.jsx)(MovaLogin_1.default, { headerText: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsxs)(material_1.Alert, __assign({ severity: 'warning', icon: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {}), style: Tools_1.flexCenter, sx: { width: '100%', textTransform: 'none', textAlign: 'center' } }, { children: [(0, jsx_runtime_1.jsx)("b", { children: "INSCRIPTION GARAGE" }), (0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "body2", style: Tools_1.flexCenter, sx: { mt: 1 } }, { children: "Connexion obligatoire" }))] })) }), darkMode: false, movaAppType: Enums_1.MovaAppType.GARAGE, version: "0.1.3", onSubmit: function (form) {
127
+ } }) })), (0, jsx_runtime_1.jsx)(MovaLogin_1.default, { darkMode: false, movaAppType: Enums_1.MovaAppType.INDIVIDUAL, version: "0.1.3", onSubmit: function (form) {
128
128
  alert('Form Submitted !');
129
129
  }, onSubmitForgotPassword: function (email) {
130
130
  throw new Error('Function not implemented.');
@@ -78,6 +78,7 @@ var styles = {
78
78
  var initialFormState = {
79
79
  email: { value: '', isValid: true },
80
80
  password: { value: '', isValid: true },
81
+ phoneNumberEmail: { value: '', isValid: true }
81
82
  };
82
83
  /**
83
84
  * Formulaire d'authentification Movalib (Garage / Utilisateur)
@@ -117,14 +118,20 @@ var MovaLogin = function (_a) {
117
118
  var validateForm = function () {
118
119
  var newForm = __assign({}, form);
119
120
  // Validator pour les champs obligatoires
120
- newForm.email = (0, Tools_1.validateField)(form.email, function (value) { return !!value; }, 'Champ obligatoire');
121
+ if (movaAppType === Enums_1.MovaAppType.GARAGE) {
122
+ newForm.email = (0, Tools_1.validateField)(form.email, function (value) { return !!value; }, 'Champ obligatoire');
123
+ // Validator pour l'email
124
+ newForm.email = (0, Tools_1.validateField)(form.email, Validator_1.validateEmail, 'Adresse email invalide');
125
+ }
126
+ if (movaAppType === Enums_1.MovaAppType.INDIVIDUAL) {
127
+ newForm.phoneNumberEmail = (0, Tools_1.validateField)(form.phoneNumberEmail, function (value) { return !!value; }, 'Champ obligatoire');
128
+ }
121
129
  newForm.password = (0, Tools_1.validateField)(form.password, function (value) { return !!value; }, 'Champ obligatoire');
122
- // Validator pour l'email
123
- newForm.email = (0, Tools_1.validateField)(form.email, Validator_1.validateEmail, 'Adresse email invalide');
124
130
  // Validator pour le mot de passe
125
131
  newForm.password = (0, Tools_1.validateField)(form.password, function (value) { return value.length >= 10 && /[a-z]/.test(value) && /[A-Z]/.test(value); }, 'Mot de passe invalide');
126
132
  setForm(newForm);
127
- return newForm.email.isValid && newForm.password.isValid;
133
+ return newForm.password.isValid && (movaAppType === Enums_1.MovaAppType.GARAGE ? newForm.email.isValid : true)
134
+ && (movaAppType === Enums_1.MovaAppType.INDIVIDUAL ? newForm.phoneNumberEmail.isValid : true);
128
135
  };
129
136
  var getMovaLogo = function () {
130
137
  if (darkMode) {
@@ -179,11 +186,17 @@ var MovaLogin = function (_a) {
179
186
  display: 'flex',
180
187
  flexDirection: 'column',
181
188
  alignItems: 'center',
182
- } }, { children: [(0, jsx_runtime_1.jsx)("img", { src: getMovaLogo(), style: { width: '80%' } }), headerText && (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "button", sx: { pt: 3, width: '100%' } }, { children: headerText })), (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, sx: {
183
- '& .MuiOutlinedInput-notchedOutline': {
184
- borderColor: darkMode ? 'white' : 'default', // Couleur de la bordure
185
- }
186
- } }), (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: {
189
+ } }, { children: [(0, jsx_runtime_1.jsx)("img", { src: getMovaLogo(), style: { width: '80%' } }), headerText && (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "button", sx: { pt: 3, width: '100%' } }, { children: headerText })), (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: [movaAppType === Enums_1.MovaAppType.INDIVIDUAL &&
190
+ (0, jsx_runtime_1.jsx)(material_1.TextField, { margin: "normal", required: true, fullWidth: true, id: "phoneNumberEmail", label: "N\u00B0 de t\u00E9l\u00E9phone ou adresse email", name: "phoneNumberEmail", autoFocus: true, onChange: function (e) { return handleInputChange(e); }, value: form.phoneNumberEmail.value, error: !form.phoneNumberEmail.isValid, helperText: form.phoneNumberEmail.error, sx: {
191
+ '& .MuiOutlinedInput-notchedOutline': {
192
+ borderColor: darkMode ? 'white' : 'default', // Couleur de la bordure
193
+ }
194
+ } }), movaAppType === Enums_1.MovaAppType.GARAGE &&
195
+ (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, sx: {
196
+ '& .MuiOutlinedInput-notchedOutline': {
197
+ borderColor: darkMode ? 'white' : 'default', // Couleur de la bordure
198
+ }
199
+ } }), (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: {
187
200
  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, {}) })) }))),
188
201
  }, sx: {
189
202
  '& .MuiOutlinedInput-notchedOutline': {
@@ -237,7 +237,7 @@ var MovaLogin = function (_a) {
237
237
  }
238
238
  }, InputProps: {
239
239
  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: function () { return setOpenEmailInfo(!openEmailInfo); } }, { children: (0, jsx_runtime_1.jsx)(Info_1.default, {}) })) }))),
240
- } }), openEmailInfo && (0, jsx_runtime_1.jsx)(material_1.Alert, __assign({ severity: "info", variant: 'standard' }, { children: "Et si on arr\u00EAtait le papier ? En plus de pouvoir vous notifier, l'email vous permet de recevoir tous vos documents au format num\u00E9rique \uD83D\uDE0A\uD83C\uDF3F" })), (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: {
240
+ } }), openEmailInfo && (0, jsx_runtime_1.jsx)(material_1.Alert, __assign({ severity: "info", variant: 'standard' }, { children: "Et si on arr\u00EAtait le papier ? En plus de vous notifier, l'email vous permet de recevoir tous vos documents au format num\u00E9rique \uD83D\uDE0A\uD83C\uDF3F" })), (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: {
241
241
  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, {}) })) }))),
242
242
  }, sx: {
243
243
  '& .MuiOutlinedInput-notchedOutline': {
@@ -35,6 +35,7 @@ export type MovaUserSignUpForm = {
35
35
  export type MovaLoginForm = {
36
36
  email: MovaFormField;
37
37
  password: MovaFormField;
38
+ phoneNumberEmail: MovaFormField;
38
39
  };
39
40
  export type MovaFormField = {
40
41
  value?: any;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@movalib/movalib-commons",
3
- "version": "1.1.66",
3
+ "version": "1.1.68",
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",
package/src/MovaLogin.tsx CHANGED
@@ -29,6 +29,7 @@ const styles: CSSProperties = {
29
29
  const initialFormState = {
30
30
  email: { value: '', isValid: true },
31
31
  password: { value: '', isValid: true },
32
+ phoneNumberEmail: { value: '', isValid: true}
32
33
  };
33
34
 
34
35
  /**
@@ -91,12 +92,18 @@ const MovaLogin: FunctionComponent<MovaLoginProps> = ({ loading, movaAppType, on
91
92
  let newForm: MovaLoginForm = { ...form };
92
93
 
93
94
  // Validator pour les champs obligatoires
94
- newForm.email = validateField(form.email, value => !!value, 'Champ obligatoire');
95
- newForm.password = validateField(form.password, value => !!value, 'Champ obligatoire');
96
-
97
- // Validator pour l'email
98
- newForm.email = validateField(form.email, validateEmail, 'Adresse email invalide');
95
+ if(movaAppType === MovaAppType.GARAGE){
96
+ newForm.email = validateField(form.email, value => !!value, 'Champ obligatoire');
97
+ // Validator pour l'email
98
+ newForm.email = validateField(form.email, validateEmail, 'Adresse email invalide');
99
+ }
99
100
 
101
+ if(movaAppType === MovaAppType.INDIVIDUAL){
102
+ newForm.phoneNumberEmail = validateField(form.phoneNumberEmail, value => !!value, 'Champ obligatoire');
103
+ }
104
+
105
+ newForm.password = validateField(form.password, value => !!value, 'Champ obligatoire');
106
+
100
107
  // Validator pour le mot de passe
101
108
  newForm.password = validateField(form.password,
102
109
  value => value.length >= 10 && /[a-z]/.test(value) && /[A-Z]/.test(value),
@@ -104,7 +111,8 @@ const MovaLogin: FunctionComponent<MovaLoginProps> = ({ loading, movaAppType, on
104
111
 
105
112
  setForm(newForm);
106
113
 
107
- return newForm.email.isValid && newForm.password.isValid;
114
+ return newForm.password.isValid && (movaAppType === MovaAppType.GARAGE ? newForm.email.isValid : true)
115
+ && (movaAppType === MovaAppType.INDIVIDUAL ? newForm.phoneNumberEmail.isValid : true) ;
108
116
  }
109
117
 
110
118
  const getMovaLogo = () => {
@@ -220,25 +228,49 @@ const MovaLogin: FunctionComponent<MovaLoginProps> = ({ loading, movaAppType, on
220
228
  </Box>
221
229
 
222
230
  <Box component="form" onSubmit={handleSubmit} noValidate sx={{ mt: 1 }}>
223
- <TextField
224
- margin="normal"
225
- required
226
- fullWidth
227
- id="email"
228
- label="Adresse email"
229
- name="email"
230
- autoComplete="email"
231
- autoFocus
232
- onChange={e => handleInputChange(e)}
233
- value={form.email.value}
234
- error={!form.email.isValid}
235
- helperText={form.email.error}
236
- sx={{
237
- '& .MuiOutlinedInput-notchedOutline': {
238
- borderColor: darkMode ? 'white' : 'default', // Couleur de la bordure
239
- }
240
- }}
241
- />
231
+ {movaAppType === MovaAppType.INDIVIDUAL &&
232
+ <TextField
233
+ margin="normal"
234
+ required
235
+ fullWidth
236
+ id="phoneNumberEmail"
237
+ label="N° de téléphone ou adresse email"
238
+ name="phoneNumberEmail"
239
+ autoFocus
240
+ onChange={e => handleInputChange(e)}
241
+ value={form.phoneNumberEmail.value}
242
+ error={!form.phoneNumberEmail.isValid}
243
+ helperText={form.phoneNumberEmail.error}
244
+ sx={{
245
+ '& .MuiOutlinedInput-notchedOutline': {
246
+ borderColor: darkMode ? 'white' : 'default', // Couleur de la bordure
247
+ }
248
+ }}
249
+ />
250
+ }
251
+
252
+ {movaAppType === MovaAppType.GARAGE &&
253
+ <TextField
254
+ margin="normal"
255
+ required
256
+ fullWidth
257
+ id="email"
258
+ label="Adresse email"
259
+ name="email"
260
+ autoComplete="email"
261
+ autoFocus
262
+ onChange={e => handleInputChange(e)}
263
+ value={form.email.value}
264
+ error={!form.email.isValid}
265
+ helperText={form.email.error}
266
+ sx={{
267
+ '& .MuiOutlinedInput-notchedOutline': {
268
+ borderColor: darkMode ? 'white' : 'default', // Couleur de la bordure
269
+ }
270
+ }}
271
+ />
272
+ }
273
+
242
274
  <TextField
243
275
  margin="normal"
244
276
  required
@@ -316,7 +316,7 @@ const MovaLogin: FunctionComponent<MovaSignUpProps> = ({ loading, movaAppType, o
316
316
  </InputAdornment>
317
317
  ),
318
318
  }}
319
- />{openEmailInfo && <Alert severity="info" variant='standard'>Et si on arrêtait le papier ? En plus de pouvoir vous notifier, l'email vous permet de recevoir tous vos documents au format numérique 😊🌿</Alert>}
319
+ />{openEmailInfo && <Alert severity="info" variant='standard'>Et si on arrêtait le papier ? En plus de vous notifier, l'email vous permet de recevoir tous vos documents au format numérique 😊🌿</Alert>}
320
320
  <TextField
321
321
  margin="normal"
322
322
  required
@@ -40,7 +40,8 @@ export type MovaUserSignUpForm = {
40
40
 
41
41
  export type MovaLoginForm = {
42
42
  email: MovaFormField,
43
- password: MovaFormField
43
+ password: MovaFormField,
44
+ phoneNumberEmail: MovaFormField
44
45
  }
45
46
 
46
47
  export type MovaFormField = {