@ssplib/react-components 0.0.110 → 0.0.112

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,7 +65,8 @@ 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) => {
@@ -88,7 +89,8 @@ function FileUpload({ name, tipoArquivo, title, required = false, multiple = fal
88
89
  setFilesError((fl) => [...fl, id]);
89
90
  }
90
91
  });
91
- });
92
+ })
93
+ .catch((err) => console.log(err));
92
94
  return { id: id, name: file.name, loading: true, error: false, file: file };
93
95
  }),
94
96
  ]);
@@ -105,12 +107,14 @@ function FileUpload({ name, tipoArquivo, title, required = false, multiple = fal
105
107
  headers: {
106
108
  Authorization: `Bearer ${user === null || user === void 0 ? void 0 : user.token}`,
107
109
  },
108
- }).then((res) => {
110
+ })
111
+ .then((res) => {
109
112
  if (res.status === 200) {
110
113
  setFiles(files.filter((x) => x.id !== id));
111
114
  context.setFilesUid((fId) => fId.filter((idd) => idd.CO_SEQ_ARQUIVO !== id));
112
115
  }
113
- });
116
+ })
117
+ .catch((err) => console.log(err));
114
118
  }
115
119
  };
116
120
  (0, react_1.useEffect)(() => {
@@ -132,15 +136,15 @@ function FileUpload({ name, tipoArquivo, title, required = false, multiple = fal
132
136
  react_1.default.createElement(material_1.Box, { sx: { backgroundColor: '#e2eafc', padding: 1, borderRadius: 1, marginTop: 1 } },
133
137
  react_1.default.createElement("input", Object.assign({ id: name, type: 'file', multiple: multiple }, context === null || context === void 0 ? void 0 : context.formRegister(name, {
134
138
  validate: (v, f) => {
135
- console.log('dsadsadas 1');
136
- if (v.length <= 0 && required)
139
+ console.log('v: ', v.length, 'filesupload: ', filesLoaded.length);
140
+ if (filesLoaded.length <= 0 && required)
137
141
  return 'O campo de arquivo é obrigatório';
138
142
  },
139
143
  }), { onChange: onFile, accept: '.pdf', style: { display: 'none' } })),
140
144
  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, {
141
145
  validate: (v, f) => {
142
- console.log('dsadsadas 2');
143
- if (v.length <= 0 && required)
146
+ console.log('v: ', v.length, 'filesupload: ', filesLoaded.length);
147
+ if (filesLoaded.length <= 0 && required)
144
148
  return 'O campo de arquivo é obrigatório';
145
149
  },
146
150
  }), { onChange: onFile, accept: '.jpg, .png, .jpeg', style: { display: 'none' } })),
@@ -3,7 +3,7 @@ interface ColumnData {
3
3
  title: string;
4
4
  keyName: string;
5
5
  }
6
- export declare function Table({ columns, fetchFunc, emptyMsg, dataPath, tableName, csv, columnSize, action, isPublic, filters, statusKeyName, csvExcludeKeys, csvCustomKeyNames, csvExcludeValidate, csvButtonTitle, csvAllButtonTitle, csvShowAllButton, }: {
6
+ export declare function Table({ columns, fetchFunc, emptyMsg, dataPath, tableName, csv, columnSize, action, isPublic, filters, statusKeyName, csvExcludeKeys, csvCustomKeyNames, csvExcludeValidate, csvButtonTitle, csvAllButtonTitle, csvShowAllButton, itemCount, }: {
7
7
  columns: ColumnData[];
8
8
  tableName: string;
9
9
  csvShowAllButton?: boolean;
@@ -15,6 +15,7 @@ export declare function Table({ columns, fetchFunc, emptyMsg, dataPath, tableNam
15
15
  };
16
16
  csvExcludeKeys?: string[];
17
17
  statusKeyName?: string;
18
+ itemCount?: number;
18
19
  action: (prop: any) => JSX.Element;
19
20
  csv?: {
20
21
  fileName: string;
@@ -40,11 +40,20 @@ const auth_1 = require("../../../context/auth");
40
40
  function Table({ columns, fetchFunc, emptyMsg = {
41
41
  user: 'Nenhum dado encontrado',
42
42
  public: 'Nenhum dado encontrado',
43
- }, dataPath = '', tableName, csv, columnSize, action, isPublic = false, filters, statusKeyName = '', csvExcludeKeys = [], csvCustomKeyNames = {}, csvExcludeValidate = (key, value) => false, csvButtonTitle = 'Salvar .CSV', csvAllButtonTitle = 'Salvar Tudo como CSV', csvShowAllButton = false, }) {
43
+ }, dataPath = '', tableName, csv, columnSize, action, isPublic = false, filters, statusKeyName = '', csvExcludeKeys = [], csvCustomKeyNames = {}, csvExcludeValidate = (key, value) => false, csvButtonTitle = 'Salvar .CSV', csvAllButtonTitle = 'Salvar Tudo como CSV', csvShowAllButton = false, itemCount = 10, }) {
44
44
  const [isLoading, setIsLoading] = (0, react_1.useState)(true);
45
45
  const [error, setError] = (0, react_1.useState)(null);
46
46
  const [data, setData] = (0, react_1.useState)(null);
47
47
  const { user, userLoaded } = (0, react_1.useContext)(auth_1.AuthContext);
48
+ const [list, setList] = (0, react_1.useState)([]);
49
+ //numero de items pra ser mostrado
50
+ const [itemsCount, setItemsCount] = (0, react_1.useState)(itemCount);
51
+ const [currentPage, setCurrentPage] = (0, react_1.useState)(0);
52
+ const [paginationCount, setPagCount] = (0, react_1.useState)(1);
53
+ const [listPage, setListPage] = (0, react_1.useState)(1);
54
+ const [gridSize, setGridSize] = (0, react_1.useState)(12);
55
+ const theme = (0, material_1.useTheme)();
56
+ const isSmall = (0, material_1.useMediaQuery)(theme.breakpoints.only('xs'));
48
57
  (0, react_1.useEffect)(() => {
49
58
  if (userLoaded || isPublic)
50
59
  fetchFunc()
@@ -72,18 +81,9 @@ function Table({ columns, fetchFunc, emptyMsg = {
72
81
  });
73
82
  });
74
83
  }, [userLoaded]);
75
- const [list, setList] = (0, react_1.useState)([]);
76
- //numero de items pra ser mostrado
77
- const [itemsCount, setItemsCount] = (0, react_1.useState)(20);
78
- const [currentPage, setCurrentPage] = (0, react_1.useState)(0);
79
- const [paginationCount, setPagCount] = (0, react_1.useState)(1);
80
- const [listPage, setListPage] = (0, react_1.useState)(1);
81
- const [gridSize, setGridSize] = (0, react_1.useState)(12);
82
84
  (0, react_1.useEffect)(() => {
83
85
  setGridSize(12 / (columns.length + (user ? 1 : 0)));
84
86
  }, [user, columns]);
85
- const theme = (0, material_1.useTheme)();
86
- const isSmall = (0, material_1.useMediaQuery)(theme.breakpoints.only('xs'));
87
87
  const getCount = (0, react_1.useCallback)((countData) => {
88
88
  if (countData.length <= 0)
89
89
  return 1;
@@ -119,6 +119,7 @@ function Table({ columns, fetchFunc, emptyMsg = {
119
119
  const listData = getData(data);
120
120
  // setList([])
121
121
  // setListPage(1)
122
+ console.log(listData);
122
123
  const newList = [];
123
124
  listData.forEach((x) => {
124
125
  const dataStr = [];
@@ -134,7 +135,7 @@ function Table({ columns, fetchFunc, emptyMsg = {
134
135
  return;
135
136
  let exists = false;
136
137
  dataStr.forEach((key) => {
137
- const status = ['P', 'C', 'A', 'R'];
138
+ const status = ['P', 'C', 'A', 'R', 'L', 'PA'];
138
139
  if (status.includes(key)) {
139
140
  switch (key) {
140
141
  case 'P':
@@ -163,7 +164,7 @@ function Table({ columns, fetchFunc, emptyMsg = {
163
164
  }
164
165
  return;
165
166
  case 'PA':
166
- if ('pré aprovado'.includes(searchValue.toLowerCase())) {
167
+ if ('pré aprovado'.includes(searchValue.toLowerCase()) || 'pre aprovado'.includes(searchValue.toLowerCase())) {
167
168
  exists = true;
168
169
  }
169
170
  return;
@@ -179,6 +180,8 @@ function Table({ columns, fetchFunc, emptyMsg = {
179
180
  });
180
181
  setList(newList);
181
182
  setPagCount(getCount(newList));
183
+ setCurrentPage(0);
184
+ setListPage(1);
182
185
  }, [getCount, data]);
183
186
  const getMaxItems = (0, react_1.useCallback)(() => {
184
187
  const start = currentPage * itemsCount;
@@ -320,7 +323,12 @@ function Table({ columns, fetchFunc, emptyMsg = {
320
323
  csvShowAllButton && (react_1.default.createElement(material_1.Button, { startIcon: react_1.default.createElement(FileDownload_1.default, null), variant: 'contained', size: 'small', onClick: downloadCSVAll, sx: { backgroundColor: '#64748B', marginRight: { xs: 2, md: 0 }, width: { xs: '100%', md: 'fit-content' } } }, csvAllButtonTitle)),
321
324
  react_1.default.createElement(material_1.Button, { startIcon: react_1.default.createElement(FileDownload_1.default, null), variant: 'contained', size: 'small', onClick: downloadCSV, sx: { backgroundColor: '#22C55E', marginRight: { xs: 2, md: 0 }, width: { xs: '100%', md: 'fit-content' } } }, csvButtonTitle))),
322
325
  react_1.default.createElement(material_1.Stack, { direction: 'row', justifyContent: 'center', paddingY: 4 },
323
- react_1.default.createElement(Pagination_1.default, { count: paginationCount, siblingCount: isSmall ? 0 : 1, size: 'large', onChange: onPaginationChange, page: listPage })))))));
326
+ react_1.default.createElement(material_1.Stack, { direction: 'column', justifyContent: 'center', alignItems: 'center' },
327
+ react_1.default.createElement(Typography_1.default, { marginBottom: 2 },
328
+ getMaxItems().length < itemsCount ? getMaxItems().length : itemsCount,
329
+ " de ",
330
+ list.length),
331
+ react_1.default.createElement(Pagination_1.default, { count: paginationCount, siblingCount: isSmall ? 0 : 1, size: 'large', onChange: onPaginationChange, page: listPage }))))))));
324
332
  }
325
333
  exports.Table = Table;
326
334
  exports.default = react_1.default.memo(Table);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ssplib/react-components",
3
- "version": "0.0.110",
3
+ "version": "0.0.112",
4
4
  "description": "SSP React Components",
5
5
  "main": "index.js",
6
6
  "author": "Pedro Henrique <sr.hudrick@gmail.com>",