argous 1.2.235 → 1.2.236

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.
@@ -112,6 +112,7 @@ var ContactValidationInput = function (_a) {
112
112
  var inputValue = state.inputValue, loading = state.loading, searched = state.searched, validated = state.validated, idContato = state.idContato, cdContato = state.cdContato, code = state.code, message = state.message, validating = state.validating;
113
113
  var createModal = utils_1.useModal().createModal;
114
114
  var sealModal = createModal(SealModal_1.default);
115
+ var onChangeRef = react_1.useRef(onChange);
115
116
  var logicSetState = function (_a) {
116
117
  var type = _a.type, field = _a.field, value = _a.value;
117
118
  return setState(function (states) {
@@ -148,13 +149,13 @@ var ContactValidationInput = function (_a) {
148
149
  padding: 5,
149
150
  fontSize: 22
150
151
  };
151
- var handleOnChange = function (event) {
152
+ var handleOnChange = react_1.useCallback(function (event) {
152
153
  event.target.value = event.target.value.toString().toLowerCase();
153
154
  logicSetState({ type: 'inputValue', value: event.target.value });
154
- (typeof onChange === 'function') && onChange(event);
155
- };
155
+ (typeof onChangeRef.current === 'function') && onChangeRef.current(event);
156
+ }, []);
156
157
  var search = react_1.useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
157
- var parameters, fetchOptions, _a, status, cdContato, isVerificado;
158
+ var parameters, fetchOptions, _a, status, cdContato, isVerificado, newInputValue_1, newEvent;
158
159
  return __generator(this, function (_b) {
159
160
  switch (_b.label) {
160
161
  case 0:
@@ -180,13 +181,17 @@ var ContactValidationInput = function (_a) {
180
181
  case 1:
181
182
  _a = _b.sent(), status = _a.status, cdContato = _a.cdContato, isVerificado = _a.isVerificado;
182
183
  if (status) {
183
- setState(function (states) { return (__assign(__assign({}, states), { cdContato: cdContato, inputValue: (cdContato || ''), searched: true, validated: isVerificado })); });
184
+ newInputValue_1 = (cdContato || '');
185
+ setState(function (states) { return (__assign(__assign({}, states), { cdContato: cdContato, inputValue: newInputValue_1, searched: true, validated: isVerificado })); });
186
+ newEvent = new Event('search');
187
+ Object.defineProperty(newEvent, 'target', { writable: false, value: { value: newInputValue_1 } });
188
+ handleOnChange(newEvent);
184
189
  }
185
190
  logicSetState({ type: 'loading', field: 'input', value: false });
186
191
  return [2 /*return*/];
187
192
  }
188
193
  });
189
- }); }, [cellphoneType, emailType, invalidType, cpf]);
194
+ }); }, [cellphoneType, emailType, invalidType, cpf, handleOnChange]);
190
195
  react_1.useEffect(function () {
191
196
  search();
192
197
  }, [search]);
@@ -5,7 +5,7 @@ import { api, headers } from '../../api';
5
5
  import { numbersOnly, useModal } from '../../utils';
6
6
  import { setError } from '../../utils/api';
7
7
  import { Button, CircularProgress, Grid, IconButton, InputAdornment, TextField, Typography, useTheme } from '@material-ui/core';
8
- import React, { useCallback, useEffect, useState } from 'react';
8
+ import React, { useCallback, useEffect, useRef, useState } from 'react';
9
9
  import { IoMdCheckmark } from 'react-icons/io';
10
10
  import { LiaExclamationTriangleSolid } from 'react-icons/lia';
11
11
  import { PiSealCheck } from 'react-icons/pi';
@@ -64,6 +64,7 @@ const ContactValidationInput = ({
64
64
  const { inputValue, loading, searched, validated, idContato, cdContato, code, message, validating } = state;
65
65
  const { createModal } = useModal();
66
66
  const sealModal = createModal(SealModal);
67
+ const onChangeRef = useRef(onChange);
67
68
 
68
69
  const logicSetState = ({ type, field, value }) => setState((states) => ({
69
70
  ...states,
@@ -108,11 +109,11 @@ const ContactValidationInput = ({
108
109
  };
109
110
 
110
111
 
111
- const handleOnChange = (event) => {
112
+ const handleOnChange = useCallback((event) => {
112
113
  event.target.value = event.target.value.toString().toLowerCase();
113
114
  logicSetState({ type: 'inputValue', value: event.target.value });
114
- (typeof onChange === 'function') && onChange(event);
115
- };
115
+ (typeof onChangeRef.current === 'function') && onChangeRef.current(event);
116
+ }, []);
116
117
 
117
118
  const search = useCallback(async () => {
118
119
  if (invalidType) return;
@@ -133,17 +134,23 @@ const ContactValidationInput = ({
133
134
 
134
135
  const { status, cdContato, isVerificado } = await fetch(`${api()}agscontactconfirmation.rslvr`, fetchOptions).then(async (response) => await response.json());
135
136
  if (status) {
137
+ const newInputValue = (cdContato || '');
138
+
136
139
  setState((states) => ({
137
140
  ...states,
138
141
  cdContato,
139
- inputValue: (cdContato || ''),
142
+ inputValue: newInputValue,
140
143
  searched: true,
141
144
  validated: isVerificado
142
145
  }));
146
+
147
+ let newEvent = new Event('search');
148
+ Object.defineProperty(newEvent, 'target', { writable: false, value: { value: newInputValue } });
149
+ handleOnChange(newEvent);
143
150
  }
144
151
 
145
152
  logicSetState({ type: 'loading', field: 'input', value: false });
146
- }, [cellphoneType, emailType, invalidType, cpf]);
153
+ }, [cellphoneType, emailType, invalidType, cpf, handleOnChange]);
147
154
 
148
155
  useEffect(() => {
149
156
  search();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "argous",
3
- "version": "1.2.235",
3
+ "version": "1.2.236",
4
4
  "description": "Argous.",
5
5
  "main": "lib/index.js",
6
6
  "author": "Carlos Schneider",