From 729d3583a265fcbcc3208031cd1cd72415641552 Mon Sep 17 00:00:00 2001 From: Han <56923450+waddaboo@users.noreply.github.com> Date: Thu, 31 Oct 2024 20:47:14 +0800 Subject: [PATCH] feat(client): add redeemInvite for on-chain join group by invite --- apps/client/src/api/bandadaAPI.ts | 19 +++++++++++++++++++ apps/client/src/pages/home.tsx | 4 ++++ 2 files changed, 23 insertions(+) diff --git a/apps/client/src/api/bandadaAPI.ts b/apps/client/src/api/bandadaAPI.ts index 49aba4d2..661d2391 100644 --- a/apps/client/src/api/bandadaAPI.ts +++ b/apps/client/src/api/bandadaAPI.ts @@ -72,3 +72,22 @@ export async function addMemberByInviteCode( return null } } + +export async function redeemInvite( + inviteCode: string, + groupId: string +): Promise { + 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 + } +} diff --git a/apps/client/src/pages/home.tsx b/apps/client/src/pages/home.tsx index 8305dcbc..f4f5dd19 100644 --- a/apps/client/src/pages/home.tsx +++ b/apps/client/src/pages/home.tsx @@ -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"