* Wip * WIP * Removed concole log * Add relations to workspace init (#2511) * Add relations to workspace init * remove logs * update prefill * add missing isSystem * comment relation fields * Migrate v2 core models to graphql schema (#2509) * migrate v2 core models to graphql schema * Migrate to new workspace member schema * Continue work * migrated-main * Finished accountOwner nested field integration on companies * Introduce bug * Fix --------- Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com> Co-authored-by: Weiko <corentin@twenty.com>
25 lines
573 B
TypeScript
25 lines
573 B
TypeScript
export const mapPaginatedObjectsToObjects = <
|
|
ObjectType extends { id: string } & Record<string, any>,
|
|
ObjectTypeQuery extends {
|
|
[objectNamePlural: string]: {
|
|
edges: ObjectEdge[];
|
|
};
|
|
},
|
|
ObjectEdge extends {
|
|
node: ObjectType;
|
|
},
|
|
>({
|
|
pagedObjects,
|
|
objectNamePlural,
|
|
}: {
|
|
pagedObjects: ObjectTypeQuery | undefined;
|
|
objectNamePlural: string;
|
|
}) => {
|
|
const formattedObjects: ObjectType[] =
|
|
pagedObjects?.[objectNamePlural].edges.map((objectEdge: ObjectEdge) => ({
|
|
...objectEdge.node,
|
|
})) ?? [];
|
|
|
|
return formattedObjects;
|
|
};
|