From cea46b06a1f4ea2d948fdab2102f847271cad38a Mon Sep 17 00:00:00 2001 From: Giancarlo Buomprisco Date: Sat, 26 Apr 2025 06:30:49 +0700 Subject: [PATCH] Update team member check in join page to use RPC call (#246) * Update team member check in join page to use RPC call Replaces direct API call with an RPC function to verify if a user is already a team member. This improves efficiency and ensures consistency with database operations. --- apps/web/app/join/page.tsx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/apps/web/app/join/page.tsx b/apps/web/app/join/page.tsx index 784db96b8..6fa5c7760 100644 --- a/apps/web/app/join/page.tsx +++ b/apps/web/app/join/page.tsx @@ -79,12 +79,15 @@ async function JoinTeamAccountPage(props: JoinTeamAccountPageProps) { // we need to verify the user isn't already in the account // we do so by checking if the user can read the account // if the user can read the account, then they are already in the account - const account = await api - .getTeamAccountById(invitation.account.id) - .catch(() => undefined); + const { data: isAlreadyTeamMember } = await client.rpc( + 'is_account_team_member', + { + target_account_id: invitation.account.id, + }, + ); // if the user is already in the account redirect to the home page - if (account) { + if (isAlreadyTeamMember) { const { getLogger } = await import('@kit/shared/logger'); const logger = await getLogger();