Skip to content

Commit

Permalink
fix: collapse site fields in project service
Browse files Browse the repository at this point in the history
  • Loading branch information
shrouxm committed Sep 13, 2023
1 parent a0e3a5e commit 8afc947
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
3 changes: 1 addition & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion src/project/projectService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import type {
Project,
SerializableSet,
} from 'terraso-client-shared/project/projectSlice';
import { collapseSiteFields } from 'terraso-client-shared/site/siteService';
import { Site } from 'terraso-client-shared/site/siteSlice';
import * as terrasoApi from 'terraso-client-shared/terrasoApi/api';
import {
Expand Down Expand Up @@ -66,7 +67,10 @@ const collapseProjectFields = collapseFields<
sites: inp =>
inp.siteSet.edges
.map(edge => edge.node)
.reduce((x, y) => ({ ...x, [y.id]: y }), {} as Record<string, Site>),
.reduce(
(x, y) => ({ ...x, [y.id]: collapseSiteFields(y) }),
{} as Record<string, Site>,
),
memberships: inp =>
inp.group.memberships.edges
.map(({ node: { id, userRole, membershipStatus } }) => ({
Expand Down
2 changes: 1 addition & 1 deletion src/site/siteService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import type { Site } from 'terraso-client-shared/site/siteSlice';
import * as terrasoApi from 'terraso-client-shared/terrasoApi/api';
import { collapseConnectionEdges } from 'terraso-client-shared/terrasoApi/utils';

const collapseSiteFields = (site: SiteDataFragment): Site => {
export const collapseSiteFields = (site: SiteDataFragment): Site => {
const { project, owner, ...rest } = site;
return {
...rest,
Expand Down

0 comments on commit 8afc947

Please sign in to comment.