refactor(bandadaapi.ts): provided the user with more information on the error within the dashboard

created a util function creatAlert and used it inside bandadaAPI.ts whenever it needed to create an
alert

396
This commit is contained in:
Steven
2024-02-19 17:15:27 -05:00
parent 088d84ed42
commit c29d122ea1
2 changed files with 19 additions and 19 deletions

View File

@@ -1,7 +1,7 @@
import { request } from "@bandada/utils"
import { SiweMessage } from "siwe"
import { Group } from "../types"
import { createAlert } from "../utils/createAlert"
import createAlert from "../utils/createAlert"
const API_URL = import.meta.env.VITE_API_URL
const CLIENT_INVITES_URL = import.meta.env.VITE_CLIENT_INVITES_URL
@@ -30,7 +30,7 @@ export async function generateMagicLink(
return (clientUrl || CLIENT_INVITES_URL).replace("\\", code)
} catch (error: any) {
console.error(error)
createAlert(error.response)
createAlert(error)
return null
}
}
@@ -50,7 +50,7 @@ export async function getGroups(adminId: string): Promise<Group[] | null> {
}))
} catch (error: any) {
console.error(error)
createAlert(error.response)
createAlert(error)
return null
}
}
@@ -67,7 +67,7 @@ export async function getGroup(groupId: string): Promise<Group | null> {
return { ...group, type: "off-chain" }
} catch (error: any) {
console.error(error)
createAlert(error.response)
createAlert(error)
return null
}
}
@@ -101,7 +101,7 @@ export async function createGroup(
return { ...group, type: "off-chain" }
} catch (error: any) {
console.error(error)
createAlert(error.response)
createAlert(error)
return null
}
}
@@ -124,7 +124,7 @@ export async function updateGroup(
return { ...group, type: "off-chain" }
} catch (error: any) {
console.error(error)
createAlert(error.response)
createAlert(error)
return null
}
}
@@ -140,7 +140,7 @@ export async function generateApiKey(groupId: string): Promise<string | null> {
})
} catch (error: any) {
console.error(error)
createAlert(error.response)
createAlert(error)
return null
}
}
@@ -156,7 +156,7 @@ export async function removeGroup(groupId: string): Promise<void | null> {
})
} catch (error: any) {
console.error(error)
createAlert(error.response)
createAlert(error)
return null
}
}
@@ -189,7 +189,7 @@ export async function setOAuthState(
})
} catch (error: any) {
console.error(error)
createAlert(error.response)
createAlert(error)
return null
}
}
@@ -213,7 +213,7 @@ export async function addMemberByCredentials(
})
} catch (error: any) {
console.error(error)
createAlert(error.response)
createAlert(error)
return null
}
}
@@ -233,7 +233,7 @@ export async function addMember(
})
} catch (error: any) {
console.error(error)
createAlert(error.response)
createAlert(error)
return null
}
}
@@ -259,7 +259,7 @@ export async function addMembers(
})
} catch (error: any) {
console.error(error)
createAlert(error.response)
createAlert(error)
return null
}
}
@@ -279,7 +279,7 @@ export async function removeMember(
})
} catch (error: any) {
console.error(error)
createAlert(error.response)
createAlert(error)
return null
}
}
@@ -305,7 +305,7 @@ export async function removeMembers(
})
} catch (error: any) {
console.error(error)
createAlert(error.response)
createAlert(error)
return null
}
}
@@ -321,7 +321,7 @@ export async function getNonce(): Promise<string | null> {
})
} catch (error: any) {
console.error(error)
createAlert(error.response)
createAlert(error)
return null
}
}
@@ -349,7 +349,7 @@ export async function signIn({
})
} catch (error: any) {
console.error(error)
createAlert(error.response)
createAlert(error)
return null
}
}
@@ -364,7 +364,7 @@ export async function logOut(): Promise<void | null> {
})
} catch (error: any) {
console.error(error)
createAlert(error.response)
createAlert(error)
return null
}
}
@@ -380,7 +380,7 @@ export async function isLoggedIn(): Promise<null | boolean> {
})
} catch (error: any) {
console.error(error)
createAlert(error.response)
createAlert(error)
return null
}
}

View File

@@ -1,4 +1,4 @@
export default function capitalize(data: { message: string; }) {
export default function createAlert(data: { message: string; }) {
if (data.message){
alert(data.message);
}else{