@movalib/movalib-commons 1.1.63 → 1.1.65

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.
@@ -30,6 +30,7 @@ var MovaDialog_1 = __importDefault(require("./MovaDialog"));
30
30
  var logo_large_png_1 = __importDefault(require("./assets/images/logo/logo_large.png"));
31
31
  var logo_pro_large_png_1 = __importDefault(require("./assets/images/logo/logo_pro_large.png"));
32
32
  var ConfirmationDialog_1 = __importDefault(require("./ConfirmationDialog"));
33
+ var Validator_1 = require("./helpers/Validator");
33
34
  var initialFormState = {
34
35
  password: { value: '', isValid: true },
35
36
  confirmation: { value: '', isValid: true },
@@ -93,6 +94,10 @@ var AccountValidation = function (_a) {
93
94
  var fieldName = e.target.name;
94
95
  var fieldValue = e.target.value;
95
96
  var newField = (_a = {}, _a[fieldName] = { value: fieldValue, isValid: true }, _a);
97
+ if (fieldName == "phoneNumber") {
98
+ if (!(0, Validator_1.validatePhoneNumber)(fieldValue))
99
+ return;
100
+ }
96
101
  setValidationForm(__assign(__assign({}, validationForm), newField));
97
102
  }
98
103
  };
@@ -141,10 +146,11 @@ var AccountValidation = function (_a) {
141
146
  var handleOpenResendCode = function () {
142
147
  setOpenPhoneNumberInput(true);
143
148
  };
144
- var validatePhoneNumber = function () {
149
+ var controlPhoneNumber = function () {
145
150
  var _a, _b, _c, _d, _e;
146
151
  var newForm = validationForm;
147
152
  var newField;
153
+ newForm.phoneNumber = (0, Tools_1.validateField)(validationForm.phoneNumber, function (value) { return !!value; }, 'Champ obligatoire');
148
154
  // Validator 'phoneNumber'
149
155
  if ((_a = newForm.phoneNumber) === null || _a === void 0 ? void 0 : _a.value) {
150
156
  if (((_b = newForm.phoneNumber) === null || _b === void 0 ? void 0 : _b.value.length) < 10) {
@@ -160,7 +166,7 @@ var AccountValidation = function (_a) {
160
166
  };
161
167
  var resendCode = function () {
162
168
  var _a;
163
- if (validatePhoneNumber()) {
169
+ if (controlPhoneNumber()) {
164
170
  var req = {
165
171
  phoneNumber: (_a = validationForm.phoneNumber) === null || _a === void 0 ? void 0 : _a.value
166
172
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@movalib/movalib-commons",
3
- "version": "1.1.63",
3
+ "version": "1.1.65",
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",
@@ -15,6 +15,7 @@ import MovaDialog from './MovaDialog';
15
15
  import LogoLarge from './assets/images/logo/logo_large.png';
16
16
  import LogoProLarge from './assets/images/logo/logo_pro_large.png';
17
17
  import ConfirmationDialog from './ConfirmationDialog';
18
+ import { validatePhoneNumber } from './helpers/Validator';
18
19
 
19
20
  const initialFormState = {
20
21
  password: { value: '', isValid: true },
@@ -98,6 +99,11 @@ const AccountValidation: FunctionComponent<AccountValidationProps> = ({ movaAppT
98
99
  const fieldValue: string = e.target.value;
99
100
  const newField: MovaFormField = { [fieldName]: { value: fieldValue, isValid: true } };
100
101
 
102
+ if (fieldName == "phoneNumber"){
103
+ if(!validatePhoneNumber(fieldValue))
104
+ return;
105
+ }
106
+
101
107
  setValidationForm({ ...validationForm, ...newField});
102
108
  }
103
109
  }
@@ -165,29 +171,31 @@ const AccountValidation: FunctionComponent<AccountValidationProps> = ({ movaAppT
165
171
  setOpenPhoneNumberInput(true);
166
172
  }
167
173
 
168
- const validatePhoneNumber = ():boolean => {
174
+ const controlPhoneNumber = ():boolean => {
169
175
 
170
176
  let newForm: MovaValidationForm = validationForm;
171
177
  let newField: MovaFormField;
172
178
 
179
+ newForm.phoneNumber = validateField(validationForm.phoneNumber, value => !!value, 'Champ obligatoire');
180
+
173
181
  // Validator 'phoneNumber'
174
- if(newForm.phoneNumber?.value){
175
- if(newForm.phoneNumber?.value.length < 10){
176
- newField = { value: validationForm.phoneNumber?.value, error: "Le n° de téléphone est invalide."};
177
- } else {
178
- newField ={ value: validationForm.phoneNumber?.value, error: ''};
182
+ if(newForm.phoneNumber?.value){
183
+ if(newForm.phoneNumber?.value.length < 10){
184
+ newField = { value: validationForm.phoneNumber?.value, error: "Le n° de téléphone est invalide."};
185
+ } else {
186
+ newField ={ value: validationForm.phoneNumber?.value, error: ''};
187
+ }
188
+ newForm = { ...newForm, ...{ phoneNumber: newField } };
179
189
  }
180
- newForm = { ...newForm, ...{ phoneNumber: newField } };
181
- }
182
-
183
- setValidationForm(newForm);
190
+
191
+ setValidationForm(newForm);
184
192
 
185
- return !Boolean(newForm.phoneNumber?.error);
193
+ return !Boolean(newForm.phoneNumber?.error);
186
194
  }
187
195
 
188
196
  const resendCode = () => {
189
197
 
190
- if(validatePhoneNumber()){
198
+ if(controlPhoneNumber()){
191
199
 
192
200
  let req = {
193
201
  phoneNumber : validationForm.phoneNumber?.value