@ssplib/react-components 0.0.109 → 0.0.111
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.
|
@@ -132,15 +132,13 @@ function FileUpload({ name, tipoArquivo, title, required = false, multiple = fal
|
|
|
132
132
|
react_1.default.createElement(material_1.Box, { sx: { backgroundColor: '#e2eafc', padding: 1, borderRadius: 1, marginTop: 1 } },
|
|
133
133
|
react_1.default.createElement("input", Object.assign({ id: name, type: 'file', multiple: multiple }, context === null || context === void 0 ? void 0 : context.formRegister(name, {
|
|
134
134
|
validate: (v, f) => {
|
|
135
|
-
|
|
136
|
-
if (v.length <= 0 && required)
|
|
135
|
+
if (filesLoaded.length <= 0 && required)
|
|
137
136
|
return 'O campo de arquivo é obrigatório';
|
|
138
137
|
},
|
|
139
138
|
}), { onChange: onFile, accept: '.pdf', style: { display: 'none' } })),
|
|
140
139
|
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
140
|
validate: (v, f) => {
|
|
142
|
-
|
|
143
|
-
if (v.length <= 0 && required)
|
|
141
|
+
if (filesLoaded.length <= 0 && required)
|
|
144
142
|
return 'O campo de arquivo é obrigatório';
|
|
145
143
|
},
|
|
146
144
|
}), { 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(
|
|
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);
|
|
@@ -76,7 +76,7 @@ function LoginProvider({ children, AUTH_URL, redirectURL = '/', validateTokenRou
|
|
|
76
76
|
setLoading(true);
|
|
77
77
|
fetch(loginURL, {
|
|
78
78
|
method: 'POST',
|
|
79
|
-
body: JSON.stringify(Object.assign(Object.assign({}, data), { cpf: data.cpf.replaceAll(/[.-]/g, ''), captchaToken })),
|
|
79
|
+
body: JSON.stringify(Object.assign(Object.assign({}, data), { cpf: data.cpf.replaceAll(/[.-]/g, ''), captchaToken: captchaToken ? captchaToken : 'hmg' })),
|
|
80
80
|
headers: {
|
|
81
81
|
'Content-Type': 'application/json',
|
|
82
82
|
},
|