Skip to content

Commit

Permalink
fix: Add extractMembership function
Browse files Browse the repository at this point in the history
  • Loading branch information
josebui committed Aug 28, 2023
1 parent c2500db commit b233d92
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/collaboration/membershipsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import _ from 'lodash/fp';
import type {
AccountCollaborationMembershipFragment,
CollaborationMembershipFieldsFragment,
CollaborationMembershipsFragment,
CollaborationMembershipsInfoFragment,
CollaborationMembershipsPendingFragment,
Expand All @@ -38,6 +39,15 @@ export const extractMembershipsInfo = (
membershipsSample: extractMemberships(membershipList),
});

export const extractMembership = (
membership: Partial<CollaborationMembershipFieldsFragment>,
) => ({
...membership.user,
..._.omit('user', membership),
membershipId: membership.id,
userId: membership.user?.id,
});

export const extractMemberships = (membershipList?: MembershipQuery | null) =>
(
(
Expand All @@ -47,11 +57,7 @@ export const extractMemberships = (membershipList?: MembershipQuery | null) =>
| null
| undefined
)?.memberships?.edges || []
).map(edge => ({
...edge.node.user,
..._.omit('user', edge.node),
membershipId: edge.node.id,
}));
).map(edge => extractMembership(edge.node));

export const extractAccountMembership = (
membershipList?: AccountCollaborationMembershipFragment | null,
Expand Down

0 comments on commit b233d92

Please sign in to comment.