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.
This commit is contained in:
Giancarlo Buomprisco
2025-04-26 06:30:49 +07:00
committed by GitHub
parent 2d4dc0fa5d
commit cea46b06a1

View File

@@ -79,12 +79,15 @@ async function JoinTeamAccountPage(props: JoinTeamAccountPageProps) {
// we need to verify the user isn't already in the account // we need to verify the user isn't already in the account
// we do so by checking if the user can read 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 // if the user can read the account, then they are already in the account
const account = await api const { data: isAlreadyTeamMember } = await client.rpc(
.getTeamAccountById(invitation.account.id) 'is_account_team_member',
.catch(() => undefined); {
target_account_id: invitation.account.id,
},
);
// if the user is already in the account redirect to the home page // 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 { getLogger } = await import('@kit/shared/logger');
const logger = await getLogger(); const logger = await getLogger();