chore: reducing team next data (#11463)

* chore: reducing team next data

* Removing console.log
pull/11464/head
Leo Giovanetti 2023-09-20 14:45:14 -03:00 committed by GitHub
parent 2565d0915a
commit 07860c238a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 14 deletions

View File

@ -129,7 +129,8 @@ function TeamPage({ team, isUnpublished, markdownStrippedBio, isValidOrgDomain }
<span className="text-default text-sm font-bold">{ch.name}</span>
<span className="text-subtle block text-xs">
{t("number_member", {
count: ch.members.filter((mem) => mem.user.username !== null).length,
count: team.members.filter((mem) => mem.subteams?.includes(ch.slug) && mem.accepted)
.length,
})}
</span>
</div>
@ -138,9 +139,9 @@ function TeamPage({ team, isUnpublished, markdownStrippedBio, isValidOrgDomain }
className="mr-6"
size="sm"
truncateAfter={4}
items={ch.members
.filter((mem) => mem.user.username !== null)
.map(({ user: member }) => ({
items={team.members
.filter((mem) => mem.subteams?.includes(ch.slug) && mem.accepted)
.map((member) => ({
alt: member.name || "",
image: `/${member.username}/avatar.png`,
title: member.name || "",
@ -316,7 +317,9 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) =>
name: member.name,
id: member.id,
bio: member.bio,
subteams: member.subteams,
username: member.username,
accepted: member.accepted,
safeBio: markdownToSafeHTML(member.bio || ""),
};
});

View File

@ -28,6 +28,15 @@ export async function getTeamWithMembers(args: {
externalId: true,
},
},
teams: {
select: {
team: {
select: {
slug: true,
},
},
},
},
selectedCalendars: true,
credentials: {
select: {
@ -68,16 +77,6 @@ export async function getTeamWithMembers(args: {
name: true,
logo: true,
slug: true,
members: {
select: {
user: {
select: {
name: true,
username: true,
},
},
},
},
},
},
members: {
@ -142,6 +141,9 @@ export async function getTeamWithMembers(args: {
role: obj.role,
accepted: obj.accepted,
disableImpersonation: obj.disableImpersonation,
subteams: orgSlug
? obj.user.teams.filter((obj) => obj.team.slug !== orgSlug).map((obj) => obj.team.slug)
: null,
avatar: `${WEBAPP_URL}/${obj.user.username}/avatar.png`,
connectedApps: obj?.user?.credentials?.map((cred) => {
const appSlug = cred.app?.slug;