(signerPos, setXyPosition, value, userId)
| 1461 | } |
| 1462 | }; |
| 1463 | export const addInitialData = (signerPos, setXyPosition, value, userId) => { |
| 1464 | return signerPos.map((item) => { |
| 1465 | if (item.placeHolder && item.placeHolder.length > 0) { |
| 1466 | // If there is a nested array, recursively add the field to the last object |
| 1467 | if (item.Id === userId) { |
| 1468 | return { |
| 1469 | ...item, |
| 1470 | placeHolder: addInitialData( |
| 1471 | item.placeHolder, |
| 1472 | setXyPosition, |
| 1473 | value, |
| 1474 | userId |
| 1475 | ) |
| 1476 | }; |
| 1477 | } else { |
| 1478 | return item; |
| 1479 | } |
| 1480 | } else if (item.pos && item.pos.length > 0) { |
| 1481 | // If there is no nested array, add the new field |
| 1482 | return { |
| 1483 | ...item, |
| 1484 | pos: addInitialData(item.pos, setXyPosition, value, userId) |
| 1485 | // Adjust this line to add the desired field |
| 1486 | }; |
| 1487 | } else { |
| 1488 | const widgetData = widgetDataValue(item.type, value); |
| 1489 | if (["name", "company", "job title", "email"].includes(item.type)) { |
| 1490 | return { |
| 1491 | ...item, |
| 1492 | options: { |
| 1493 | ...item.options, |
| 1494 | defaultValue: item?.options?.defaultValue || widgetData |
| 1495 | } |
| 1496 | }; |
| 1497 | } else { |
| 1498 | return item; |
| 1499 | } |
| 1500 | } |
| 1501 | }); |
| 1502 | }; |
| 1503 | |
| 1504 | //function for embed document id |
| 1505 | export const embedDocId = async (pdfOriginalWH, pdfDoc, documentId) => { |
no test coverage detected