@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.
@@ -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
- switch (formType) {
436
- case 'create':
437
- url = formSettings.url;
438
- method = 'POST';
439
- break;
440
- case 'update':
441
- url =
442
- formSettings.url +
443
- '/' +
444
- formData[formSettings.primaryKey];
445
- method = 'PUT';
446
- break;
447
- case 'delete':
448
- url =
449
- formSettings.url +
450
- '/' +
451
- formData[formSettings.primaryKey];
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
@@ -44,7 +44,7 @@
44
44
  "react-dom": "^17.0.1"
45
45
  },
46
46
  "name": "@visns-studio/visns-components",
47
- "version": "2.7.12",
47
+ "version": "2.8.0",
48
48
  "description": "Various packages to assist in the development of our Custom Applications.",
49
49
  "main": "index.js",
50
50
  "scripts": {