diff --git a/src/components/ProjectTeamPage/ProjectTeamPage.tsx b/src/components/ProjectTeamPage/ProjectTeamPage.tsx index 850b1b376..4dde12081 100644 --- a/src/components/ProjectTeamPage/ProjectTeamPage.tsx +++ b/src/components/ProjectTeamPage/ProjectTeamPage.tsx @@ -23,7 +23,7 @@ export const ProjectTeamPage = ({ user, ssrTime, params: { id } }: ExternalPageP const { data: project } = trpc.v2.project.getById.useQuery({ id }); const { updateProjectTeams } = useProjectResource(id); - const ids = useMemo(() => project?.teams.map(({ externalTeamId }) => externalTeamId) ?? [], [project]); + const ids = useMemo(() => project?.teams?.map(({ externalTeamId }) => externalTeamId) ?? [], [project]); const enabledTeamsRequest = Boolean(ids.length); @@ -40,12 +40,13 @@ export const ProjectTeamPage = ({ user, ssrTime, params: { id } }: ExternalPageP if (project) { updateProjectTeams({ id: project.id, - teams: project.teams.reduce((acum, { externalTeamId }) => { - if (externalTeamId !== id) { - acum.push(externalTeamId); - } - return acum; - }, []), + teams: + project.teams?.reduce((acum, { externalTeamId }) => { + if (externalTeamId !== id) { + acum.push(externalTeamId); + } + return acum; + }, []) ?? [], }); } }, diff --git a/src/components/TeamComboBox/TeamComboBox.tsx b/src/components/TeamComboBox/TeamComboBox.tsx index ef77180e2..bb0066d2a 100644 --- a/src/components/TeamComboBox/TeamComboBox.tsx +++ b/src/components/TeamComboBox/TeamComboBox.tsx @@ -42,7 +42,7 @@ export const TeamComboBox: FC externalTeamId), item.id], + teams: [...(project.teams?.map(({ externalTeamId }) => externalTeamId) ?? []), item.id], }); } }, diff --git a/trpc/router/projectV2.ts b/trpc/router/projectV2.ts index e5b910bac..97dbda473 100644 --- a/trpc/router/projectV2.ts +++ b/trpc/router/projectV2.ts @@ -117,7 +117,7 @@ type ProjectById = Omit & Pick & { parent: Array<{ id: string; title: string }>; accessUsers: Array; - teams: Array; + teams: Array | null; children?: Array<{ id: string; title: string }>; };