Skip to content

Commit 0e6203a

Browse files
fix: install paypal button team level (calcom#24442)
* fix: install paypal button at team level * fix: install paypal button at team level --------- Co-authored-by: Anik Dhabal Babu <81948346+anikdhabal@users.noreply.github.com>
1 parent 624d6d7 commit 0e6203a

1 file changed

Lines changed: 20 additions & 5 deletions

File tree

apps/web/components/apps/AppPage.tsx

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,13 +160,21 @@ export const AppPage = ({
160160
function refactorMeWithoutEffect() {
161161
const data = appDbQuery.data;
162162

163-
const credentialsCount = data?.credentials.length || 0;
164-
setExistingCredentials(data?.credentials || []);
163+
const credentials = data?.credentials || [];
164+
setExistingCredentials(credentials);
165+
166+
const hasPersonalInstall = credentials.some((c) => !!c.userId && !c.teamId);
167+
const installedTeamIds = new Set<number>();
168+
for (const cred of credentials) {
169+
if (cred.teamId) installedTeamIds.add(cred.teamId);
170+
}
171+
172+
const totalInstalledTargets = (hasPersonalInstall ? 1 : 0) + installedTeamIds.size;
165173

166174
const appInstalledForAllTargets =
167175
availableForTeams && data?.userAdminTeams && data.userAdminTeams.length > 0
168-
? credentialsCount >= data.userAdminTeams.length
169-
: credentialsCount > 0;
176+
? totalInstalledTargets >= data.userAdminTeams.length + 1
177+
: credentials.length > 0;
170178
setAppInstalledForAllTargets(appInstalledForAllTargets);
171179
},
172180
[appDbQuery.data, availableForTeams]
@@ -244,7 +252,14 @@ export const AppPage = ({
244252
loading: isLoading,
245253
};
246254
}
247-
return <InstallAppButtonChild credentials={appDbQuery.data?.credentials} paid={paid} {...props} />;
255+
256+
return (
257+
<InstallAppButtonChild
258+
credentials={availableForTeams ? undefined : appDbQuery.data?.credentials}
259+
paid={paid}
260+
{...props}
261+
/>
262+
);
248263
}}
249264
/>
250265
);

0 commit comments

Comments
 (0)