mirror of
https://github.com/AtHeartEngineering/bandada.git
synced 2026-01-09 18:38:00 -05:00
chore: comment out dashboard group page api key section to avoid errors
n
This commit is contained in:
@@ -111,39 +111,41 @@ export async function createGroup(
|
||||
* @param group The group id.
|
||||
* @param memberId The group member id.
|
||||
*/
|
||||
export async function updateGroup(
|
||||
groupId: string,
|
||||
{ apiEnabled }: { apiEnabled: boolean }
|
||||
): Promise<Group | null> {
|
||||
try {
|
||||
const group = await request(`${API_URL}/groups/${groupId}`, {
|
||||
method: "PATCH",
|
||||
data: { apiEnabled }
|
||||
})
|
||||
// @todo needs refactoring to support the new logic.
|
||||
// export async function updateGroup(
|
||||
// groupId: string,
|
||||
// { apiEnabled }: { apiEnabled: boolean }
|
||||
// ): Promise<Group | null> {
|
||||
// try {
|
||||
// const group = await request(`${API_URL}/groups/${groupId}`, {
|
||||
// method: "PATCH",
|
||||
// data: { apiEnabled }
|
||||
// })
|
||||
|
||||
return { ...group, type: "off-chain" }
|
||||
} catch (error: any) {
|
||||
console.error(error)
|
||||
createAlert(error.response.data.message)
|
||||
return null
|
||||
}
|
||||
}
|
||||
// return { ...group, type: "off-chain" }
|
||||
// } catch (error: any) {
|
||||
// console.error(error)
|
||||
// createAlert(error.response.data.message)
|
||||
// return null
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* It generates a new API key.
|
||||
* @param group The group id.
|
||||
*/
|
||||
export async function generateApiKey(groupId: string): Promise<string | null> {
|
||||
try {
|
||||
return await request(`${API_URL}/groups/${groupId}/api-key`, {
|
||||
method: "PATCH"
|
||||
})
|
||||
} catch (error: any) {
|
||||
console.error(error)
|
||||
createAlert(error.response.data.message)
|
||||
return null
|
||||
}
|
||||
}
|
||||
// @todo needs refactoring to support the new logic.
|
||||
// export async function generateApiKey(groupId: string): Promise<string | null> {
|
||||
// try {
|
||||
// return await request(`${API_URL}/groups/${groupId}/api-key`, {
|
||||
// method: "PATCH"
|
||||
// })
|
||||
// } catch (error: any) {
|
||||
// console.error(error)
|
||||
// createAlert(error.response.data.message)
|
||||
// return null
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* It removes a group.
|
||||
|
||||
@@ -17,7 +17,7 @@ import {
|
||||
MenuButton,
|
||||
MenuItem,
|
||||
MenuList,
|
||||
Switch,
|
||||
// Switch,
|
||||
Text,
|
||||
Tooltip,
|
||||
useClipboard,
|
||||
@@ -49,7 +49,7 @@ export default function GroupPage(): JSX.Element {
|
||||
const toast = useToast()
|
||||
const { groupId, groupType } = useParams()
|
||||
const [_group, setGroup] = useState<Group | null>()
|
||||
const { hasCopied, setValue: setApiKey, onCopy } = useClipboard("")
|
||||
// const { hasCopied, setValue: setApiKey, onCopy } = useClipboard("")
|
||||
const { hasCopied: hasCopiedGroupId, onCopy: onCopyGroupId } = useClipboard(
|
||||
groupId || ""
|
||||
)
|
||||
@@ -77,27 +77,33 @@ export default function GroupPage(): JSX.Element {
|
||||
return
|
||||
}
|
||||
|
||||
setApiKey(group.apiKey || "")
|
||||
// @todo needs refactoring to support the new logic.
|
||||
// setApiKey(group.apiKey || "")
|
||||
setGroup(group)
|
||||
}
|
||||
})()
|
||||
}, [groupId, groupType, setApiKey])
|
||||
}, [
|
||||
groupId,
|
||||
groupType
|
||||
// setApiKey
|
||||
])
|
||||
|
||||
const onApiAccessToggle = useCallback(
|
||||
async (apiEnabled: boolean) => {
|
||||
const group = await bandadaApi.updateGroup(_group!.id as string, {
|
||||
apiEnabled
|
||||
})
|
||||
// const onApiAccessToggle = useCallback(
|
||||
// async (apiEnabled: boolean) => {
|
||||
// const group = await bandadaApi.updateGroup(_group!.id as string, {
|
||||
// apiEnabled
|
||||
// })
|
||||
|
||||
if (group === null) {
|
||||
return
|
||||
}
|
||||
// if (group === null) {
|
||||
// return
|
||||
// }
|
||||
|
||||
setApiKey(group.apiKey!)
|
||||
setGroup(group)
|
||||
},
|
||||
[_group, setApiKey]
|
||||
)
|
||||
// // @todo needs refactoring to support the new logic.
|
||||
// // setApiKey(group.apiKey!)
|
||||
// setGroup(group)
|
||||
// },
|
||||
// [_group, setApiKey]
|
||||
// )
|
||||
|
||||
const addMember = useCallback(
|
||||
(memberIds?: string[]) => {
|
||||
@@ -199,24 +205,24 @@ ${memberIds.join("\n")}
|
||||
navigate("/groups")
|
||||
}, [_group, navigate])
|
||||
|
||||
const generateApiKey = useCallback(async () => {
|
||||
if (
|
||||
!window.confirm("Are you sure you want to generate a new API key?")
|
||||
) {
|
||||
return
|
||||
}
|
||||
// const generateApiKey = useCallback(async () => {
|
||||
// if (
|
||||
// !window.confirm("Are you sure you want to generate a new API key?")
|
||||
// ) {
|
||||
// return
|
||||
// }
|
||||
|
||||
const apiKey = await bandadaApi.generateApiKey(_group!.id)
|
||||
// const apiKey = await bandadaApi.generateApiKey(_group!.id)
|
||||
|
||||
if (apiKey === null) {
|
||||
return
|
||||
}
|
||||
// if (apiKey === null) {
|
||||
// return
|
||||
// }
|
||||
|
||||
_group!.apiKey = apiKey
|
||||
// _group!.apiKey = apiKey
|
||||
|
||||
setApiKey(apiKey)
|
||||
setGroup({ ..._group! })
|
||||
}, [_group, setApiKey])
|
||||
// setApiKey(apiKey)
|
||||
// setGroup({ ..._group! })
|
||||
// }, [_group, setApiKey])
|
||||
|
||||
const toggleMemberSelection = (memberId: string) => {
|
||||
if (_selectedMembers.includes(memberId)) {
|
||||
@@ -398,7 +404,7 @@ ${memberIds.join("\n")}
|
||||
/>
|
||||
</Box>
|
||||
)}
|
||||
{groupType === "off-chain" &&
|
||||
{/* {groupType === "off-chain" &&
|
||||
!_group.credentials &&
|
||||
isGroupAdmin && (
|
||||
<Box
|
||||
@@ -476,7 +482,7 @@ ${memberIds.join("\n")}
|
||||
</>
|
||||
)}
|
||||
</Box>
|
||||
)}
|
||||
)} */}
|
||||
<Image src={image1} />
|
||||
{_group.type === "off-chain" && isGroupAdmin && (
|
||||
<Box
|
||||
|
||||
@@ -8,8 +8,8 @@ export type Group = {
|
||||
fingerprintDuration?: number
|
||||
members: string[]
|
||||
admin: string
|
||||
apiEnabled?: boolean
|
||||
apiKey?: string
|
||||
// apiEnabled?: boolean
|
||||
// apiKey?: string
|
||||
createdAt?: string
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user