@visns-studio/visns-components 2.9.1 → 2.9.3
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.
|
@@ -2,9 +2,10 @@ import React, { useEffect, useState, useCallback } from 'react';
|
|
|
2
2
|
import { motion } from 'framer-motion';
|
|
3
3
|
import { useDropzone } from 'react-dropzone';
|
|
4
4
|
import { confirmAlert } from 'react-confirm-alert';
|
|
5
|
-
import { File, TrashCan } from 'akar-icons';
|
|
5
|
+
import { CircleX, File, TrashCan } from 'akar-icons';
|
|
6
6
|
import { toast } from 'react-toastify';
|
|
7
7
|
import { arrayMoveImmutable } from 'array-move';
|
|
8
|
+
import Popup from 'reactjs-popup';
|
|
8
9
|
|
|
9
10
|
import 'react-confirm-alert/src/react-confirm-alert.css';
|
|
10
11
|
|
|
@@ -14,6 +15,23 @@ import SortableList from './sorting/List';
|
|
|
14
15
|
function VisnsDropZone({ fetchData, files, settings }) {
|
|
15
16
|
const [data, setData] = useState(files);
|
|
16
17
|
|
|
18
|
+
/** Modal States */
|
|
19
|
+
const [modalData, setModalData] = useState({
|
|
20
|
+
id: 0,
|
|
21
|
+
title: '',
|
|
22
|
+
description: '',
|
|
23
|
+
});
|
|
24
|
+
const [modalShow, setModalShow] = useState(false);
|
|
25
|
+
|
|
26
|
+
/** Modal Functions */
|
|
27
|
+
const modalOpen = () => {
|
|
28
|
+
setModalShow(true);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const modalClose = () => {
|
|
32
|
+
setModalShow(false);
|
|
33
|
+
};
|
|
34
|
+
|
|
17
35
|
const [loadingProgress, setLoadingProgress] = useState(0);
|
|
18
36
|
|
|
19
37
|
const onSortEnd = ({ oldIndex, newIndex }) => {
|
|
@@ -70,6 +88,36 @@ function VisnsDropZone({ fetchData, files, settings }) {
|
|
|
70
88
|
}
|
|
71
89
|
};
|
|
72
90
|
|
|
91
|
+
const handleChange = (e) => {
|
|
92
|
+
const { name, value } = e.target;
|
|
93
|
+
|
|
94
|
+
setModalData((prevState) => ({
|
|
95
|
+
...prevState,
|
|
96
|
+
[name]: value,
|
|
97
|
+
}));
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
const handleEdit = async (fileData) => {
|
|
101
|
+
try {
|
|
102
|
+
const res = await CustomFetch(
|
|
103
|
+
`/ajax/files/${fileData.id}`,
|
|
104
|
+
'GET',
|
|
105
|
+
{}
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
setModalData((prevState) => ({
|
|
109
|
+
...prevState,
|
|
110
|
+
id: res.data.id,
|
|
111
|
+
title: res.data.file_title,
|
|
112
|
+
description: res.data.file_description,
|
|
113
|
+
}));
|
|
114
|
+
|
|
115
|
+
modalOpen();
|
|
116
|
+
} catch (error) {
|
|
117
|
+
console.info(error);
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
|
|
73
121
|
const handleDelete = (id, name) => {
|
|
74
122
|
console.info(id, name);
|
|
75
123
|
if (id && id > 0) {
|
|
@@ -107,6 +155,32 @@ function VisnsDropZone({ fetchData, files, settings }) {
|
|
|
107
155
|
}
|
|
108
156
|
};
|
|
109
157
|
|
|
158
|
+
const handleSubmit = async (e) => {
|
|
159
|
+
try {
|
|
160
|
+
if (e) {
|
|
161
|
+
e.preventDefault();
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const res = await CustomFetch(
|
|
165
|
+
`/ajax/files/${modalData.id}`,
|
|
166
|
+
'PUT',
|
|
167
|
+
{
|
|
168
|
+
file_title: modalData.title,
|
|
169
|
+
file_description: modalData.description,
|
|
170
|
+
}
|
|
171
|
+
);
|
|
172
|
+
|
|
173
|
+
if (res.data.error === '') {
|
|
174
|
+
toast.success('File metadata has been successfully updated.');
|
|
175
|
+
modalClose();
|
|
176
|
+
} else {
|
|
177
|
+
toast.error(res.data.error);
|
|
178
|
+
}
|
|
179
|
+
} catch (error) {
|
|
180
|
+
console.info(error);
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
|
|
110
184
|
useEffect(() => {
|
|
111
185
|
if (data.length > 0) {
|
|
112
186
|
CustomFetch(
|
|
@@ -137,6 +211,7 @@ function VisnsDropZone({ fetchData, files, settings }) {
|
|
|
137
211
|
helperClass="dragitem"
|
|
138
212
|
transitionDuration={250}
|
|
139
213
|
handleDelete={handleDelete}
|
|
214
|
+
handleEdit={handleEdit}
|
|
140
215
|
useDragHandle
|
|
141
216
|
/>
|
|
142
217
|
) : null}
|
|
@@ -195,6 +270,68 @@ function VisnsDropZone({ fetchData, files, settings }) {
|
|
|
195
270
|
</ul>
|
|
196
271
|
) : null}
|
|
197
272
|
</section>
|
|
273
|
+
<Popup
|
|
274
|
+
open={modalShow}
|
|
275
|
+
onClose={modalClose}
|
|
276
|
+
closeOnDocumentClick={false}
|
|
277
|
+
>
|
|
278
|
+
<div className="modalwrap top--modal">
|
|
279
|
+
<div className="modal">
|
|
280
|
+
<div className="modal__header">
|
|
281
|
+
<h1>Update File Metadata</h1>
|
|
282
|
+
<button
|
|
283
|
+
className="modal__close"
|
|
284
|
+
onClick={modalClose}
|
|
285
|
+
>
|
|
286
|
+
<CircleX strokeWidth={1} size={24} />
|
|
287
|
+
</button>
|
|
288
|
+
</div>
|
|
289
|
+
<div className="modal__content">
|
|
290
|
+
<div className="formcontainer">
|
|
291
|
+
<form
|
|
292
|
+
className="modalForm"
|
|
293
|
+
onSubmit={handleSubmit}
|
|
294
|
+
>
|
|
295
|
+
<div className="formItem fwItem">
|
|
296
|
+
<label className="fi__label">
|
|
297
|
+
<input
|
|
298
|
+
type="text"
|
|
299
|
+
name="title"
|
|
300
|
+
onChange={handleChange}
|
|
301
|
+
value={modalData.title}
|
|
302
|
+
/>
|
|
303
|
+
<span className="fi__span">
|
|
304
|
+
Title
|
|
305
|
+
</span>
|
|
306
|
+
</label>
|
|
307
|
+
</div>
|
|
308
|
+
<div className="formItem fwItem">
|
|
309
|
+
<label className="fi__label">
|
|
310
|
+
<textarea
|
|
311
|
+
name="description"
|
|
312
|
+
rows="5"
|
|
313
|
+
onChange={handleChange}
|
|
314
|
+
value={modalData.description}
|
|
315
|
+
></textarea>
|
|
316
|
+
<span className="fi__span">
|
|
317
|
+
Description
|
|
318
|
+
</span>
|
|
319
|
+
</label>
|
|
320
|
+
</div>
|
|
321
|
+
<div className="formItem fwItem lastItem">
|
|
322
|
+
<button
|
|
323
|
+
className="btn modalsave"
|
|
324
|
+
type="submit"
|
|
325
|
+
>
|
|
326
|
+
Save
|
|
327
|
+
</button>
|
|
328
|
+
</div>
|
|
329
|
+
</form>
|
|
330
|
+
</div>
|
|
331
|
+
</div>
|
|
332
|
+
</div>
|
|
333
|
+
</div>
|
|
334
|
+
</Popup>
|
|
198
335
|
</>
|
|
199
336
|
);
|
|
200
337
|
}
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { SortableElement, sortableHandle } from 'react-sortable-hoc';
|
|
3
|
-
import { ChevronVertical, TrashCan } from 'akar-icons';
|
|
3
|
+
import { ChevronVertical, Pencil, TrashCan } from 'akar-icons';
|
|
4
4
|
|
|
5
5
|
const DragHandle = sortableHandle(() => (
|
|
6
6
|
<ChevronVertical strokeWidth={1} size={26} />
|
|
7
7
|
));
|
|
8
8
|
|
|
9
|
-
const SortableItem = ({
|
|
9
|
+
const SortableItem = ({
|
|
10
|
+
containerIndex,
|
|
11
|
+
handleClick,
|
|
12
|
+
handleEdit,
|
|
13
|
+
handleDelete,
|
|
14
|
+
value,
|
|
15
|
+
}) => {
|
|
10
16
|
return (
|
|
11
17
|
<li
|
|
12
18
|
onClick={(e) => {
|
|
@@ -31,6 +37,23 @@ const SortableItem = ({ containerIndex, handleClick, handleDelete, value }) => {
|
|
|
31
37
|
<img src={value.file_url} />
|
|
32
38
|
</div>
|
|
33
39
|
) : null}
|
|
40
|
+
|
|
41
|
+
{handleEdit &&
|
|
42
|
+
value.hasOwnProperty('file_title') &&
|
|
43
|
+
value.hasOwnProperty('file_description') && (
|
|
44
|
+
<Pencil
|
|
45
|
+
className="delete pencil-edit"
|
|
46
|
+
strokeWidth={1}
|
|
47
|
+
size={26}
|
|
48
|
+
onClick={(e) => {
|
|
49
|
+
e.preventDefault();
|
|
50
|
+
e.stopPropagation();
|
|
51
|
+
|
|
52
|
+
handleEdit(value);
|
|
53
|
+
}}
|
|
54
|
+
/>
|
|
55
|
+
)}
|
|
56
|
+
|
|
34
57
|
{handleDelete && (
|
|
35
58
|
<TrashCan
|
|
36
59
|
className="delete trash-delete"
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import VisnsSortableItem from './Item';
|
|
3
3
|
import { SortableContainer } from 'react-sortable-hoc';
|
|
4
4
|
|
|
5
|
-
const SortableList = ({ handleClick, handleDelete, items }) => {
|
|
5
|
+
const SortableList = ({ handleClick, handleDelete, handleEdit, items }) => {
|
|
6
6
|
return (
|
|
7
7
|
<ul className="sortlist">
|
|
8
8
|
{items.map((value, index) => (
|
|
@@ -13,6 +13,7 @@ const SortableList = ({ handleClick, handleDelete, items }) => {
|
|
|
13
13
|
value={value}
|
|
14
14
|
handleClick={handleClick}
|
|
15
15
|
handleDelete={handleDelete}
|
|
16
|
+
handleEdit={handleEdit}
|
|
16
17
|
/>
|
|
17
18
|
))}
|
|
18
19
|
</ul>
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { useEffect, useRef, useState } from 'react';
|
|
2
|
+
import ReactToPrint from 'react-to-print';
|
|
3
|
+
|
|
4
|
+
import CustomFetch from './Fetch';
|
|
5
|
+
|
|
6
|
+
const QrCode = ({ config, dataId }) => {
|
|
7
|
+
const printComponentRef = useRef();
|
|
8
|
+
const [qrCodeData, setQrCodeData] = useState({
|
|
9
|
+
logo: '',
|
|
10
|
+
qrCode: '',
|
|
11
|
+
title: '',
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
const fetchQrCode = async ({ url }) => {
|
|
15
|
+
try {
|
|
16
|
+
const res = await CustomFetch(`${url}/${dataId}`, 'POST', {});
|
|
17
|
+
|
|
18
|
+
setQrCodeData((prevState) => ({ ...prevState, ...res.data }));
|
|
19
|
+
} catch (error) {
|
|
20
|
+
console.error(error);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
fetchQrCode(config);
|
|
26
|
+
}, []);
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<>
|
|
30
|
+
<div className="gridtxt" ref={printComponentRef}>
|
|
31
|
+
{qrCodeData.logo && qrCodeData.logo !== '' && (
|
|
32
|
+
<ul className="customer__overview">
|
|
33
|
+
<li
|
|
34
|
+
className="fw-grid-item"
|
|
35
|
+
style={{
|
|
36
|
+
textAlign: 'center',
|
|
37
|
+
}}
|
|
38
|
+
>
|
|
39
|
+
<img
|
|
40
|
+
src={qrCodeData.logo}
|
|
41
|
+
alt="Dawn Projects"
|
|
42
|
+
width="40%"
|
|
43
|
+
/>
|
|
44
|
+
</li>
|
|
45
|
+
</ul>
|
|
46
|
+
)}
|
|
47
|
+
<ul className="customer__overview">
|
|
48
|
+
<li
|
|
49
|
+
className="fw-grid-item"
|
|
50
|
+
style={{
|
|
51
|
+
textAlign: 'center',
|
|
52
|
+
}}
|
|
53
|
+
>
|
|
54
|
+
{qrCodeData.title}
|
|
55
|
+
</li>
|
|
56
|
+
</ul>
|
|
57
|
+
<ul className="customer__overview">
|
|
58
|
+
<li
|
|
59
|
+
className="fw-grid-item"
|
|
60
|
+
style={{ textAlign: 'center' }}
|
|
61
|
+
>
|
|
62
|
+
{qrCodeData.qrCode && qrCodeData.qrCode !== '' && (
|
|
63
|
+
<img
|
|
64
|
+
src={`data:image/svg+xml;base64, ${qrCodeData.qrCode}`}
|
|
65
|
+
alt="SVG Image"
|
|
66
|
+
width="80%"
|
|
67
|
+
/>
|
|
68
|
+
)}
|
|
69
|
+
</li>
|
|
70
|
+
</ul>
|
|
71
|
+
</div>
|
|
72
|
+
<div className="polActions">
|
|
73
|
+
<ReactToPrint
|
|
74
|
+
trigger={() => <button className="btn">Print</button>}
|
|
75
|
+
content={() => printComponentRef.current}
|
|
76
|
+
/>
|
|
77
|
+
</div>
|
|
78
|
+
</>
|
|
79
|
+
);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export default QrCode;
|
|
@@ -20,12 +20,14 @@ import 'react-confirm-alert/src/react-confirm-alert.css';
|
|
|
20
20
|
|
|
21
21
|
import CustomFetch from '../Fetch';
|
|
22
22
|
import Form from '../Form';
|
|
23
|
+
import QrCode from '../QrCode';
|
|
23
24
|
import Table from '../DataGrid';
|
|
24
25
|
import TableFilter from '../TableFilter';
|
|
25
26
|
import { toast } from 'react-toastify';
|
|
26
27
|
|
|
27
28
|
function GenericDetail({ setting, urlParam, userProfile }) {
|
|
28
29
|
const routeParams = useParams();
|
|
30
|
+
|
|
29
31
|
const { filters, page, stages, tabs } = setting;
|
|
30
32
|
|
|
31
33
|
/** Fileupload states */
|
|
@@ -93,10 +95,6 @@ function GenericDetail({ setting, urlParam, userProfile }) {
|
|
|
93
95
|
path.reduce((result, key) => (result ? result[key] : ''), data) ??
|
|
94
96
|
'';
|
|
95
97
|
|
|
96
|
-
if (path[0] && path[0] === 'insurance_types') {
|
|
97
|
-
console.info(value);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
98
|
if (value) {
|
|
101
99
|
if (Array.isArray(value)) {
|
|
102
100
|
return value
|
|
@@ -626,6 +624,13 @@ function GenericDetail({ setting, urlParam, userProfile }) {
|
|
|
626
624
|
)}
|
|
627
625
|
</>
|
|
628
626
|
);
|
|
627
|
+
case 'qrCode':
|
|
628
|
+
return (
|
|
629
|
+
<QrCode
|
|
630
|
+
config={activeTabConfig}
|
|
631
|
+
dataId={routeParams[urlParam]}
|
|
632
|
+
/>
|
|
633
|
+
);
|
|
629
634
|
case 'table':
|
|
630
635
|
if (
|
|
631
636
|
config.ajaxSetting &&
|
package/package.json
CHANGED
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
"react-select": "^5.8.0",
|
|
27
27
|
"react-slugify": "^3.0.3",
|
|
28
28
|
"react-sortable-hoc": "^2.0.0",
|
|
29
|
+
"react-to-print": "^2.14.15",
|
|
29
30
|
"react-toastify": "^9.1.3",
|
|
30
31
|
"react-toggle": "^4.1.3",
|
|
31
32
|
"react-tooltip": "^5.24.0",
|
|
@@ -44,7 +45,7 @@
|
|
|
44
45
|
"react-dom": "^17.0.1"
|
|
45
46
|
},
|
|
46
47
|
"name": "@visns-studio/visns-components",
|
|
47
|
-
"version": "2.9.
|
|
48
|
+
"version": "2.9.3",
|
|
48
49
|
"description": "Various packages to assist in the development of our Custom Applications.",
|
|
49
50
|
"main": "index.js",
|
|
50
51
|
"scripts": {
|