@visns-studio/visns-components 1.7.7 → 1.8.2

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.
@@ -425,7 +425,12 @@ const DataGrid = forwardRef(
425
425
  onChange={handleChangeSearch}
426
426
  />
427
427
  </div>
428
- ) : null;
428
+ ) : (
429
+ <div
430
+ className="filterInput--alt"
431
+ style={{ height: "37px" }}
432
+ ></div>
433
+ );
429
434
  };
430
435
 
431
436
  const handleCoding = (c, data) => {
@@ -4,77 +4,85 @@ import { trackPromise } from "react-promise-tracker";
4
4
  import { toast } from "react-toastify";
5
5
  import parse from "html-react-parser";
6
6
 
7
- const CustomFetch = async (
8
- url,
9
- method,
10
- formData,
11
- successCallback = null,
12
- errorCallback = null
7
+ const CustomFetch = (
8
+ url,
9
+ method,
10
+ formData,
11
+ successCallback = null,
12
+ errorCallback = null
13
13
  ) => {
14
- const baseUrl = "";
15
- const headers = {
16
- "Content-Type": "application/json",
17
- };
14
+ const baseUrl = "";
15
+ const headers = {
16
+ "Content-Type": "application/json",
17
+ };
18
18
 
19
- if (method.toUpperCase() === "PUT" || method.toUpperCase() === "PATCH") {
20
- formData = {
21
- ...formData,
22
- _method: method,
23
- };
24
- }
19
+ if (method.toUpperCase() === "PUT" || method.toUpperCase() === "PATCH") {
20
+ formData = {
21
+ ...formData,
22
+ _method: method,
23
+ };
24
+ }
25
25
 
26
- const options = {
27
- method: method,
28
- data: formData,
29
- headers: headers,
30
- url: baseUrl + url,
31
- };
26
+ const options = {
27
+ method: method,
28
+ data: formData,
29
+ headers: headers,
30
+ url: baseUrl + url,
31
+ };
32
32
 
33
- try {
34
- const response = await trackPromise(axios(options));
33
+ return trackPromise(
34
+ new Promise((resolve, reject) => {
35
+ axios(options)
36
+ .then((response) => {
37
+ if (successCallback) {
38
+ successCallback(response.data);
39
+ } else {
40
+ const error = response.data.error;
35
41
 
36
- if (successCallback) {
37
- successCallback(response.data);
38
- } else {
39
- const error =
40
- response.data.error || "Data has been updated successfully.";
41
- toast.error(<div>{parse(error)}</div>);
42
- }
43
- } catch (error) {
44
- let errorMessage = "";
42
+ if (error && error !== "") {
43
+ toast.error(<div>{parse(error)}</div>);
44
+ }
45
+ }
46
+ resolve(response);
47
+ })
48
+ .catch((error) => {
49
+ let errorMessage = "";
45
50
 
46
- if (
47
- error.response &&
48
- error.response.data &&
49
- error.response.data.message
50
- ) {
51
- const { data } = error.response;
51
+ if (
52
+ error.response &&
53
+ error.response.data &&
54
+ error.response.data.message
55
+ ) {
56
+ const { data } = error.response;
52
57
 
53
- if (data.errors) {
54
- const { errors } = data;
58
+ if (data.errors) {
59
+ const { errors } = data;
55
60
 
56
- Object.values(errors).forEach((errorArray) => {
57
- errorArray.forEach((errorMsg) => {
58
- errorMessage += `${errorMsg}<br />`;
59
- });
60
- });
61
- } else {
62
- if (data.message === "CSRF token mismatch.") {
63
- window.location.replace("/login");
64
- } else {
65
- errorMessage = data.message;
66
- }
67
- }
68
- } else {
69
- errorMessage = error.message;
70
- }
61
+ Object.values(errors).forEach((errorArray) => {
62
+ errorArray.forEach((errorMsg) => {
63
+ errorMessage += `${errorMsg}<br />`;
64
+ });
65
+ });
66
+ } else {
67
+ if (data.message === "CSRF token mismatch.") {
68
+ window.location.replace("/login");
69
+ } else {
70
+ errorMessage = data.message;
71
+ }
72
+ }
73
+ } else {
74
+ errorMessage = error.message;
75
+ }
71
76
 
72
- if (errorCallback) {
73
- errorCallback(errorMessage);
74
- } else {
75
- toast.error(<div>{parse(errorMessage)}</div>);
76
- }
77
- }
77
+ if (errorCallback) {
78
+ errorCallback(errorMessage);
79
+ } else {
80
+ toast.error(<div>{parse(errorMessage)}</div>);
81
+ }
82
+ reject(error);
83
+ });
84
+ })
85
+ );
78
86
  };
79
87
 
80
88
  export default CustomFetch;