fix: teams are listed on insights but then you cant find them on settings page 11087 cal 2401 (#11092)

* fix listing of other teams

* add more invalidate trpc queries

* Remove unused code

* Removed unnecesary flags
This commit is contained in:
alannnc authored and GitHub committed 2023-09-04 08:47:53 -07:00
1 parent dfe7056c93
commit 7d944af7f6
6 files changed
+21 -80

No files matched your search

@@ -9,38 +9,20 @@ type ListOptions = {
};
export const listOtherTeamHandler = async ({ ctx }: ListOptions) => {
const teamsInOrgIamNotPartOf = await prisma.membership.findMany({
const teamsInOrgIamNotPartOf = await prisma.team.findMany({
where: {
userId: {
not: ctx.user.id,
parent: {
id: ctx.user?.organization?.id,
},
team: {
parent: {
is: {
id: ctx.user?.organization?.id,
},
},
members: {
none: {
userId: ctx.user.id,
},
members: {
none: {
userId: ctx.user.id,
},
},
},
include: {
team: true,
},
orderBy: { role: "desc" },
distinct: ["teamId"],
});
return teamsInOrgIamNotPartOf.map(({ team, ...membership }) => ({
role: membership.role,
accepted: membership.accepted,
userId: membership.userId,
isOrgAdmin: true,
...team,
}));
return teamsInOrgIamNotPartOf;
};
export default listOtherTeamHandler;