From afae46cea07c17bcde083d32fd65be4e6bb6de25 Mon Sep 17 00:00:00 2001 From: cedoor Date: Fri, 11 Aug 2023 10:31:06 +0200 Subject: [PATCH 1/3] chore: v0.13.0 --- apps/api/package.json | 4 ++-- apps/client/package.json | 4 ++-- apps/contracts/contracts/package.json | 2 +- apps/dashboard/package.json | 4 ++-- libs/api-sdk/package.json | 4 ++-- libs/credentials/package.json | 4 ++-- libs/hardhat/package.json | 4 ++-- libs/utils/package.json | 2 +- yarn.lock | 24 ++++++++++++------------ 9 files changed, 26 insertions(+), 26 deletions(-) diff --git a/apps/api/package.json b/apps/api/package.json index 96117d61..ad2b9e5a 100644 --- a/apps/api/package.json +++ b/apps/api/package.json @@ -8,8 +8,8 @@ "build": "nest build" }, "dependencies": { - "@bandada/credentials": "0.12.0", - "@bandada/utils": "0.12.0", + "@bandada/credentials": "0.13.0", + "@bandada/utils": "0.13.0", "@ethersproject/hash": "^5.7.0", "@nestjs/common": "^9.0.0", "@nestjs/core": "^9.0.0", diff --git a/apps/client/package.json b/apps/client/package.json index 5b2c0458..f5837198 100644 --- a/apps/client/package.json +++ b/apps/client/package.json @@ -8,8 +8,8 @@ "preview": "vite preview" }, "dependencies": { - "@bandada/api-sdk": "0.12.0", - "@bandada/utils": "0.12.0", + "@bandada/api-sdk": "0.13.0", + "@bandada/utils": "0.13.0", "@chakra-ui/react": "^2.5.1", "@chakra-ui/theme-tools": "^2.0.16", "@emotion/react": "^11.10.6", diff --git a/apps/contracts/contracts/package.json b/apps/contracts/contracts/package.json index 3542c0cb..224721bf 100644 --- a/apps/contracts/contracts/package.json +++ b/apps/contracts/contracts/package.json @@ -1,6 +1,6 @@ { "name": "@bandada/contracts", - "version": "0.12.0", + "version": "0.13.0", "description": "Bandada smart contracts to manage off-chain groups and verify their zero-knowledge proofs.", "license": "MIT", "files": [ diff --git a/apps/dashboard/package.json b/apps/dashboard/package.json index d8aebda5..a9a7526e 100644 --- a/apps/dashboard/package.json +++ b/apps/dashboard/package.json @@ -8,8 +8,8 @@ "preview": "vite preview" }, "dependencies": { - "@bandada/credentials": "0.12.0", - "@bandada/utils": "0.12.0", + "@bandada/credentials": "0.13.0", + "@bandada/utils": "0.13.0", "@chakra-ui/react": "^2.5.1", "@chakra-ui/theme-tools": "^2.0.16", "@emotion/react": "^11.10.6", diff --git a/libs/api-sdk/package.json b/libs/api-sdk/package.json index f696057e..65a47fdb 100644 --- a/libs/api-sdk/package.json +++ b/libs/api-sdk/package.json @@ -1,6 +1,6 @@ { "name": "@bandada/api-sdk", - "version": "0.12.0", + "version": "0.13.0", "description": "A Typescript SDK for the Bandada API.", "license": "MIT", "main": "dist/index.node.js", @@ -29,7 +29,7 @@ "access": "public" }, "dependencies": { - "@bandada/utils": "0.12.0" + "@bandada/utils": "0.13.0" }, "devDependencies": { "@rollup/plugin-typescript": "^11.0.0", diff --git a/libs/credentials/package.json b/libs/credentials/package.json index b3f3c0f6..4004d6f9 100644 --- a/libs/credentials/package.json +++ b/libs/credentials/package.json @@ -1,6 +1,6 @@ { "name": "@bandada/credentials", - "version": "0.12.0", + "version": "0.13.0", "description": "Bandada library to validate users' credentials.", "license": "MIT", "main": "dist/index.node.js", @@ -29,7 +29,7 @@ "access": "public" }, "dependencies": { - "@bandada/utils": "0.12.0" + "@bandada/utils": "0.13.0" }, "devDependencies": { "@rollup/plugin-typescript": "^11.0.0", diff --git a/libs/hardhat/package.json b/libs/hardhat/package.json index 69f222c7..7943b183 100644 --- a/libs/hardhat/package.json +++ b/libs/hardhat/package.json @@ -1,6 +1,6 @@ { "name": "@bandada/hardhat", - "version": "0.12.0", + "version": "0.13.0", "description": "A Hardhat plugin which provides tasks to deploy Bandada contracts.", "license": "MIT", "main": "dist/index.node.js", @@ -39,7 +39,7 @@ "typescript": "^4.9.5" }, "peerDependencies": { - "@bandada/contracts": "0.12.0", + "@bandada/contracts": "0.13.0", "@nomiclabs/hardhat-ethers": "^2.0.0", "@semaphore-protocol/contracts": "3.4.0", "ethers": "^5.4.7", diff --git a/libs/utils/package.json b/libs/utils/package.json index e99ac736..22c883a8 100644 --- a/libs/utils/package.json +++ b/libs/utils/package.json @@ -1,6 +1,6 @@ { "name": "@bandada/utils", - "version": "0.12.0", + "version": "0.13.0", "description": "General Bandada utility functions.", "license": "MIT", "main": "dist/index.node.js", diff --git a/yarn.lock b/yarn.lock index f8298c09..65f94e1f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -783,11 +783,11 @@ __metadata: languageName: node linkType: hard -"@bandada/api-sdk@0.12.0, @bandada/api-sdk@workspace:libs/api-sdk": +"@bandada/api-sdk@0.13.0, @bandada/api-sdk@workspace:libs/api-sdk": version: 0.0.0-use.local resolution: "@bandada/api-sdk@workspace:libs/api-sdk" dependencies: - "@bandada/utils": 0.12.0 + "@bandada/utils": 0.13.0 "@rollup/plugin-typescript": ^11.0.0 rimraf: ^4.1.2 rollup: ^3.17.2 @@ -805,11 +805,11 @@ __metadata: languageName: unknown linkType: soft -"@bandada/credentials@0.12.0, @bandada/credentials@workspace:libs/credentials": +"@bandada/credentials@0.13.0, @bandada/credentials@workspace:libs/credentials": version: 0.0.0-use.local resolution: "@bandada/credentials@workspace:libs/credentials" dependencies: - "@bandada/utils": 0.12.0 + "@bandada/utils": 0.13.0 "@rollup/plugin-typescript": ^11.0.0 rimraf: ^4.1.2 rollup: ^3.17.2 @@ -832,7 +832,7 @@ __metadata: rollup-plugin-cleanup: ^3.2.1 typescript: ^4.9.5 peerDependencies: - "@bandada/contracts": 0.12.0 + "@bandada/contracts": 0.13.0 "@nomiclabs/hardhat-ethers": ^2.0.0 "@semaphore-protocol/contracts": 3.4.0 ethers: ^5.4.7 @@ -840,7 +840,7 @@ __metadata: languageName: unknown linkType: soft -"@bandada/utils@0.12.0, @bandada/utils@workspace:libs/utils": +"@bandada/utils@0.13.0, @bandada/utils@workspace:libs/utils": version: 0.0.0-use.local resolution: "@bandada/utils@workspace:libs/utils" dependencies: @@ -7610,8 +7610,8 @@ __metadata: version: 0.0.0-use.local resolution: "api@workspace:apps/api" dependencies: - "@bandada/credentials": 0.12.0 - "@bandada/utils": 0.12.0 + "@bandada/credentials": 0.13.0 + "@bandada/utils": 0.13.0 "@ethersproject/hash": ^5.7.0 "@nestjs/cli": ^9.0.0 "@nestjs/common": ^9.0.0 @@ -9114,8 +9114,8 @@ __metadata: version: 0.0.0-use.local resolution: "client@workspace:apps/client" dependencies: - "@bandada/api-sdk": 0.12.0 - "@bandada/utils": 0.12.0 + "@bandada/api-sdk": 0.13.0 + "@bandada/utils": 0.13.0 "@chakra-ui/react": ^2.5.1 "@chakra-ui/theme-tools": ^2.0.16 "@emotion/react": ^11.10.6 @@ -9864,8 +9864,8 @@ __metadata: version: 0.0.0-use.local resolution: "dashboard@workspace:apps/dashboard" dependencies: - "@bandada/credentials": 0.12.0 - "@bandada/utils": 0.12.0 + "@bandada/credentials": 0.13.0 + "@bandada/utils": 0.13.0 "@chakra-ui/react": ^2.5.1 "@chakra-ui/theme-tools": ^2.0.16 "@emotion/react": ^11.10.6 From 68fa5278282cb4cef40e72980bf59a3e4dcbe749 Mon Sep 17 00:00:00 2001 From: cedoor Date: Fri, 11 Aug 2023 11:40:07 +0200 Subject: [PATCH 2/3] chore: v0.14.0 --- apps/api/package.json | 4 +- apps/client/package.json | 4 +- apps/client/src/pages/home.tsx | 62 +++++++++++--------- apps/contracts/contracts/package.json | 2 +- apps/dashboard/package.json | 4 +- apps/dashboard/src/hooks/use-session-data.ts | 1 + libs/api-sdk/package.json | 4 +- libs/api-sdk/src/apiSdk.ts | 2 +- libs/api-sdk/src/groups.ts | 16 ++++- libs/api-sdk/src/invites.ts | 2 + libs/api-sdk/src/types/index.ts | 10 +++- libs/credentials/package.json | 4 +- libs/hardhat/package.json | 4 +- libs/utils/package.json | 2 +- yarn.lock | 24 ++++---- 15 files changed, 86 insertions(+), 59 deletions(-) diff --git a/apps/api/package.json b/apps/api/package.json index ad2b9e5a..08c215cf 100644 --- a/apps/api/package.json +++ b/apps/api/package.json @@ -8,8 +8,8 @@ "build": "nest build" }, "dependencies": { - "@bandada/credentials": "0.13.0", - "@bandada/utils": "0.13.0", + "@bandada/credentials": "0.14.0", + "@bandada/utils": "0.14.0", "@ethersproject/hash": "^5.7.0", "@nestjs/common": "^9.0.0", "@nestjs/core": "^9.0.0", diff --git a/apps/client/package.json b/apps/client/package.json index f5837198..a32570de 100644 --- a/apps/client/package.json +++ b/apps/client/package.json @@ -8,8 +8,8 @@ "preview": "vite preview" }, "dependencies": { - "@bandada/api-sdk": "0.13.0", - "@bandada/utils": "0.13.0", + "@bandada/api-sdk": "0.14.0", + "@bandada/utils": "0.14.0", "@chakra-ui/react": "^2.5.1", "@chakra-ui/theme-tools": "^2.0.16", "@emotion/react": "^11.10.6", diff --git a/apps/client/src/pages/home.tsx b/apps/client/src/pages/home.tsx index d5df5955..27386747 100644 --- a/apps/client/src/pages/home.tsx +++ b/apps/client/src/pages/home.tsx @@ -1,4 +1,3 @@ -import { request } from "@bandada/utils" import { Button, Container, @@ -19,6 +18,12 @@ import { useCallback, useEffect, useState } from "react" import { FiGithub } from "react-icons/fi" import { useSearchParams } from "react-router-dom" import icon1Image from "../assets/icon1.svg" +import { + addMemberByInviteCode, + getGroup, + getInvite, + isGroupMember +} from "../utils/api" const injectedConnector = new InjectedConnector({}) @@ -54,12 +59,9 @@ export default function HomePage(): JSX.Element { if (account && library) { setLoading(true) - const invite = await request( - `${import.meta.env.VITE_API_URL}/invites/${inviteCode}` - ) + const invite = await getInvite(inviteCode) - if (!invite) { - alert("Some error occurred!") + if (invite === null) { setLoading(false) return } @@ -70,33 +72,36 @@ export default function HomePage(): JSX.Element { const identity = new Identity(await signer.signMessage(message)) const identityCommitment = identity.getCommitment().toString() - const hasJoined = await request( - `${import.meta.env.VITE_API_URL}/groups/${ - invite.groupId - }/members/${identityCommitment}` + const hasJoined = await isGroupMember( + invite.groupId, + identityCommitment ) + if (hasJoined === null) { + setLoading(false) + return + } + if (hasJoined) { - alert("You have already joined this group") setLoading(false) + alert("You have already joined this group") return } - await request( - `${import.meta.env.VITE_API_URL}/groups/${ - invite.groupId - }/members/${identityCommitment}`, - { - method: "post", - data: { - inviteCode - } - } + const response = await addMemberByInviteCode( + invite.groupId, + identityCommitment, + inviteCode ) - alert("You have joined the group!") + if (response === null) { + setLoading(false) + return + } + setInviteCode("") setLoading(false) + alert("You have joined the group!") } }, [account, library] @@ -107,12 +112,15 @@ export default function HomePage(): JSX.Element { if (account && library) { setLoading(true) - const { credentials } = await request( - `${import.meta.env.VITE_API_URL}/groups/${groupId}` - ) + const group = await getGroup(groupId) + + if (group === null) { + setLoading(false) + return + } - const providerName = JSON.parse(credentials) - .id.split("_")[0] + const providerName = group.credentials.id + .split("_")[0] .toLowerCase() const signer = library.getSigner(account) diff --git a/apps/contracts/contracts/package.json b/apps/contracts/contracts/package.json index 224721bf..be36b6fa 100644 --- a/apps/contracts/contracts/package.json +++ b/apps/contracts/contracts/package.json @@ -1,6 +1,6 @@ { "name": "@bandada/contracts", - "version": "0.13.0", + "version": "0.14.0", "description": "Bandada smart contracts to manage off-chain groups and verify their zero-knowledge proofs.", "license": "MIT", "files": [ diff --git a/apps/dashboard/package.json b/apps/dashboard/package.json index a9a7526e..c885e4f8 100644 --- a/apps/dashboard/package.json +++ b/apps/dashboard/package.json @@ -8,8 +8,8 @@ "preview": "vite preview" }, "dependencies": { - "@bandada/credentials": "0.13.0", - "@bandada/utils": "0.13.0", + "@bandada/credentials": "0.14.0", + "@bandada/utils": "0.14.0", "@chakra-ui/react": "^2.5.1", "@chakra-ui/theme-tools": "^2.0.16", "@emotion/react": "^11.10.6", diff --git a/apps/dashboard/src/hooks/use-session-data.ts b/apps/dashboard/src/hooks/use-session-data.ts index 44cb5eed..88298dd3 100644 --- a/apps/dashboard/src/hooks/use-session-data.ts +++ b/apps/dashboard/src/hooks/use-session-data.ts @@ -14,6 +14,7 @@ export default function useSessionData() { useEffect(() => { ;(async () => { if (!(await bandadaAPI.isLoggedIn())) { + session.deleteAdmin() setAdmin(null) } })() diff --git a/libs/api-sdk/package.json b/libs/api-sdk/package.json index 65a47fdb..36fc7822 100644 --- a/libs/api-sdk/package.json +++ b/libs/api-sdk/package.json @@ -1,6 +1,6 @@ { "name": "@bandada/api-sdk", - "version": "0.13.0", + "version": "0.14.0", "description": "A Typescript SDK for the Bandada API.", "license": "MIT", "main": "dist/index.node.js", @@ -29,7 +29,7 @@ "access": "public" }, "dependencies": { - "@bandada/utils": "0.13.0" + "@bandada/utils": "0.14.0" }, "devDependencies": { "@rollup/plugin-typescript": "^11.0.0", diff --git a/libs/api-sdk/src/apiSdk.ts b/libs/api-sdk/src/apiSdk.ts index a8752ec0..f56d79d5 100644 --- a/libs/api-sdk/src/apiSdk.ts +++ b/libs/api-sdk/src/apiSdk.ts @@ -30,7 +30,7 @@ export default class ApiSdk { checkParameter(config, "config", "object") if (!config["baseURL"]) { this._config = { - baseUrl: url, + baseURL: url, ...config } } else { diff --git a/libs/api-sdk/src/groups.ts b/libs/api-sdk/src/groups.ts index 7cb27088..62316c54 100644 --- a/libs/api-sdk/src/groups.ts +++ b/libs/api-sdk/src/groups.ts @@ -10,6 +10,11 @@ const url = "/groups" export async function getGroups(config: object): Promise { const groups = await request(url, config) + groups.map((group: any) => ({ + ...group, + credentials: JSON.parse(group.credentials) + })) + return groups } @@ -26,6 +31,8 @@ export async function getGroup( const group = await request(requestUrl, config) + group.credentials = JSON.parse(group.credentials) + return group } @@ -105,12 +112,15 @@ export async function addMemberByInviteCode( ): Promise { const requestUrl = `${url}/${groupId}/members/${memberId}` - await request(requestUrl, { + const newConfig: any = { method: "post", data: { inviteCode - } - }) + }, + ...config + } + + await request(requestUrl, newConfig) } /** diff --git a/libs/api-sdk/src/invites.ts b/libs/api-sdk/src/invites.ts index c9d61307..6bdafaa5 100644 --- a/libs/api-sdk/src/invites.ts +++ b/libs/api-sdk/src/invites.ts @@ -16,5 +16,7 @@ export async function getInvite( const invite = await request(requestUrl, config) + invite.group.credentials = JSON.parse(invite.group.credentials) + return invite } diff --git a/libs/api-sdk/src/types/index.ts b/libs/api-sdk/src/types/index.ts index a62b385a..879d0619 100644 --- a/libs/api-sdk/src/types/index.ts +++ b/libs/api-sdk/src/types/index.ts @@ -7,7 +7,10 @@ export type GroupResponse = { fingerprintDuration: number createdAt: Date members: string[] - credentials: object + credentials: { + id: string + criteria: Record + } } type Group = { @@ -17,7 +20,10 @@ type Group = { adminId: string treeDepth: number fingerprintDuration: number - credentials: object + credentials: { + id: string + criteria: Record + } apiEnabled: boolean apiKey: string createdAt: Date diff --git a/libs/credentials/package.json b/libs/credentials/package.json index 4004d6f9..ec2c0159 100644 --- a/libs/credentials/package.json +++ b/libs/credentials/package.json @@ -1,6 +1,6 @@ { "name": "@bandada/credentials", - "version": "0.13.0", + "version": "0.14.0", "description": "Bandada library to validate users' credentials.", "license": "MIT", "main": "dist/index.node.js", @@ -29,7 +29,7 @@ "access": "public" }, "dependencies": { - "@bandada/utils": "0.13.0" + "@bandada/utils": "0.14.0" }, "devDependencies": { "@rollup/plugin-typescript": "^11.0.0", diff --git a/libs/hardhat/package.json b/libs/hardhat/package.json index 7943b183..dbd12dde 100644 --- a/libs/hardhat/package.json +++ b/libs/hardhat/package.json @@ -1,6 +1,6 @@ { "name": "@bandada/hardhat", - "version": "0.13.0", + "version": "0.14.0", "description": "A Hardhat plugin which provides tasks to deploy Bandada contracts.", "license": "MIT", "main": "dist/index.node.js", @@ -39,7 +39,7 @@ "typescript": "^4.9.5" }, "peerDependencies": { - "@bandada/contracts": "0.13.0", + "@bandada/contracts": "0.14.0", "@nomiclabs/hardhat-ethers": "^2.0.0", "@semaphore-protocol/contracts": "3.4.0", "ethers": "^5.4.7", diff --git a/libs/utils/package.json b/libs/utils/package.json index 22c883a8..2c4e8979 100644 --- a/libs/utils/package.json +++ b/libs/utils/package.json @@ -1,6 +1,6 @@ { "name": "@bandada/utils", - "version": "0.13.0", + "version": "0.14.0", "description": "General Bandada utility functions.", "license": "MIT", "main": "dist/index.node.js", diff --git a/yarn.lock b/yarn.lock index 65f94e1f..de1f4ecc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -783,11 +783,11 @@ __metadata: languageName: node linkType: hard -"@bandada/api-sdk@0.13.0, @bandada/api-sdk@workspace:libs/api-sdk": +"@bandada/api-sdk@0.14.0, @bandada/api-sdk@workspace:libs/api-sdk": version: 0.0.0-use.local resolution: "@bandada/api-sdk@workspace:libs/api-sdk" dependencies: - "@bandada/utils": 0.13.0 + "@bandada/utils": 0.14.0 "@rollup/plugin-typescript": ^11.0.0 rimraf: ^4.1.2 rollup: ^3.17.2 @@ -805,11 +805,11 @@ __metadata: languageName: unknown linkType: soft -"@bandada/credentials@0.13.0, @bandada/credentials@workspace:libs/credentials": +"@bandada/credentials@0.14.0, @bandada/credentials@workspace:libs/credentials": version: 0.0.0-use.local resolution: "@bandada/credentials@workspace:libs/credentials" dependencies: - "@bandada/utils": 0.13.0 + "@bandada/utils": 0.14.0 "@rollup/plugin-typescript": ^11.0.0 rimraf: ^4.1.2 rollup: ^3.17.2 @@ -832,7 +832,7 @@ __metadata: rollup-plugin-cleanup: ^3.2.1 typescript: ^4.9.5 peerDependencies: - "@bandada/contracts": 0.13.0 + "@bandada/contracts": 0.14.0 "@nomiclabs/hardhat-ethers": ^2.0.0 "@semaphore-protocol/contracts": 3.4.0 ethers: ^5.4.7 @@ -840,7 +840,7 @@ __metadata: languageName: unknown linkType: soft -"@bandada/utils@0.13.0, @bandada/utils@workspace:libs/utils": +"@bandada/utils@0.14.0, @bandada/utils@workspace:libs/utils": version: 0.0.0-use.local resolution: "@bandada/utils@workspace:libs/utils" dependencies: @@ -7610,8 +7610,8 @@ __metadata: version: 0.0.0-use.local resolution: "api@workspace:apps/api" dependencies: - "@bandada/credentials": 0.13.0 - "@bandada/utils": 0.13.0 + "@bandada/credentials": 0.14.0 + "@bandada/utils": 0.14.0 "@ethersproject/hash": ^5.7.0 "@nestjs/cli": ^9.0.0 "@nestjs/common": ^9.0.0 @@ -9114,8 +9114,8 @@ __metadata: version: 0.0.0-use.local resolution: "client@workspace:apps/client" dependencies: - "@bandada/api-sdk": 0.13.0 - "@bandada/utils": 0.13.0 + "@bandada/api-sdk": 0.14.0 + "@bandada/utils": 0.14.0 "@chakra-ui/react": ^2.5.1 "@chakra-ui/theme-tools": ^2.0.16 "@emotion/react": ^11.10.6 @@ -9864,8 +9864,8 @@ __metadata: version: 0.0.0-use.local resolution: "dashboard@workspace:apps/dashboard" dependencies: - "@bandada/credentials": 0.13.0 - "@bandada/utils": 0.13.0 + "@bandada/credentials": 0.14.0 + "@bandada/utils": 0.14.0 "@chakra-ui/react": ^2.5.1 "@chakra-ui/theme-tools": ^2.0.16 "@emotion/react": ^11.10.6 From 5deaba31f2cc31bf4b6adcf2893d3c8c2c55a596 Mon Sep 17 00:00:00 2001 From: cedoor Date: Fri, 11 Aug 2023 11:42:12 +0200 Subject: [PATCH 3/3] refactor(client): add api-sdk lib to the client app re #260 --- apps/client/src/utils/api.ts | 76 ++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 apps/client/src/utils/api.ts diff --git a/apps/client/src/utils/api.ts b/apps/client/src/utils/api.ts new file mode 100644 index 00000000..ccdae015 --- /dev/null +++ b/apps/client/src/utils/api.ts @@ -0,0 +1,76 @@ +import { ApiSdk, GroupResponse, InviteResponse } from "@bandada/api-sdk" + +const api = new ApiSdk(import.meta.env.VITE_API_URL) + +export async function getInvite( + inviteCode: string +): Promise { + try { + return await api.getInvite(inviteCode) + } catch (error: any) { + console.error(error) + + if (error.response) { + alert(error.response.statusText) + } else { + alert("Some error occurred!") + } + + return null + } +} + +export async function getGroup(groupId: string): Promise { + try { + return await api.getGroup(groupId) + } catch (error: any) { + console.error(error) + + if (error.response) { + alert(error.response.statusText) + } else { + alert("Some error occurred!") + } + + return null + } +} + +export async function isGroupMember( + groupId: string, + memberId: string +): Promise { + try { + return await api.isGroupMember(groupId, memberId) + } catch (error: any) { + console.error(error) + + if (error.response) { + alert(error.response.statusText) + } else { + alert("Some error occurred!") + } + + return null + } +} + +export async function addMemberByInviteCode( + groupId: string, + memberId: string, + inviteCode: string +): Promise { + try { + return await api.addMemberByInviteCode(groupId, memberId, inviteCode) + } catch (error: any) { + console.error(error) + + if (error.response) { + alert(error.response.statusText) + } else { + alert("Some error occurred!") + } + + return null + } +}