Skip to content

Commit

Permalink
Merge pull request #464 from bandada-infra/ref/dashboard
Browse files Browse the repository at this point in the history
Fix API Key component not working properly
  • Loading branch information
vplasencia authored Mar 31, 2024
2 parents 8233812 + 2e77a40 commit 9086474
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions apps/dashboard/src/components/api-key.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useEffect, useState } from "react"
import { useCallback, useEffect, useState } from "react"
import {
Box,
Flex,
Expand Down Expand Up @@ -26,7 +26,7 @@ export default function ApiKeyComponent({
const { onCopy } = useClipboard(apiKey)
const toast = useToast()

useEffect(() => {
const getAdminInfo = useCallback(async () => {
getAdmin(adminId).then((admin) => {
if (admin) {
setAdmin(admin)
Expand All @@ -36,6 +36,10 @@ export default function ApiKeyComponent({
})
}, [adminId])

useEffect(() => {
getAdminInfo()
}, [getAdminInfo])

useEffect(() => {
if (isCopied) {
const timer = setTimeout(() => {
Expand Down Expand Up @@ -91,7 +95,7 @@ export default function ApiKeyComponent({
"Successfully refreshed",
"success"
)
setApiKey(newApiKey)
getAdminInfo()
}
}
}
Expand Down Expand Up @@ -132,9 +136,8 @@ export default function ApiKeyComponent({
? "API key has been enabled."
: "API key has been disabled."
}

getAdminInfo()
showToast(toastTitle, toastDescription, "success")
setIsEnabled((prevState) => !prevState)
}
}

Expand Down

0 comments on commit 9086474

Please sign in to comment.