Skip to content

Commit

Permalink
feat(client): add redeemInvite for on-chain join group by invite
Browse files Browse the repository at this point in the history
  • Loading branch information
waddaboo committed Oct 31, 2024
1 parent 924b483 commit 729d358
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
19 changes: 19 additions & 0 deletions apps/client/src/api/bandadaAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,22 @@ export async function addMemberByInviteCode(
return null
}
}

export async function redeemInvite(
inviteCode: string,
groupId: string
): Promise<Invite | null> {
try {
return await api.redeemInvite(inviteCode, groupId)
} catch (error: any) {
console.error(error)

if (error.response) {
alert(error.response.statusText)
} else {
alert("Some error occurred!")
}

return null
}
}
4 changes: 4 additions & 0 deletions apps/client/src/pages/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ export default function HomePage(): JSX.Element {
)

await semaphore.addMember(group.id, identityCommitment)
await bandadaAPI.redeemInvite(
inviteCode,
invite.group.id
)
} catch (error) {
alert(
"Some error occurred! Check if you're on Sepolia network and the transaction is signed and completed"
Expand Down

0 comments on commit 729d358

Please sign in to comment.