From d5b34b86c5ff222ec6f9138647af402a48e5aa36 Mon Sep 17 00:00:00 2001 From: Morgan Vernay Date: Fri, 20 Oct 2023 15:54:22 +0300 Subject: [PATCH] fix: getAppInstallsBySlug now use teamIds --- apps/web/pages/apps/onboarding/[[...step]].tsx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/apps/web/pages/apps/onboarding/[[...step]].tsx b/apps/web/pages/apps/onboarding/[[...step]].tsx index 74215020ae..b4c1f12eee 100644 --- a/apps/web/pages/apps/onboarding/[[...step]].tsx +++ b/apps/web/pages/apps/onboarding/[[...step]].tsx @@ -358,7 +358,7 @@ const getEventTypeById = async (eventTypeId: number) => { } as ConfigureEventTypeProp; }; -const getAppInstallsBySlug = async (appSlug: string, userId: number, teamId?: number) => { +const getAppInstallsBySlug = async (appSlug: string, userId: number, teamIds?: number[]) => { const appInstalls = await prisma.credential.findMany({ where: { OR: [ @@ -366,10 +366,10 @@ const getAppInstallsBySlug = async (appSlug: string, userId: number, teamId?: nu appId: appSlug, userId: userId, }, - teamId + teamIds && Boolean(teamIds.length) ? { appId: appSlug, - teamId: 5, + teamId: { in: teamIds }, } : {}, ], @@ -404,7 +404,11 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) => .map((team) => ({ ...team.team, accepted: team.accepted })); const hasTeams = Boolean(userAcceptedTeams.length); - const appInstalls = await getAppInstallsBySlug(parsedAppSlug, user.id, parsedTeamIdParam); + const appInstalls = await getAppInstallsBySlug( + parsedAppSlug, + user.id, + userAcceptedTeams.map(({ id }) => id) + ); if (parsedTeamIdParam) { const isUserMemberOfTeam = userAcceptedTeams.some((team) => team.id === parsedTeamIdParam);