@visns-studio/visns-components 4.8.12 → 4.8.13
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.
package/package.json
CHANGED
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"react-dom": "^17.0.0 || ^18.0.0"
|
|
76
76
|
},
|
|
77
77
|
"name": "@visns-studio/visns-components",
|
|
78
|
-
"version": "4.8.
|
|
78
|
+
"version": "4.8.13",
|
|
79
79
|
"description": "Various packages to assist in the development of our Custom Applications.",
|
|
80
80
|
"main": "src/index.js",
|
|
81
81
|
"files": [
|
|
@@ -32,6 +32,7 @@ function useConfig(setting, tabs, filters, setRowsSelected, tableSetting) {
|
|
|
32
32
|
|
|
33
33
|
useEffect(() => {
|
|
34
34
|
setConfig({
|
|
35
|
+
export: setting.export || {},
|
|
35
36
|
ajaxSetting: setting.ajaxSetting,
|
|
36
37
|
form: setting.form,
|
|
37
38
|
columns: setting.columns,
|
|
@@ -216,6 +217,37 @@ function GenericIndex({
|
|
|
216
217
|
}
|
|
217
218
|
}, [rowsSelected, setting?.functions?.checkboxUpdate]);
|
|
218
219
|
|
|
220
|
+
const handleExport = async (e) => {
|
|
221
|
+
try {
|
|
222
|
+
if (e) {
|
|
223
|
+
e.preventDefault();
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
console.info(config, setting);
|
|
227
|
+
|
|
228
|
+
const res = await Download(
|
|
229
|
+
config.export.url,
|
|
230
|
+
config.export.method,
|
|
231
|
+
{}
|
|
232
|
+
);
|
|
233
|
+
|
|
234
|
+
if (res.data.error) {
|
|
235
|
+
toast.error(res.data.error);
|
|
236
|
+
} else {
|
|
237
|
+
// Assuming the response contains a Blob or similar data
|
|
238
|
+
if (res.data && res.data instanceof Blob) {
|
|
239
|
+
const fileName = `${config.export.filename}`;
|
|
240
|
+
saveAs(res.data, fileName);
|
|
241
|
+
} else {
|
|
242
|
+
// Handle the case where the response is not a Blob
|
|
243
|
+
toast.error('Invalid file format received.');
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
} catch (err) {
|
|
247
|
+
console.error(err);
|
|
248
|
+
}
|
|
249
|
+
};
|
|
250
|
+
|
|
219
251
|
const renderTable = useCallback(() => {
|
|
220
252
|
const isConfigValid = (config) => {
|
|
221
253
|
return (
|
|
@@ -387,6 +419,14 @@ function GenericIndex({
|
|
|
387
419
|
</button>
|
|
388
420
|
</div>
|
|
389
421
|
)}
|
|
422
|
+
|
|
423
|
+
{setting.export?.label && (
|
|
424
|
+
<div className={styles.polActions}>
|
|
425
|
+
<button className={styles.btn} onClick={handleExport}>
|
|
426
|
+
{setting.export.label}
|
|
427
|
+
</button>
|
|
428
|
+
</div>
|
|
429
|
+
)}
|
|
390
430
|
</>
|
|
391
431
|
);
|
|
392
432
|
}
|