From d8ee1e2536047ce9b5d84b4ee87ff448a66441b8 Mon Sep 17 00:00:00 2001 From: Maksym Date: Tue, 13 Feb 2024 11:36:29 +0200 Subject: [PATCH] Export identity (#46) * Export identity * Update icon --- src/common/ProfileMenu.tsx | 34 +++++++++++++++++++++++----------- src/enums/icons.ts | 2 ++ 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/src/common/ProfileMenu.tsx b/src/common/ProfileMenu.tsx index 67ee827f..75b9abfc 100644 --- a/src/common/ProfileMenu.tsx +++ b/src/common/ProfileMenu.tsx @@ -8,15 +8,16 @@ import { Typography, useTheme, } from '@mui/material' -import { useState } from 'react' +import { useCallback, useState } from 'react' import { Link } from 'react-router-dom' +import { zkpSnap } from '@/api/clients' import { UserAvatar } from '@/common' import { config } from '@/config' import { BusEvents } from '@/enums' -import { bus, formatDid } from '@/helpers' +import { bus, ErrorHandler, formatDid } from '@/helpers' import { useAuth, useCopyToClipboard } from '@/hooks' -import { UiIcon, UiIconButton, UiTooltip } from '@/ui' +import { UiIcon, UiIconButton } from '@/ui' interface ProfileMenuProps { userDid: string @@ -27,6 +28,7 @@ export default function ProfileMenu({ userDid }: ProfileMenuProps) { const { logout } = useAuth() const { copy, isCopied } = useCopyToClipboard() const [anchorEl, setAnchorEl] = useState(null) + const [isExporting, setIsExporting] = useState(false) const menuItemSx: SxProps = { py: 2.5, px: 4 } @@ -38,6 +40,16 @@ export default function ProfileMenu({ userDid }: ProfileMenuProps) { } } + const exportIdentity = useCallback(async () => { + try { + setIsExporting(true) + await zkpSnap.exportIdentity() + } catch (error) { + ErrorHandler.process(error) + } + setIsExporting(false) + }, []) + return ( <> setAnchorEl(event.currentTarget)}> @@ -71,20 +83,20 @@ export default function ProfileMenu({ userDid }: ProfileMenuProps) { > {formatDid(userDid)} - - - - - + + + {/*TODO: Add handler*/} - + - + - QR login + + {isExporting ? 'Exporting...' : 'Export Identity'} +