@visns-studio/visns-components 3.5.7 → 3.5.8

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.
@@ -363,27 +363,26 @@ const GenericDynamic = ({ data, fetchData, label, setData, setting, type }) => {
363
363
  };
364
364
 
365
365
  useEffect(() => {
366
- if (data[type]) {
366
+ if (data[type] && data[type].length > 0) {
367
367
  // Retrieve the last form of the specified type
368
368
  let lastForm = data[type][data[type].length - 1];
369
369
 
370
- Object.entries(data[type][data[type].length - 1]).forEach(
371
- ([key, field]) => {
372
- if (field.required) {
370
+ if (lastForm && typeof lastForm === 'object') {
371
+ Object.entries(lastForm).forEach(([key, field]) => {
372
+ if (field && field.required) {
373
373
  if (
374
374
  field.required === 'yes' ||
375
375
  field.required === 'no'
376
376
  ) {
377
- lastForm[key].required =
378
- field.required === 'yes' ? true : false;
377
+ lastForm[key].required = field.required === 'yes';
379
378
  }
380
379
  }
381
- }
382
- );
380
+ });
383
381
 
384
- // Update the active form with the modified lastForm
385
- setActiveForm(lastForm);
386
- setActiveFormKey(data[type].length - 1);
382
+ // Update the active form with the modified lastForm
383
+ setActiveForm(lastForm);
384
+ setActiveFormKey(data[type].length - 1);
385
+ }
387
386
  } else {
388
387
  handleAddNewForm();
389
388
  }
package/package.json CHANGED
@@ -50,7 +50,7 @@
50
50
  "react-dom": "^17.0.1"
51
51
  },
52
52
  "name": "@visns-studio/visns-components",
53
- "version": "3.5.7",
53
+ "version": "3.5.8",
54
54
  "description": "Various packages to assist in the development of our Custom Applications.",
55
55
  "main": "index.js",
56
56
  "scripts": {