@ssplib/react-components 0.0.53 → 0.0.55

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.
@@ -3,9 +3,10 @@ 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, }: {
6
+ export declare function Table({ columns, fetchFunc, emptyMsg, dataPath, tableName, csv, columnSize, action, isPublic, filters, statusKeyName, csvExcludeKeys, csvCustomKeyNames, csvExcludeValidate, }: {
7
7
  columns: ColumnData[];
8
8
  tableName: string;
9
+ csvExcludeValidate?: (key: string, value: string | number) => boolean;
9
10
  csvCustomKeyNames?: {
10
11
  [key: string]: string;
11
12
  };
@@ -40,7 +40,7 @@ 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 = {}, }) {
43
+ }, dataPath = '', tableName, csv, columnSize, action, isPublic = false, filters, statusKeyName = '', csvExcludeKeys = [], csvCustomKeyNames = {}, csvExcludeValidate = (key, value) => false, }) {
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);
@@ -122,7 +122,7 @@ function Table({ columns, fetchFunc, emptyMsg = {
122
122
  return;
123
123
  let exists = false;
124
124
  dataStr.forEach((key) => {
125
- const status = ['P', 'C', 'R'];
125
+ const status = ['P', 'C', 'A', 'R'];
126
126
  if (status.includes(key)) {
127
127
  switch (key) {
128
128
  case 'P':
@@ -131,12 +131,12 @@ function Table({ columns, fetchFunc, emptyMsg = {
131
131
  }
132
132
  return;
133
133
  case 'C':
134
- if ('cadastrado'.includes(searchValue.toLowerCase())) {
134
+ if ('cancelado'.includes(searchValue.toLowerCase())) {
135
135
  exists = true;
136
136
  }
137
137
  return;
138
138
  case 'A':
139
- if ('aprovado'.includes(searchValue.toLowerCase())) {
139
+ if ('cadastrado'.includes(searchValue.toLowerCase())) {
140
140
  exists = true;
141
141
  }
142
142
  return;
@@ -169,10 +169,16 @@ function Table({ columns, fetchFunc, emptyMsg = {
169
169
  return;
170
170
  const keys = Object.keys(list[0]).filter((k) => !csvExcludeKeys.includes(k));
171
171
  const header = keys.map((k) => (csvCustomKeyNames[k] ? csvCustomKeyNames[k] : k)).join(',') + '\n';
172
- const values = list
173
- .map((x) => {
174
- return keys
172
+ const values = [];
173
+ list.forEach((x) => {
174
+ let include = true;
175
+ const value = keys
175
176
  .map((k) => {
177
+ //verificar se pode incluir
178
+ if (csvExcludeValidate(k, x[k])) {
179
+ include = false;
180
+ return;
181
+ }
176
182
  if (k === 'tbRa')
177
183
  return x[k]['NO_CIDADE'];
178
184
  if (k === 'rlEventoData')
@@ -182,9 +188,10 @@ function Table({ columns, fetchFunc, emptyMsg = {
182
188
  return x[k];
183
189
  })
184
190
  .join(',');
185
- })
186
- .join('\n');
187
- const csvData = header + values;
191
+ if (include)
192
+ values.push(value);
193
+ });
194
+ const csvData = header + values.join('\n');
188
195
  // download
189
196
  const a = document.createElement('a');
190
197
  a.href = 'data:text/csv;charset=utf-8,' + csvData;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ssplib/react-components",
3
- "version": "0.0.53",
3
+ "version": "0.0.55",
4
4
  "description": "SSP React Components",
5
5
  "main": "index.js",
6
6
  "author": "Pedro Henrique <sr.hudrick@gmail.com>",