Skip to content

Commit

Permalink
#395: Implement off-chain group information download
Browse files Browse the repository at this point in the history
  • Loading branch information
uooooo committed Sep 13, 2024
1 parent 7733dc1 commit 7b345b8
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's data in 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 7b345b8

Please sign in to comment.