@visns-studio/visns-components 4.3.1 → 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 +60 -1
- 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) {
|
|
@@ -1274,7 +1326,14 @@ function Form({
|
|
|
1274
1326
|
<div className="polActions">
|
|
1275
1327
|
{formSettings.hasOwnProperty('customButton') &&
|
|
1276
1328
|
formSettings.customButton.url ? (
|
|
1277
|
-
<button
|
|
1329
|
+
<button
|
|
1330
|
+
className="btn"
|
|
1331
|
+
onClick={(e) => {
|
|
1332
|
+
e.preventDefault();
|
|
1333
|
+
|
|
1334
|
+
handleCustom(formSettings);
|
|
1335
|
+
}}
|
|
1336
|
+
>
|
|
1278
1337
|
{formSettings.customButton.label
|
|
1279
1338
|
? formSettings.customButton.label
|
|
1280
1339
|
: 'Sort'}
|
package/package.json
CHANGED