Skip to content

Commit

Permalink
fix(INTERNAL-1264): fix command page 500
Browse files Browse the repository at this point in the history
  • Loading branch information
asabotovich committed Oct 21, 2024
1 parent ef7688e commit 0b22b9d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
15 changes: 8 additions & 7 deletions src/components/ProjectTeamPage/ProjectTeamPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -40,12 +40,13 @@ export const ProjectTeamPage = ({ user, ssrTime, params: { id } }: ExternalPageP
if (project) {
updateProjectTeams({
id: project.id,
teams: project.teams.reduce<string[]>((acum, { externalTeamId }) => {
if (externalTeamId !== id) {
acum.push(externalTeamId);
}
return acum;
}, []),
teams:
project.teams?.reduce<string[]>((acum, { externalTeamId }) => {
if (externalTeamId !== id) {
acum.push(externalTeamId);
}
return acum;
}, []) ?? [],
});
}
},
Expand Down
2 changes: 1 addition & 1 deletion src/components/TeamComboBox/TeamComboBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const TeamComboBox: FC<TeamComboBoxProps & React.HTMLAttributes<HTMLDivEl
if (item) {
updateProjectTeams({
id: project.id,
teams: [...project.teams.map(({ externalTeamId }) => externalTeamId), item.id],
teams: [...(project.teams?.map(({ externalTeamId }) => externalTeamId) ?? []), item.id],
});
}
},
Expand Down
2 changes: 1 addition & 1 deletion trpc/router/projectV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ type ProjectById = Omit<ProjectResponse, 'goals'> &
Pick<DashboardProject, '_count'> & {
parent: Array<{ id: string; title: string }>;
accessUsers: Array<ProjectActivity>;
teams: Array<Team>;
teams: Array<Team> | null;
children?: Array<{ id: string; title: string }>;
};

Expand Down

0 comments on commit 0b22b9d

Please sign in to comment.