@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
|
-
|
|
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
|
-
|
|
385
|
-
|
|
386
|
-
|
|
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