@visns-studio/visns-components 4.10.7 → 4.10.8
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 +1 -1
- package/src/components/crm/DataGrid.jsx +69 -16
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.10.
|
|
78
|
+
"version": "4.10.8",
|
|
79
79
|
"description": "Various packages to assist in the development of our Custom Applications.",
|
|
80
80
|
"main": "src/index.js",
|
|
81
81
|
"files": [
|
|
@@ -60,6 +60,7 @@ import CustomFetch from './Fetch';
|
|
|
60
60
|
import Download from './Download';
|
|
61
61
|
import Form from './Form';
|
|
62
62
|
import _ from 'lodash';
|
|
63
|
+
import { distance2D } from 'framer-motion';
|
|
63
64
|
|
|
64
65
|
const loadData = async (
|
|
65
66
|
{ skip, limit, sortInfo, filterValue },
|
|
@@ -241,23 +242,65 @@ const DataGrid = forwardRef(
|
|
|
241
242
|
const toastId = toast.loading('Starting download please wait...');
|
|
242
243
|
|
|
243
244
|
try {
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
245
|
+
if (d.id && d.id > 0) {
|
|
246
|
+
const res = await Download(
|
|
247
|
+
`/ajax/files/download/${d.id}/null`,
|
|
248
|
+
'GET',
|
|
249
|
+
{}
|
|
250
|
+
);
|
|
249
251
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
+
if (res.data.error) {
|
|
253
|
+
toast.error(res.data.error);
|
|
254
|
+
} else {
|
|
255
|
+
// Assuming the response contains a Blob or similar data
|
|
256
|
+
if (res.data && res.data instanceof Blob) {
|
|
257
|
+
const fileName = `${d.file_name}`;
|
|
258
|
+
saveAs(res.data, fileName);
|
|
259
|
+
} else {
|
|
260
|
+
// Handle the case where the response is not a Blob
|
|
261
|
+
toast.error('Invalid file format received.');
|
|
262
|
+
}
|
|
263
|
+
}
|
|
252
264
|
} else {
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
265
|
+
toast.error(
|
|
266
|
+
'An issue with downloading the file has occurred.'
|
|
267
|
+
);
|
|
268
|
+
}
|
|
269
|
+
} catch (error) {
|
|
270
|
+
console.info(error);
|
|
271
|
+
} finally {
|
|
272
|
+
// Dismiss the loading toast in the finally block to ensure it's always dismissed
|
|
273
|
+
toast.dismiss(toastId);
|
|
274
|
+
}
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
const handleDownloadPath = async (file) => {
|
|
278
|
+
const toastId = toast.loading('Starting download please wait...');
|
|
279
|
+
|
|
280
|
+
try {
|
|
281
|
+
if (file.file_path && file.file_name && file.file_extension) {
|
|
282
|
+
const res = await Download(
|
|
283
|
+
`/ajax/files/downloadByPath`,
|
|
284
|
+
'POST',
|
|
285
|
+
{ ...file }
|
|
286
|
+
);
|
|
287
|
+
|
|
288
|
+
if (res.data.error) {
|
|
289
|
+
toast.error(res.data.error);
|
|
257
290
|
} else {
|
|
258
|
-
//
|
|
259
|
-
|
|
291
|
+
// Assuming the response contains a Blob or similar data
|
|
292
|
+
if (res.data && res.data instanceof Blob) {
|
|
293
|
+
const fileName = `${file.file_name}`;
|
|
294
|
+
saveAs(res.data, fileName);
|
|
295
|
+
} else {
|
|
296
|
+
// Handle the case where the response is not a Blob
|
|
297
|
+
toast.error('Invalid file format received.');
|
|
298
|
+
}
|
|
260
299
|
}
|
|
300
|
+
} else {
|
|
301
|
+
toast.error(
|
|
302
|
+
'An issue with downloading the file has occurred.'
|
|
303
|
+
);
|
|
261
304
|
}
|
|
262
305
|
} catch (error) {
|
|
263
306
|
console.info(error);
|
|
@@ -1733,9 +1776,19 @@ const DataGrid = forwardRef(
|
|
|
1733
1776
|
onClick={(e) => {
|
|
1734
1777
|
e.stopPropagation();
|
|
1735
1778
|
e.preventDefault();
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1779
|
+
|
|
1780
|
+
if (
|
|
1781
|
+
file.id &&
|
|
1782
|
+
file.id > 0
|
|
1783
|
+
) {
|
|
1784
|
+
handleDownload(
|
|
1785
|
+
file
|
|
1786
|
+
);
|
|
1787
|
+
} else {
|
|
1788
|
+
handleDownloadPath(
|
|
1789
|
+
file
|
|
1790
|
+
);
|
|
1791
|
+
}
|
|
1739
1792
|
}}
|
|
1740
1793
|
style={{
|
|
1741
1794
|
marginRight:
|