Skip to content

Commit

Permalink
fix: Get membership type for group
Browse files Browse the repository at this point in the history
  • Loading branch information
josebui committed Dec 1, 2023
1 parent c982ac8 commit fa8e5d5
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
7 changes: 5 additions & 2 deletions src/group/components/GroupForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ const FIELDS = [
type: 'url',
},
{
name: 'membershipType',
name: 'membershipsInfo.membershipType',
label: 'group.form_membershipType_label',
defaultValue: MEMBERSHIP_OPEN,
props: {
Expand Down Expand Up @@ -218,7 +218,10 @@ const GroupForm = () => {
const onSave = group => {
dispatch(
saveGroup({
group,
group: {
..._.omit(['membershipsInfo.membershipType'], group),
membershipType: group.membershipsInfo.membershipType,
},
user,
})
).then(() => {
Expand Down
2 changes: 2 additions & 0 deletions src/group/groupFragments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export const groupDataEntries = /* GraphQL */ `
export const groupMembershipList = /* GraphQL */ `
fragment groupMembershipList on GroupNode {
membershipList {
membershipType
membershipsCount
...accountCollaborationMembership
}
Expand All @@ -63,6 +64,7 @@ export const groupMembershipList = /* GraphQL */ `
export const groupMembershipListWithMembersSample = /* GraphQL */ `
fragment groupMembershipListWithMembersSample on GroupNode {
membershipList {
membershipType
membershipsCount
...accountCollaborationMembership
...collaborationMembershipsPending
Expand Down
13 changes: 9 additions & 4 deletions src/group/groupService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,16 @@ export const fetchGroupToUpdate = (slug: string) => {
edges {
node {
...groupFields
...groupMembershipList
}
}
}
}
`);
return terrasoApi
.requestGraphQL(query, { slug })
.then(
resp => resp.groups?.edges.at(0)?.node || Promise.reject('not_found')
);
.then(resp => resp.groups?.edges.at(0)?.node || Promise.reject('not_found'))
.then(extractGroup);
};

export const fetchGroupToView = async (slug: string, user: User | null) => {
Expand Down Expand Up @@ -197,7 +197,12 @@ const updateGroup = (group: Group) => {
}
`);
return terrasoApi
.requestGraphQL(query, { input: _.omit('slug', group) })
.requestGraphQL(query, {
input: {
..._.omit(['slug', 'membershipsInfo', 'membershipList'], group),
id: group.id || '',
},
})
.then(response => ({
new: false,
...response.updateGroup.group!,
Expand Down

0 comments on commit fa8e5d5

Please sign in to comment.