@visns-studio/visns-components 5.8.13 → 5.8.14
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/package.json
CHANGED
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"react-dom": "^17.0.0 || ^18.0.0"
|
|
83
83
|
},
|
|
84
84
|
"name": "@visns-studio/visns-components",
|
|
85
|
-
"version": "5.8.
|
|
85
|
+
"version": "5.8.14",
|
|
86
86
|
"description": "Various packages to assist in the development of our Custom Applications.",
|
|
87
87
|
"main": "src/index.js",
|
|
88
88
|
"files": [
|
|
@@ -350,17 +350,46 @@ function GenericDetail({
|
|
|
350
350
|
const handleCustomAction = async (action) => {
|
|
351
351
|
try {
|
|
352
352
|
if (action.url) {
|
|
353
|
+
let payload = {};
|
|
354
|
+
|
|
355
|
+
// If idKey exists, use it to extract values from data instead of routeParams
|
|
356
|
+
if (action.idKey && Array.isArray(action.idKey)) {
|
|
357
|
+
action.idKey.forEach((key) => {
|
|
358
|
+
// Handle nested keys by splitting on dots if needed
|
|
359
|
+
const keyPath = key.split('.');
|
|
360
|
+
let value = data;
|
|
361
|
+
|
|
362
|
+
// Traverse the data object using the key path
|
|
363
|
+
for (const pathSegment of keyPath) {
|
|
364
|
+
value = value?.[pathSegment];
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
// Use the last segment of the path as the payload key
|
|
368
|
+
const payloadKey = keyPath[keyPath.length - 1];
|
|
369
|
+
payload[payloadKey] = value;
|
|
370
|
+
});
|
|
371
|
+
} else {
|
|
372
|
+
// Fallback to original behavior using routeParams
|
|
373
|
+
payload.id = routeParams[urlParam];
|
|
374
|
+
}
|
|
375
|
+
|
|
353
376
|
const res = await CustomFetch(
|
|
354
377
|
action.url,
|
|
355
378
|
action.method || 'POST',
|
|
356
379
|
{
|
|
357
|
-
|
|
380
|
+
...payload,
|
|
358
381
|
...action.payload,
|
|
359
382
|
}
|
|
360
383
|
);
|
|
361
384
|
|
|
362
385
|
if (res.data.error === '') {
|
|
363
386
|
toast.success(action.message);
|
|
387
|
+
|
|
388
|
+
if (action.copyToClipboard) {
|
|
389
|
+
navigator.clipboard.writeText(
|
|
390
|
+
res.data[action.copyToClipboard]
|
|
391
|
+
);
|
|
392
|
+
}
|
|
364
393
|
} else {
|
|
365
394
|
toast.error(res.data.error);
|
|
366
395
|
}
|