Skip to content

Commit

Permalink
refactor(bandadaapi.ts): refined the function call of creatAlert
Browse files Browse the repository at this point in the history
Changed the function parameter of createAlert() to only accept a string which has the error
message, and changed all the arguments in bandadaAPI.ts

396
  • Loading branch information
code-Gambler committed Feb 19, 2024
1 parent b1b465f commit b3b176b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
34 changes: 17 additions & 17 deletions apps/dashboard/src/api/bandadaAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export async function generateMagicLink(
return (clientUrl || CLIENT_INVITES_URL).replace("\\", code)
} catch (error: any) {
console.error(error)
createAlert(error)
createAlert(error.response.data.message)
return null
}
}
Expand All @@ -50,7 +50,7 @@ export async function getGroups(adminId: string): Promise<Group[] | null> {
}))
} catch (error: any) {
console.error(error)
createAlert(error)
createAlert(error.response.data.message)
return null
}
}
Expand All @@ -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)
createAlert(error.response.data.message)
return null
}
}
Expand Down Expand Up @@ -101,7 +101,7 @@ export async function createGroup(
return { ...group, type: "off-chain" }
} catch (error: any) {
console.error(error)
createAlert(error.response.data)
createAlert(error.response.data.message)
return null
}
}
Expand All @@ -124,7 +124,7 @@ export async function updateGroup(
return { ...group, type: "off-chain" }
} catch (error: any) {
console.error(error)
createAlert(error.response.data)
createAlert(error.response.data.message)
return null
}
}
Expand All @@ -140,7 +140,7 @@ export async function generateApiKey(groupId: string): Promise<string | null> {
})
} catch (error: any) {
console.error(error)
createAlert(error.response.data)
createAlert(error.response.data.message)
return null
}
}
Expand All @@ -156,7 +156,7 @@ export async function removeGroup(groupId: string): Promise<void | null> {
})
} catch (error: any) {
console.error(error)
createAlert(error.response.data)
createAlert(error.response.data.message)
return null
}
}
Expand Down Expand Up @@ -189,7 +189,7 @@ export async function setOAuthState(
})
} catch (error: any) {
console.error(error)
createAlert(error.response.data)
createAlert(error.response.data.message)
return null
}
}
Expand All @@ -213,7 +213,7 @@ export async function addMemberByCredentials(
})
} catch (error: any) {
console.error(error)
createAlert(error.response.data)
createAlert(error.response.data.message)
return null
}
}
Expand All @@ -233,7 +233,7 @@ export async function addMember(
})
} catch (error: any) {
console.error(error)
createAlert(error.response.data)
createAlert(error.response.data.message)
return null
}
}
Expand All @@ -259,7 +259,7 @@ export async function addMembers(
})
} catch (error: any) {
console.error(error)
createAlert(error.response.data)
createAlert(error.response.data.message)
return null
}
}
Expand All @@ -279,7 +279,7 @@ export async function removeMember(
})
} catch (error: any) {
console.error(error)
createAlert(error.response.data)
createAlert(error.response.data.message)
return null
}
}
Expand All @@ -305,7 +305,7 @@ export async function removeMembers(
})
} catch (error: any) {
console.error(error)
createAlert(error.response.data)
createAlert(error.response.data.message)
return null
}
}
Expand All @@ -321,7 +321,7 @@ export async function getNonce(): Promise<string | null> {
})
} catch (error: any) {
console.error(error)
createAlert(error.response.data)
createAlert(error.response.data.message)
return null
}
}
Expand Down Expand Up @@ -349,7 +349,7 @@ export async function signIn({
})
} catch (error: any) {
console.error(error)
createAlert(error.response.data)
createAlert(error.response.data.message)
return null
}
}
Expand All @@ -364,7 +364,7 @@ export async function logOut(): Promise<void | null> {
})
} catch (error: any) {
console.error(error)
createAlert(error.response.data)
createAlert(error.response.data.message)
return null
}
}
Expand All @@ -380,7 +380,7 @@ export async function isLoggedIn(): Promise<null | boolean> {
})
} catch (error: any) {
console.error(error)
createAlert(error.response.data)
createAlert(error.response.data.message)
return null
}
}
6 changes: 3 additions & 3 deletions apps/dashboard/src/utils/createAlert.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export default function createAlert(data: { message: string; }) {
if (data.message){
alert(data.message);
export default function createAlert(message: string) {
if (message){
alert(message);
}else{
alert("Some error occurred!");
}
Expand Down

0 comments on commit b3b176b

Please sign in to comment.