From 8afc9478dedb5935e0342a71acdf9d00b1a52212 Mon Sep 17 00:00:00 2001 From: shrouxm Date: Wed, 13 Sep 2023 11:06:55 -0700 Subject: [PATCH] fix: collapse site fields in project service --- package-lock.json | 3 +-- src/project/projectService.ts | 6 +++++- src/site/siteService.ts | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index d04ba2a6..4039b76f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12983,8 +12983,7 @@ }, "node_modules/terraso-backend": { "version": "0.1.0", - "resolved": "git+ssh://git@github.com/techmatters/terraso-backend.git#8813449c8b2f4eb4b70b4add87007d2a93d25baa", - "integrity": "sha512-WXumMW1dnbEFfZjmNkRuibIuO7TDeRUQ8vr5K2nyhUs8bDZXUS67zM6TtLx92czO+PvdzI36ncH5abGHg3rpOQ==" + "resolved": "git+ssh://git@github.com/techmatters/terraso-backend.git#d87539e82c9ae59ace3948e1350f14ec25fedce4" }, "node_modules/test-exclude": { "version": "6.0.0", diff --git a/src/project/projectService.ts b/src/project/projectService.ts index 3316318e..d7ace0f2 100644 --- a/src/project/projectService.ts +++ b/src/project/projectService.ts @@ -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 { @@ -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), + .reduce( + (x, y) => ({ ...x, [y.id]: collapseSiteFields(y) }), + {} as Record, + ), memberships: inp => inp.group.memberships.edges .map(({ node: { id, userRole, membershipStatus } }) => ({ diff --git a/src/site/siteService.ts b/src/site/siteService.ts index 875b9ba0..723565af 100644 --- a/src/site/siteService.ts +++ b/src/site/siteService.ts @@ -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,