Skip to content

Commit

Permalink
Merge pull request #549 from uooooo/feature/395-download-off-chain-gr…
Browse files Browse the repository at this point in the history
…oup-info

#395: Implement off-chain group information download
  • Loading branch information
vplasencia authored Sep 14, 2024
2 parents 7733dc1 + 4d49adf commit 11a0a56
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions apps/dashboard/src/pages/group.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
MenuButton,
MenuItem,
MenuList,
Spacer,
// Switch,
Text,
Tooltip,
Expand Down Expand Up @@ -243,6 +244,34 @@ ${memberIds.join("\n")}
const handleDeselectAll = () => {
setSelectedMembers([])
}

const handleDownload = async () => {
if (!_group) return

try {
const response = await bandadaApi.getGroup(_group.id)
if (response) {
const json = JSON.stringify(response, null, 2)
const blob = new Blob([json], { type: "application/json" })
const url = URL.createObjectURL(blob)
const a = document.createElement("a")
a.href = url
a.download = `${_group.name}.json`
document.body.appendChild(a)
a.click()
document.body.removeChild(a)
URL.revokeObjectURL(url)
}
} catch (error) {
console.error("Failed to download group data:", error)
toast({
title: "Error",
description: "Failed to download group data.",
status: "error",
duration: 3000
})
}
}
let credentialsId = ""
let credentialsCriteria = ""
const credentialsIds: string[] = []
Expand Down Expand Up @@ -479,6 +508,28 @@ ${memberIds.join("\n")}
)}
</Box>
)}
{_group.type === "off-chain" && isGroupAdmin && (
<Box
bgColor="balticSea.50"
p="25px 30px 25px 30px"
borderRadius="8px"
>
<Text fontSize="20px">Download group</Text>
<Flex align="center" mt="2">
<Text my="10px" fontWeight="400">
Get the group&apos;s data JSON format.
</Text>
<Spacer />
<Button
variant="solid"
colorScheme="tertiary"
onClick={handleDownload}
>
Download
</Button>
</Flex>
</Box>
)}
{/* {groupType === "off-chain" &&
!_group.credentials &&
isGroupAdmin && (
Expand Down

0 comments on commit 11a0a56

Please sign in to comment.