@visns-studio/visns-components 1.0.5 → 1.0.6

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/index.js CHANGED
@@ -1,7 +1,6 @@
1
1
  /** CMS Components */
2
2
  import CmsForm from "./components/cms/visns-form";
3
3
  import DataGrid from "./components/cms/visns-data-grid";
4
- import Download from "./components/cms/visns-download";
5
4
  import DropZone from "./components/cms/visns-dropzone";
6
5
  import SortableList from "./components/cms/sorting/list";
7
6
 
package/package.json CHANGED
@@ -30,7 +30,7 @@
30
30
  "react-dom": ">=18.2.0"
31
31
  },
32
32
  "name": "@visns-studio/visns-components",
33
- "version": "1.0.5",
33
+ "version": "1.0.6",
34
34
  "description": "Various packages to assist in the development of our Custom Applications.",
35
35
  "main": "index.js",
36
36
  "devDependencies": {},
@@ -1,102 +0,0 @@
1
- import _ from 'lodash';
2
- import axios from 'axios';
3
- import { trackPromise } from 'react-promise-tracker';
4
-
5
- const CustomDownload = (
6
- url,
7
- method,
8
- formData,
9
- successCallback,
10
- errorCallback
11
- ) => {
12
- let baseUrl = '';
13
- let fileUpload = false;
14
- let body;
15
- let headers = {};
16
- let options = {};
17
-
18
- if (!_.isEmpty(formData)) {
19
- Object.keys(formData).forEach((item) => {
20
- if (formData[item] !== undefined) {
21
- if (formData[item] instanceof File && formData[item] !== null) {
22
- fileUpload = true;
23
- }
24
- }
25
- });
26
- }
27
-
28
- if (method.toUpperCase() === 'PUT' || method.toUpperCase() === 'PATCH') {
29
- if (fileUpload === false) {
30
- body = {
31
- ...body,
32
- _method: method,
33
- };
34
- }
35
- }
36
-
37
- if (fileUpload === false) {
38
- body = JSON.stringify(formData);
39
- headers = {
40
- ...headers,
41
- 'Content-Type': 'application/json',
42
- };
43
- } else {
44
- body = new FormData();
45
-
46
- headers = {
47
- ...headers,
48
- 'Content-Type': 'multipart/form-data',
49
- contentType: false,
50
- processData: false,
51
- };
52
-
53
- if (!_.isEmpty(formData)) {
54
- Object.keys(formData).forEach((item) => {
55
- body.append(item, formData[item]);
56
- });
57
- }
58
-
59
- if (
60
- method.toUpperCase() === 'PUT' ||
61
- method.toUpperCase() === 'PATCH'
62
- ) {
63
- if (fileUpload === false) {
64
- } else {
65
- body.append('_method', method);
66
- method = 'POST';
67
- }
68
- }
69
- }
70
-
71
- options = {
72
- method: method,
73
- data: body,
74
- headers: headers,
75
- url: baseUrl + url,
76
- responseType: 'blob',
77
- };
78
-
79
- trackPromise(
80
- axios(options).then(
81
- (result) => {
82
- successCallback(result.data);
83
- },
84
- (error) => {
85
- if (
86
- error.response.hasOwnProperty('data') &&
87
- error.response.data.hasOwnProperty('message') &&
88
- error.response.data.message !== ''
89
- ) {
90
- if (error.response.data.message === 'Unauthenticated.') {
91
- localStorage.clear();
92
- }
93
- errorCallback(error.response.data.message);
94
- } else {
95
- errorCallback(error);
96
- }
97
- }
98
- )
99
- );
100
- };
101
-
102
- export default CustomDownload;