@ssplib/react-components 0.0.111 → 0.0.113

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.
@@ -65,11 +65,14 @@ function FileUpload({ name, tipoArquivo, title, required = false, multiple = fal
65
65
  headers: {
66
66
  Authorization: `Bearer ${user ? user.token : ''}`,
67
67
  },
68
- }).then((res) => {
68
+ })
69
+ .then((res) => {
69
70
  if (!res.ok)
70
71
  setFilesError((fl) => [...fl, id]);
71
72
  res.json().then((j) => {
72
- if (j.status.status === 200) {
73
+ if (!j.status)
74
+ setFilesError((fl) => [...fl, id]);
75
+ if (j.status && j.status.status === 200) {
73
76
  const fileIdFromApi = j.data[0];
74
77
  const fileId = fileIdFromApi['coSeqArquivo'];
75
78
  context.setFilesUid((fId) => [
@@ -88,7 +91,8 @@ function FileUpload({ name, tipoArquivo, title, required = false, multiple = fal
88
91
  setFilesError((fl) => [...fl, id]);
89
92
  }
90
93
  });
91
- });
94
+ })
95
+ .catch((err) => console.log(err));
92
96
  return { id: id, name: file.name, loading: true, error: false, file: file };
93
97
  }),
94
98
  ]);
@@ -105,12 +109,14 @@ function FileUpload({ name, tipoArquivo, title, required = false, multiple = fal
105
109
  headers: {
106
110
  Authorization: `Bearer ${user === null || user === void 0 ? void 0 : user.token}`,
107
111
  },
108
- }).then((res) => {
112
+ })
113
+ .then((res) => {
109
114
  if (res.status === 200) {
110
115
  setFiles(files.filter((x) => x.id !== id));
111
116
  context.setFilesUid((fId) => fId.filter((idd) => idd.CO_SEQ_ARQUIVO !== id));
112
117
  }
113
- });
118
+ })
119
+ .catch((err) => console.log(err));
114
120
  }
115
121
  };
116
122
  (0, react_1.useEffect)(() => {
@@ -132,12 +138,14 @@ function FileUpload({ name, tipoArquivo, title, required = false, multiple = fal
132
138
  react_1.default.createElement(material_1.Box, { sx: { backgroundColor: '#e2eafc', padding: 1, borderRadius: 1, marginTop: 1 } },
133
139
  react_1.default.createElement("input", Object.assign({ id: name, type: 'file', multiple: multiple }, context === null || context === void 0 ? void 0 : context.formRegister(name, {
134
140
  validate: (v, f) => {
141
+ console.log('v: ', v.length, 'filesupload: ', filesLoaded.length);
135
142
  if (filesLoaded.length <= 0 && required)
136
143
  return 'O campo de arquivo é obrigatório';
137
144
  },
138
145
  }), { onChange: onFile, accept: '.pdf', style: { display: 'none' } })),
139
146
  react_1.default.createElement("input", Object.assign({ id: name + 'foto', type: 'file', capture: 'environment', multiple: multiple }, context === null || context === void 0 ? void 0 : context.formRegister(name, {
140
147
  validate: (v, f) => {
148
+ console.log('v: ', v.length, 'filesupload: ', filesLoaded.length);
141
149
  if (filesLoaded.length <= 0 && required)
142
150
  return 'O campo de arquivo é obrigatório';
143
151
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ssplib/react-components",
3
- "version": "0.0.111",
3
+ "version": "0.0.113",
4
4
  "description": "SSP React Components",
5
5
  "main": "index.js",
6
6
  "author": "Pedro Henrique <sr.hudrick@gmail.com>",