diff --git a/apps/web/components/apps/AppPage.tsx b/apps/web/components/apps/AppPage.tsx index 20f136ab42..b0a727b5b3 100644 --- a/apps/web/components/apps/AppPage.tsx +++ b/apps/web/components/apps/AppPage.tsx @@ -160,13 +160,21 @@ export const AppPage = ({ function refactorMeWithoutEffect() { const data = appDbQuery.data; - const credentialsCount = data?.credentials.length || 0; - setExistingCredentials(data?.credentials || []); + const credentials = data?.credentials || []; + setExistingCredentials(credentials); + + const hasPersonalInstall = credentials.some((c) => !!c.userId && !c.teamId); + const installedTeamIds = new Set(); + for (const cred of credentials) { + if (cred.teamId) installedTeamIds.add(cred.teamId); + } + + const totalInstalledTargets = (hasPersonalInstall ? 1 : 0) + installedTeamIds.size; const appInstalledForAllTargets = availableForTeams && data?.userAdminTeams && data.userAdminTeams.length > 0 - ? credentialsCount >= data.userAdminTeams.length - : credentialsCount > 0; + ? totalInstalledTargets >= data.userAdminTeams.length + 1 + : credentials.length > 0; setAppInstalledForAllTargets(appInstalledForAllTargets); }, [appDbQuery.data, availableForTeams] @@ -244,7 +252,14 @@ export const AppPage = ({ loading: isLoading, }; } - return ; + + return ( + + ); }} /> );