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

View File

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