Skip to content

Commit

Permalink
Merge branch 'emulsif-236-convert-images-to-support-sdc' of github.co…
Browse files Browse the repository at this point in the history
…m:emulsify-ds/emulsify-ui-kit into emulsif-241-convert-pager-to-support-sdc
  • Loading branch information
robherba committed Aug 9, 2024
2 parents b450e00 + 27f070e commit 298d14d
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/util/dataTransformers.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,20 @@
* @returns {Object} - A new object where each key is mapped to its `data` value from the original object.
*/
export function mapDataToTwig(props) {
const transformedData = {};
const result = {};

for (const key in props) {
if (props.hasOwnProperty(key) && props[key]?.data !== undefined) {
transformedData[key] = props[key].data;
if (props.hasOwnProperty(key)) {
if (props[key]?.data !== undefined) {
result[key] = props[key].data;
} else if (
typeof props[key] === 'object' &&
props[key].hasOwnProperty('properties')
) {
result[key] = mapDataToTwig(props[key].properties);
}
}
}

return transformedData;
return result;
}

0 comments on commit 298d14d

Please sign in to comment.