Files
twenty_crm/packages/twenty-front/src/modules/activities/utils/flattenTargetableObjectsAndTheirRelatedTargetableObjects.ts
Lucas Bordeau b112b74022 Feat/activities custom objects (#3213)
* WIP

* WIP - MultiObjectSearch

* WIP

* WIP

* Finished working version

* Fix

* Fixed and cleaned

* Fix

* Disabled files and emails for custom objects

* Cleaned console.log

* Fixed attachment

* Fixed

* fix lint

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
2024-01-05 09:08:33 +01:00

22 lines
744 B
TypeScript

import { ActivityTargetableObject } from '../types/ActivityTargetableEntity';
export const flattenTargetableObjectsAndTheirRelatedTargetableObjects = (
targetableObjectsWithRelatedTargetableObjects: ActivityTargetableObject[],
): ActivityTargetableObject[] => {
const flattenedTargetableObjects: ActivityTargetableObject[] = [];
for (const targetableObject of targetableObjectsWithRelatedTargetableObjects ??
[]) {
flattenedTargetableObjects.push(targetableObject);
if (targetableObject.relatedTargetableObjects) {
for (const relatedEntity of targetableObject.relatedTargetableObjects ??
[]) {
flattenedTargetableObjects.push(relatedEntity);
}
}
}
return flattenedTargetableObjects;
};