@ssplib/react-components 0.0.107 → 0.0.108

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.
@@ -47,18 +47,30 @@ function Table({ columns, fetchFunc, emptyMsg = {
47
47
  const { user, userLoaded } = (0, react_1.useContext)(auth_1.AuthContext);
48
48
  (0, react_1.useEffect)(() => {
49
49
  if (userLoaded || isPublic)
50
- fetchFunc().then((res) => res.json().then((j) => {
51
- if (j.statusCode === 204)
52
- setData({ body: { data: [] } });
53
- else if (j.statusCode === 403)
50
+ fetchFunc()
51
+ .then((res) => {
52
+ if (!res.ok)
54
53
  setError({
55
- status: j.statusCode,
54
+ status: 500,
56
55
  });
57
- else
58
- setData(j);
59
- console.log(j.statusCode);
60
- setIsLoading(false);
61
- }));
56
+ return res.json().then((j) => {
57
+ if (j.statusCode === 204)
58
+ setData({ body: { data: [] } });
59
+ else if (j.statusCode === 403)
60
+ setError({
61
+ status: j.statusCode,
62
+ });
63
+ else
64
+ setData(j);
65
+ console.log(j.statusCode);
66
+ setIsLoading(false);
67
+ });
68
+ })
69
+ .catch((err) => {
70
+ setError({
71
+ status: 500,
72
+ });
73
+ });
62
74
  }, [userLoaded]);
63
75
  const [list, setList] = (0, react_1.useState)([]);
64
76
  //numero de items pra ser mostrado
@@ -272,7 +284,9 @@ function Table({ columns, fetchFunc, emptyMsg = {
272
284
  }, [data]);
273
285
  if (error)
274
286
  return (react_1.default.createElement(material_1.Box, { bgcolor: '#E2E8F0', padding: 2, marginX: 2 },
275
- react_1.default.createElement(Typography_1.default, { fontSize: 24, textAlign: 'center', fontFamily: 'Inter' }, error.status === 403 && 'Acesso negado')));
287
+ react_1.default.createElement(Typography_1.default, { fontSize: 24, textAlign: 'center', fontFamily: 'Inter' },
288
+ error.status === 403 && 'Acesso negado',
289
+ error.status === 500 && (react_1.default.createElement(material_1.Box, { fontWeight: 500, textAlign: 'center' }, "Lamentavelmente, ocorreu um imprevisto em nosso servidor. Pedimos a sua compreens\u00E3o e solicitamos que aguarde por um momento enquanto verificamos a situa\u00E7\u00E3o.")))));
276
290
  if (isLoading)
277
291
  return (react_1.default.createElement(material_1.Stack, { sx: { height: '100%', width: '100%' }, justifyContent: 'center', alignItems: 'center' },
278
292
  react_1.default.createElement(Typography_1.default, { fontWeight: 600, fontSize: 20, paddingBottom: 2, marginTop: 14 },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ssplib/react-components",
3
- "version": "0.0.107",
3
+ "version": "0.0.108",
4
4
  "description": "SSP React Components",
5
5
  "main": "index.js",
6
6
  "author": "Pedro Henrique <sr.hudrick@gmail.com>",