@visns-studio/visns-components 4.3.0 → 4.3.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.
- package/components/crm/Form.jsx +68 -9
- package/package.json +1 -1
package/components/crm/Form.jsx
CHANGED
|
@@ -8,8 +8,10 @@ import parse from 'html-react-parser';
|
|
|
8
8
|
import _ from 'lodash';
|
|
9
9
|
import ReactDataGrid from '@inovua/reactdatagrid-community';
|
|
10
10
|
import { CircleX } from 'akar-icons';
|
|
11
|
+
import { confirmAlert } from 'react-confirm-alert';
|
|
11
12
|
|
|
12
13
|
import '@inovua/reactdatagrid-community/index.css';
|
|
14
|
+
import 'react-confirm-alert/src/react-confirm-alert.css';
|
|
13
15
|
|
|
14
16
|
import CustomFetch from './Fetch';
|
|
15
17
|
import Download from './Download';
|
|
@@ -491,6 +493,56 @@ function Form({
|
|
|
491
493
|
}
|
|
492
494
|
};
|
|
493
495
|
|
|
496
|
+
const handleCustom = async (s) => {
|
|
497
|
+
const executeRequest = async () => {
|
|
498
|
+
try {
|
|
499
|
+
const url = formSettings.customButton.url;
|
|
500
|
+
const method = 'POST';
|
|
501
|
+
|
|
502
|
+
const res = await CustomFetch(url, method, {
|
|
503
|
+
id: formData[formSettings.primaryKey],
|
|
504
|
+
});
|
|
505
|
+
|
|
506
|
+
if (res.data.error === '') {
|
|
507
|
+
if (res.data.message) {
|
|
508
|
+
toast.success(res.data.message);
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
fetchData();
|
|
512
|
+
} else {
|
|
513
|
+
toast.error(res.data.error);
|
|
514
|
+
}
|
|
515
|
+
} catch (error) {
|
|
516
|
+
console.error('Request failed:', error);
|
|
517
|
+
}
|
|
518
|
+
};
|
|
519
|
+
|
|
520
|
+
try {
|
|
521
|
+
if (s.customButton.confirmation) {
|
|
522
|
+
confirmAlert({
|
|
523
|
+
title: '',
|
|
524
|
+
message:
|
|
525
|
+
s.customButton.confirmation.message ||
|
|
526
|
+
'Are you sure you want to proceed?',
|
|
527
|
+
buttons: [
|
|
528
|
+
{
|
|
529
|
+
label: 'Yes',
|
|
530
|
+
onClick: executeRequest,
|
|
531
|
+
},
|
|
532
|
+
{
|
|
533
|
+
label: 'No',
|
|
534
|
+
onClick: () => close(),
|
|
535
|
+
},
|
|
536
|
+
],
|
|
537
|
+
});
|
|
538
|
+
} else {
|
|
539
|
+
await executeRequest();
|
|
540
|
+
}
|
|
541
|
+
} catch (err) {
|
|
542
|
+
console.error('An error occurred:', err);
|
|
543
|
+
}
|
|
544
|
+
};
|
|
545
|
+
|
|
494
546
|
const handleSubmit = async (e) => {
|
|
495
547
|
try {
|
|
496
548
|
if (e) {
|
|
@@ -1272,6 +1324,22 @@ function Form({
|
|
|
1272
1324
|
)}
|
|
1273
1325
|
</form>
|
|
1274
1326
|
<div className="polActions">
|
|
1327
|
+
{formSettings.hasOwnProperty('customButton') &&
|
|
1328
|
+
formSettings.customButton.url ? (
|
|
1329
|
+
<button
|
|
1330
|
+
className="btn"
|
|
1331
|
+
onClick={(e) => {
|
|
1332
|
+
e.preventDefault();
|
|
1333
|
+
|
|
1334
|
+
handleCustom(formSettings);
|
|
1335
|
+
}}
|
|
1336
|
+
>
|
|
1337
|
+
{formSettings.customButton.label
|
|
1338
|
+
? formSettings.customButton.label
|
|
1339
|
+
: 'Sort'}
|
|
1340
|
+
</button>
|
|
1341
|
+
) : null}
|
|
1342
|
+
|
|
1275
1343
|
{formSettings?.download?.button?.label && (
|
|
1276
1344
|
<button className="btn" onClick={handleDownload}>
|
|
1277
1345
|
{formSettings.download.button.label}
|
|
@@ -1287,15 +1355,6 @@ function Form({
|
|
|
1287
1355
|
</button>
|
|
1288
1356
|
) : null}
|
|
1289
1357
|
|
|
1290
|
-
{formSettings.hasOwnProperty('customButton') &&
|
|
1291
|
-
formSettings.customButton.url ? (
|
|
1292
|
-
<button className="btn" onClick={handleSort}>
|
|
1293
|
-
{formSettings.customButton.label
|
|
1294
|
-
? formSettings.customButton.label
|
|
1295
|
-
: 'Sort'}
|
|
1296
|
-
</button>
|
|
1297
|
-
) : null}
|
|
1298
|
-
|
|
1299
1358
|
<button className="btn" onClick={handleSubmit}>
|
|
1300
1359
|
{formSettings?.save?.button?.label
|
|
1301
1360
|
? formSettings.save.button.label
|
package/package.json
CHANGED