diff --git a/apps/dashboard/src/pages/group.tsx b/apps/dashboard/src/pages/group.tsx index cb2a58c7..504e90ac 100644 --- a/apps/dashboard/src/pages/group.tsx +++ b/apps/dashboard/src/pages/group.tsx @@ -17,6 +17,7 @@ import { MenuButton, MenuItem, MenuList, + Spacer, // Switch, Text, Tooltip, @@ -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[] = [] @@ -479,6 +508,28 @@ ${memberIds.join("\n")} )} )} + {_group.type === "off-chain" && isGroupAdmin && ( + + Download group + + + Get the group's data in JSON format. + + + + + + )} {/* {groupType === "off-chain" && !_group.credentials && isGroupAdmin && (