@visns-studio/visns-components 2.7.12 → 2.8.0
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 +27 -34
- package/package.json +1 -1
package/components/crm/Form.jsx
CHANGED
|
@@ -427,43 +427,28 @@ function Form({
|
|
|
427
427
|
if (validation !== '') {
|
|
428
428
|
toast.error(<div>{parse(validation)}</div>);
|
|
429
429
|
} else {
|
|
430
|
-
let url =
|
|
431
|
-
let method = '';
|
|
430
|
+
let url = formSettings.url;
|
|
431
|
+
let method = 'POST';
|
|
432
432
|
let fileUpload = false;
|
|
433
433
|
let fileKey = '';
|
|
434
434
|
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
method = 'DELETE';
|
|
453
|
-
break;
|
|
454
|
-
default:
|
|
455
|
-
if (formSettings.customUrl && formSettings.customMethod) {
|
|
456
|
-
url = formSettings.customUrl;
|
|
457
|
-
|
|
458
|
-
if (formSettings.customDataId) {
|
|
459
|
-
url += '/' + formData[formSettings.primaryKey];
|
|
460
|
-
}
|
|
461
|
-
method = formSettings.customMethod;
|
|
462
|
-
} else {
|
|
463
|
-
url = formSettings.url;
|
|
464
|
-
method = 'POST';
|
|
465
|
-
}
|
|
466
|
-
break;
|
|
435
|
+
if (formSettings.customUrl && formSettings.customMethod) {
|
|
436
|
+
url = formSettings.customUrl;
|
|
437
|
+
if (formSettings.customDataId) {
|
|
438
|
+
url += `/${formData[formSettings.primaryKey]}`;
|
|
439
|
+
}
|
|
440
|
+
method = formSettings.customMethod;
|
|
441
|
+
} else {
|
|
442
|
+
switch (formType) {
|
|
443
|
+
case 'create':
|
|
444
|
+
// URL and method are already set to default values
|
|
445
|
+
break;
|
|
446
|
+
case 'update':
|
|
447
|
+
case 'delete':
|
|
448
|
+
url += `/${formData[formSettings.primaryKey]}`;
|
|
449
|
+
method = formType === 'update' ? 'PUT' : 'DELETE';
|
|
450
|
+
break;
|
|
451
|
+
}
|
|
467
452
|
}
|
|
468
453
|
|
|
469
454
|
if (!_.isEmpty(formData)) {
|
|
@@ -510,6 +495,10 @@ function Form({
|
|
|
510
495
|
toast.success(
|
|
511
496
|
'Entry successfully saved into the system.'
|
|
512
497
|
);
|
|
498
|
+
|
|
499
|
+
if (result.redirect) {
|
|
500
|
+
navigate(result.redirect);
|
|
501
|
+
}
|
|
513
502
|
} else {
|
|
514
503
|
toast.error(
|
|
515
504
|
<div>
|
|
@@ -546,6 +535,10 @@ function Form({
|
|
|
546
535
|
) {
|
|
547
536
|
navigate(formSettings.redirect + result.data.id);
|
|
548
537
|
}
|
|
538
|
+
|
|
539
|
+
if (result.redirect) {
|
|
540
|
+
navigate(result.redirect);
|
|
541
|
+
}
|
|
549
542
|
} else {
|
|
550
543
|
toast.error(
|
|
551
544
|
<div>
|
package/package.json
CHANGED