Skip to content

Commit 9d86052

Browse files
authored
Delete account join request when redeeming an invite (#352)
* delete account join request when redeeming an invite * fix account request fetch
1 parent cf8fdd9 commit 9d86052

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

packages/web/src/actions.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,6 +1147,25 @@ export const redeemInvite = async (inviteId: string): Promise<{ success: boolean
11471147
}
11481148
});
11491149

1150+
// Delete the account request if it exists since we've redeemed an invite
1151+
const accountRequest = await tx.accountRequest.findUnique({
1152+
where: {
1153+
requestedById_orgId: {
1154+
requestedById: user.id,
1155+
orgId: invite.orgId,
1156+
}
1157+
},
1158+
});
1159+
1160+
if (accountRequest) {
1161+
logger.info(`Deleting account request ${accountRequest.id} for user ${user.id} since they've redeemed an invite`);
1162+
await tx.accountRequest.delete({
1163+
where: {
1164+
id: accountRequest.id,
1165+
}
1166+
});
1167+
}
1168+
11501169
if (IS_BILLING_ENABLED) {
11511170
const result = await incrementOrgSeatCount(invite.orgId, tx);
11521171
if (isServiceError(result)) {

0 commit comments

Comments
 (0)