@visns-studio/visns-components 4.7.2 → 4.7.4
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 +15 -14
- package/src/components/cms/DataGrid.jsx +1461 -0
- package/src/components/cms/DropZone.jsx +349 -0
- package/src/components/cms/Field.jsx +802 -0
- package/src/components/cms/Form.jsx +476 -0
- package/src/components/cms/generic/CmsDetail.jsx +36 -0
- package/src/components/cms/generic/CmsIndex.jsx +73 -0
- package/src/components/cms/generic/CmsSort.jsx +125 -0
- package/src/components/cms/sorting/Item.jsx +115 -0
- package/src/components/cms/sorting/List.jsx +30 -0
- package/src/components/crm/AsyncSelect.jsx +125 -0
- package/src/components/crm/Autocomplete.jsx +174 -0
- package/src/components/crm/Breadcrumb.jsx +52 -0
- package/src/components/crm/Call.jsx +220 -0
- package/src/components/crm/DataGrid.jsx +2701 -0
- package/src/components/crm/Download.jsx +101 -0
- package/src/components/crm/Fetch.jsx +119 -0
- package/src/components/crm/Field.jsx +1637 -0
- package/src/components/crm/Form.jsx +1409 -0
- package/src/components/crm/Loader.jsx +29 -0
- package/src/components/crm/MultiSelect.jsx +78 -0
- package/src/components/crm/Navigation.jsx +619 -0
- package/src/components/crm/Notification.jsx +197 -0
- package/src/components/crm/QrCode.jsx +83 -0
- package/src/components/crm/Select.jsx +58 -0
- package/src/components/crm/SelectList.jsx +21 -0
- package/src/components/crm/TableFilter.jsx +198 -0
- package/src/components/crm/auth/Login.jsx +223 -0
- package/src/components/crm/auth/Profile.jsx +280 -0
- package/src/components/crm/auth/Reset.jsx +111 -0
- package/src/components/crm/auth/Verify.jsx +174 -0
- package/src/components/crm/auth/styles/Login.module.scss +243 -0
- package/src/components/crm/auth/styles/Profile.module.scss +222 -0
- package/src/components/crm/auth/styles/Reset.module.scss +216 -0
- package/src/components/crm/auth/styles/Verify.module.scss +216 -0
- package/src/components/crm/generic/AuditLog.jsx +108 -0
- package/src/components/crm/generic/AuditLogs.jsx +115 -0
- package/src/components/crm/generic/GenericAuth.jsx +166 -0
- package/src/components/crm/generic/GenericDashboard.jsx +42 -0
- package/src/components/crm/generic/GenericDetail.jsx +1499 -0
- package/src/components/crm/generic/GenericDynamic.jsx +916 -0
- package/src/components/crm/generic/GenericFormBuilder.jsx +1909 -0
- package/src/components/crm/generic/GenericIndex.jsx +376 -0
- package/src/components/crm/generic/GenericMain.jsx +129 -0
- package/src/components/crm/generic/GenericSort.jsx +188 -0
- package/src/components/crm/generic/NotificationList.jsx +64 -0
- package/src/components/crm/generic/styles/AuditLog.module.scss +147 -0
- package/src/components/crm/generic/styles/AuditLogs.module.scss +92 -0
- package/src/components/crm/generic/styles/GenericDetail.module.scss +634 -0
- package/src/components/crm/generic/styles/GenericDynamic.module.scss +932 -0
- package/src/components/crm/generic/styles/GenericFormBuilder.module.scss +944 -0
- package/src/components/crm/generic/styles/GenericIndex.module.scss +247 -0
- package/src/components/crm/generic/styles/GenericMain.module.scss +91 -0
- package/src/components/crm/generic/styles/GenericSort.module.scss +123 -0
- package/src/components/crm/generic/styles/NotificationList.module.scss +67 -0
- package/src/components/crm/sorting/Item.jsx +117 -0
- package/src/components/crm/sorting/List.jsx +32 -0
- package/src/components/crm/sorting/styles/Item.module.scss +68 -0
- package/src/components/crm/sorting/styles/List.module.scss +68 -0
- package/src/components/crm/styles/AsyncSelect.module.scss +8 -0
- package/src/components/crm/styles/Autocomplete.module.scss +44 -0
- package/src/components/crm/styles/DataGrid.module.scss +210 -0
- package/src/components/crm/styles/Field.module.scss +311 -0
- package/src/components/crm/styles/Form.module.scss +499 -0
- package/src/components/crm/styles/Loader.module.scss +94 -0
- package/src/components/crm/styles/MultiSelect.module.scss +8 -0
- package/src/components/crm/styles/Navigation.module.scss +978 -0
- package/src/components/crm/styles/Notification.module.scss +147 -0
- package/src/components/crm/styles/QrCode.module.scss +87 -0
- package/src/components/crm/styles/TableFilter.module.scss +52 -0
- package/src/components/styles/global.css +73 -0
- package/src/index.js +86 -0
- package/dist/104e5636d8ddb791614c.woff2 +0 -0
- package/dist/11fe6a83d647de5daf95.woff +0 -0
- package/dist/141e2a8c7836495afe2a.woff +0 -0
- package/dist/2ba5877f7079830b5383.woff +0 -0
- package/dist/2d6836f45b2037be41f3.woff +0 -0
- package/dist/399.0a0f3e0d21be1057d599.css +0 -8
- package/dist/399.b8f57fa3f8c0c10119e4.js +0 -1
- package/dist/47d566c3b1293dfd9d77.woff +0 -0
- package/dist/6282a13cbba671a71913.woff2 +0 -0
- package/dist/78266f551031aa9db127.woff +0 -0
- package/dist/7b7da89f1e3fdcbfe36c.woff2 +0 -0
- package/dist/7e78e8338af7efeda712.woff2 +0 -0
- package/dist/7fa387951673abf164b1.woff2 +0 -0
- package/dist/819d59862c2d0640aad8.woff +0 -0
- package/dist/b615e1a6c838ea059a56.woff +0 -0
- package/dist/b9b1aa739c660c4ce67c.woff2 +0 -0
- package/dist/c5f3640b11df9414facb.woff +0 -0
- package/dist/da26d162ff5af71d6590.woff2 +0 -0
- package/dist/dd5b2912dbf896310865.woff2 +0 -0
- package/dist/f282b331272463c1aa6c.woff2 +0 -0
- package/dist/index.css +0 -2902
- package/dist/index.js +0 -2
- package/dist/index.js.LICENSE.txt +0 -150
- package/dist/main.83b033670d64419bb497.css +0 -1
- package/dist/main.b1723d17cd2d3513ab62.js +0 -1
- package/dist/report.html +0 -39
- package/dist/runtime.33c276593b23f8035b8d.js +0 -1
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import axios from 'axios';
|
|
3
|
+
import { trackPromise } from 'react-promise-tracker';
|
|
4
|
+
import { toast } from 'react-toastify';
|
|
5
|
+
import parse from 'html-react-parser';
|
|
6
|
+
|
|
7
|
+
const CustomDownload = (
|
|
8
|
+
url,
|
|
9
|
+
method,
|
|
10
|
+
formData,
|
|
11
|
+
successCallback = null,
|
|
12
|
+
errorCallback = null
|
|
13
|
+
) => {
|
|
14
|
+
let headers = {};
|
|
15
|
+
let options = {};
|
|
16
|
+
|
|
17
|
+
if (method.toUpperCase() === 'PUT' || method.toUpperCase() === 'PATCH') {
|
|
18
|
+
formData = { ...formData, _method: method };
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (!(formData instanceof FormData)) {
|
|
22
|
+
headers['Content-Type'] = 'application/json';
|
|
23
|
+
formData = JSON.stringify(formData);
|
|
24
|
+
} else {
|
|
25
|
+
headers['Content-Type'] = 'multipart/form-data';
|
|
26
|
+
headers.contentType = false;
|
|
27
|
+
headers.processData = false;
|
|
28
|
+
|
|
29
|
+
if (
|
|
30
|
+
method.toUpperCase() === 'PUT' ||
|
|
31
|
+
method.toUpperCase() === 'PATCH'
|
|
32
|
+
) {
|
|
33
|
+
formData.append('_method', method);
|
|
34
|
+
method = 'POST';
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
options = {
|
|
39
|
+
method: method,
|
|
40
|
+
data: formData,
|
|
41
|
+
headers: headers,
|
|
42
|
+
url: url,
|
|
43
|
+
responseType: 'blob',
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
return trackPromise(
|
|
47
|
+
new Promise((resolve, reject) => {
|
|
48
|
+
axios(options)
|
|
49
|
+
.then((response) => {
|
|
50
|
+
if (successCallback) {
|
|
51
|
+
successCallback(response.data);
|
|
52
|
+
} else {
|
|
53
|
+
const error = response.data.error;
|
|
54
|
+
|
|
55
|
+
if (error && error !== '') {
|
|
56
|
+
toast.error(<div>{parse(error)}</div>);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
resolve(response);
|
|
60
|
+
})
|
|
61
|
+
.catch((error) => {
|
|
62
|
+
let errorMessage = '';
|
|
63
|
+
|
|
64
|
+
if (
|
|
65
|
+
error.response &&
|
|
66
|
+
error.response.data &&
|
|
67
|
+
error.response.data.message
|
|
68
|
+
) {
|
|
69
|
+
const { data } = error.response;
|
|
70
|
+
|
|
71
|
+
if (data.errors) {
|
|
72
|
+
const { errors } = data;
|
|
73
|
+
|
|
74
|
+
Object.values(errors).forEach((errorArray) => {
|
|
75
|
+
errorArray.forEach((errorMsg) => {
|
|
76
|
+
errorMessage += `${errorMsg}<br />`;
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
} else {
|
|
80
|
+
if (data.message === 'CSRF token mismatch.') {
|
|
81
|
+
window.location.replace('/login');
|
|
82
|
+
} else {
|
|
83
|
+
errorMessage = data.message;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
} else {
|
|
87
|
+
errorMessage = error.message;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (errorCallback) {
|
|
91
|
+
errorCallback(errorMessage);
|
|
92
|
+
} else {
|
|
93
|
+
toast.error(<div>{parse(errorMessage)}</div>);
|
|
94
|
+
}
|
|
95
|
+
reject(error);
|
|
96
|
+
});
|
|
97
|
+
})
|
|
98
|
+
);
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export default CustomDownload;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import axios from 'axios';
|
|
3
|
+
import { trackPromise } from 'react-promise-tracker';
|
|
4
|
+
import { toast } from 'react-toastify';
|
|
5
|
+
import parse from 'html-react-parser';
|
|
6
|
+
|
|
7
|
+
const CustomFetch = (
|
|
8
|
+
url,
|
|
9
|
+
method,
|
|
10
|
+
formData,
|
|
11
|
+
successCallback = null,
|
|
12
|
+
errorCallback = null
|
|
13
|
+
) => {
|
|
14
|
+
const baseUrl = '';
|
|
15
|
+
const headers = {
|
|
16
|
+
'Content-Type': 'application/json',
|
|
17
|
+
};
|
|
18
|
+
const MAX_PAYLOAD_SIZE_MB =
|
|
19
|
+
parseFloat(import.meta.env.VITE_MAX_PAYLOAD_SIZE_MB) || 4.5;
|
|
20
|
+
const MAX_PAYLOAD_SIZE = MAX_PAYLOAD_SIZE_MB * 1024 * 1024; // Convert MB to bytes
|
|
21
|
+
|
|
22
|
+
// Estimate headers size
|
|
23
|
+
const headersSize = JSON.stringify(headers).length;
|
|
24
|
+
|
|
25
|
+
// Estimate cookies size (if any)
|
|
26
|
+
const cookies = document.cookie;
|
|
27
|
+
const cookiesSize = cookies ? cookies.length : 0;
|
|
28
|
+
|
|
29
|
+
// Check payload size
|
|
30
|
+
const payloadSize = new Blob([JSON.stringify(formData)]).size;
|
|
31
|
+
const totalRequestSize = payloadSize + headersSize + cookiesSize;
|
|
32
|
+
|
|
33
|
+
if (totalRequestSize > MAX_PAYLOAD_SIZE) {
|
|
34
|
+
const errorMessage =
|
|
35
|
+
'The request is too large. Please try again with a smaller payload.';
|
|
36
|
+
if (errorCallback) {
|
|
37
|
+
errorCallback(errorMessage);
|
|
38
|
+
} else {
|
|
39
|
+
toast.error(errorMessage);
|
|
40
|
+
}
|
|
41
|
+
return Promise.reject(new Error(errorMessage));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (method.toUpperCase() === 'PUT' || method.toUpperCase() === 'PATCH') {
|
|
45
|
+
formData = {
|
|
46
|
+
...formData,
|
|
47
|
+
_method: method,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const options = {
|
|
52
|
+
method: method,
|
|
53
|
+
data: formData,
|
|
54
|
+
headers: headers,
|
|
55
|
+
url: baseUrl + url,
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
return trackPromise(
|
|
59
|
+
new Promise((resolve, reject) => {
|
|
60
|
+
axios(options)
|
|
61
|
+
.then((response) => {
|
|
62
|
+
if (successCallback) {
|
|
63
|
+
successCallback(response.data);
|
|
64
|
+
} else {
|
|
65
|
+
const error = response.data.error;
|
|
66
|
+
|
|
67
|
+
if (error && error !== '') {
|
|
68
|
+
toast.error(<div>{parse(error)}</div>);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
resolve(response);
|
|
72
|
+
})
|
|
73
|
+
.catch((error) => {
|
|
74
|
+
let errorMessage = '';
|
|
75
|
+
|
|
76
|
+
if (
|
|
77
|
+
error.response &&
|
|
78
|
+
error.response.data &&
|
|
79
|
+
error.response.data.message
|
|
80
|
+
) {
|
|
81
|
+
const { data } = error.response;
|
|
82
|
+
|
|
83
|
+
if (data.errors) {
|
|
84
|
+
const { errors } = data;
|
|
85
|
+
|
|
86
|
+
Object.values(errors).forEach((errorArray) => {
|
|
87
|
+
errorArray.forEach((errorMsg) => {
|
|
88
|
+
errorMessage += `${errorMsg}<br />`;
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
} else {
|
|
92
|
+
if (data.message === 'CSRF token mismatch.') {
|
|
93
|
+
window.location.replace('/login');
|
|
94
|
+
} else {
|
|
95
|
+
errorMessage = data.message;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
} else {
|
|
99
|
+
errorMessage = error.message;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (errorCallback) {
|
|
103
|
+
errorCallback(errorMessage);
|
|
104
|
+
} else {
|
|
105
|
+
if (errorMessage !== 'Unauthenticated.') {
|
|
106
|
+
toast.error(<div>{parse(errorMessage)}</div>);
|
|
107
|
+
} else {
|
|
108
|
+
console.info(
|
|
109
|
+
'You are not authenticated into the system.'
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
reject(error);
|
|
114
|
+
});
|
|
115
|
+
})
|
|
116
|
+
);
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
export default CustomFetch;
|