@ssplib/react-components 0.0.48 → 0.0.50
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.
|
@@ -56,7 +56,7 @@ function FileUpload({ name, tipoArquivo, title, required = false, multiple = fal
|
|
|
56
56
|
const fd = new FormData();
|
|
57
57
|
fd.append('files', file);
|
|
58
58
|
fd.append('tipoArquivo', tipoArquivo);
|
|
59
|
-
fetch(
|
|
59
|
+
fetch(apiURL, {
|
|
60
60
|
method: 'POST',
|
|
61
61
|
body: fd,
|
|
62
62
|
headers: {
|
|
@@ -3,9 +3,11 @@ 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, }: {
|
|
6
|
+
export declare function Table({ columns, fetchFunc, emptyMsg, dataPath, tableName, csv, columnSize, action, isPublic, filters, statusKeyName, csvExcludeKeys, }: {
|
|
7
7
|
columns: ColumnData[];
|
|
8
8
|
tableName: string;
|
|
9
|
+
csvExcludeKeys?: string[];
|
|
10
|
+
statusKeyName?: string;
|
|
9
11
|
action: (prop: any) => JSX.Element;
|
|
10
12
|
csv?: {
|
|
11
13
|
fileName: string;
|
|
@@ -27,7 +27,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.Table = void 0;
|
|
30
|
-
const Add_1 = __importDefault(require("@mui/icons-material/Add"));
|
|
31
30
|
const FileDownload_1 = __importDefault(require("@mui/icons-material/FileDownload"));
|
|
32
31
|
const Search_1 = __importDefault(require("@mui/icons-material/Search"));
|
|
33
32
|
const material_1 = require("@mui/material");
|
|
@@ -41,7 +40,7 @@ const auth_1 = require("../../../context/auth");
|
|
|
41
40
|
function Table({ columns, fetchFunc, emptyMsg = {
|
|
42
41
|
user: 'Nenhum dado encontrado',
|
|
43
42
|
public: 'Nenhum dado encontrado',
|
|
44
|
-
}, dataPath = '', tableName, csv, columnSize, action, isPublic = false, filters, }) {
|
|
43
|
+
}, dataPath = '', tableName, csv, columnSize, action, isPublic = false, filters, statusKeyName = '', csvExcludeKeys = [], }) {
|
|
45
44
|
const [isLoading, setIsLoading] = (0, react_1.useState)(true);
|
|
46
45
|
const [error, setError] = (0, react_1.useState)(null);
|
|
47
46
|
const [data, setData] = (0, react_1.useState)(null);
|
|
@@ -168,7 +167,7 @@ function Table({ columns, fetchFunc, emptyMsg = {
|
|
|
168
167
|
e.preventDefault();
|
|
169
168
|
if (list.length <= 0)
|
|
170
169
|
return;
|
|
171
|
-
const keys = Object.keys(list[0]);
|
|
170
|
+
const keys = Object.keys(list[0]).filter((k) => !csvExcludeKeys.includes(k));
|
|
172
171
|
const header = keys.join(',') + '\n';
|
|
173
172
|
const values = list
|
|
174
173
|
.map((x) => {
|
|
@@ -220,8 +219,6 @@ function Table({ columns, fetchFunc, emptyMsg = {
|
|
|
220
219
|
});
|
|
221
220
|
setList(newList);
|
|
222
221
|
setPagCount(getCount(newList));
|
|
223
|
-
console.log('minha lista:', listData);
|
|
224
|
-
console.log('selecionei:', newValue, 'minha chave:', key);
|
|
225
222
|
}, [data]);
|
|
226
223
|
if (error)
|
|
227
224
|
return (react_1.default.createElement(material_1.Box, { bgcolor: '#E2E8F0', padding: 2, marginX: 2 },
|
|
@@ -242,16 +239,13 @@ function Table({ columns, fetchFunc, emptyMsg = {
|
|
|
242
239
|
}, size: 'small', onChange: onInputChange, fullWidth: true, placeholder: `Pesquisar ${tableName}` }), filters === null || filters === void 0 ? void 0 :
|
|
243
240
|
filters.map((f) => (react_1.default.createElement(material_1.Autocomplete, { options: f.options.map((name) => name), onChange: (e, newValue) => onFilterSelect(f.key, newValue), renderInput: (args) => react_1.default.createElement(TextField_1.default, Object.assign({}, args, { label: f.name, size: 'small' })) })))),
|
|
244
241
|
react_1.default.createElement(material_1.Stack, { spacing: 0.2 }, getMaxItems().length <= 0 ? (react_1.default.createElement(material_1.Stack, { sx: { backgroundColor: '#E2E8F0', padding: 2, borderRadius: 2, marginX: { xs: 2, md: 0 } }, justifyContent: 'center', alignItems: 'center' },
|
|
245
|
-
react_1.default.createElement(Typography_1.default, { fontSize: 21, fontFamily: 'Inter', fontWeight: 600, textAlign: 'center' }, user ? emptyMsg.user : emptyMsg.public),
|
|
246
|
-
user && (react_1.default.createElement(material_1.Box, { sx: { '& a': { textDecoration: 'none' }, marginTop: 2 } },
|
|
247
|
-
react_1.default.createElement(material_1.Link, { href: '/cadastro' },
|
|
248
|
-
react_1.default.createElement(material_1.Button, { variant: 'contained', startIcon: react_1.default.createElement(Add_1.default, null), sx: { backgroundColor: '#64748B' } }, "Cadastrar")))))) : (getMaxItems().map((x, index) => (react_1.default.createElement(material_1.Paper, { key: index, sx: { padding: 0.5, borderRadius: 2, backgroundColor: index % 2 === 0 ? '#E2E8F0' : '#F8FAFC', paddingY: 2 }, elevation: 0 },
|
|
242
|
+
react_1.default.createElement(Typography_1.default, { fontSize: 21, fontFamily: 'Inter', fontWeight: 600, textAlign: 'center' }, user ? emptyMsg.user : emptyMsg.public))) : (getMaxItems().map((x, index) => (react_1.default.createElement(material_1.Paper, { key: index, sx: { padding: 0.5, borderRadius: 2, backgroundColor: index % 2 === 0 ? '#E2E8F0' : '#F8FAFC', paddingY: 2 }, elevation: 0 },
|
|
249
243
|
react_1.default.createElement(Grid_1.default, { container: true, spacing: isSmall ? 2 : 0, paddingX: 2 },
|
|
250
244
|
columns.map((c) => (react_1.default.createElement(Grid_1.default, { key: c.keyName + index, item: true, xs: 12, md: 12 / columnSize },
|
|
251
245
|
react_1.default.createElement(material_1.Box, { sx: { width: 'max-content', borderRadius: 1, paddingX: 1 } },
|
|
252
246
|
react_1.default.createElement(Typography_1.default, { fontSize: 16, fontWeight: 700, color: '#1E293B', fontFamily: 'Inter' }, c.title)),
|
|
253
247
|
react_1.default.createElement(material_1.Box, { paddingLeft: 1 },
|
|
254
|
-
react_1.default.createElement(Typography_1.default, { fontSize: 16, sx: { wordWrap: 'break-word', color: '#1E293B' }, fontFamily: 'Inter' }, c.keyName ===
|
|
248
|
+
react_1.default.createElement(Typography_1.default, { fontSize: 16, sx: { wordWrap: 'break-word', color: '#1E293B' }, fontFamily: 'Inter' }, c.keyName === statusKeyName ? getStatusMsg((0, lodash_get_1.default)(x, c.keyName)) : (0, lodash_get_1.default)(x, c.keyName)))))),
|
|
255
249
|
react_1.default.createElement(Grid_1.default, { item: true, xs: 12, md: 12 / columnSize },
|
|
256
250
|
react_1.default.createElement(material_1.Stack, { direction: 'row', alignItems: 'center', justifyContent: isSmall ? 'start' : 'flex-end', sx: { height: '100%', paddingBottom: isSmall ? 2 : 0 } }, action(x))))))))),
|
|
257
251
|
getMaxItems().length > 0 && (react_1.default.createElement(react_1.default.Fragment, null,
|