diff --git a/packages/settings/src/ui/settings-ui-export-account-secret-key-sheet.tsx b/packages/settings/src/ui/settings-ui-export-account-secret-key-sheet.tsx new file mode 100644 index 00000000..63cf8f01 --- /dev/null +++ b/packages/settings/src/ui/settings-ui-export-account-secret-key-sheet.tsx @@ -0,0 +1,57 @@ +import type { Account } from '@workspace/db/account/account' +import { useAccountReadSecretKey } from '@workspace/db-react/use-account-read-secret-key' +import { useTranslation } from '@workspace/i18n' +import { Button } from '@workspace/ui/components/button' +import { UiBottomSheet } from '@workspace/ui/components/ui-bottom-sheet' +import { UiIcon } from '@workspace/ui/components/ui-icon' +import { UiTextCopyButton } from '@workspace/ui/components/ui-text-copy-button' +import { useState } from 'react' +import { SettingsUiExportConfirm } from './settings-ui-export-confirm.tsx' +import { SettingsUiMnemonicBlur } from './settings-ui-mnemonic-blur.tsx' + +export function SettingsUiExportAccountSecretKeySheet({ + account, + open, + setOpen, +}: { + account: Account + open: boolean + setOpen: (value: boolean) => void +}) { + const { t } = useTranslation('settings') + const [revealed, setRevealed] = useState(false) + const readSecretKeyMutation = useAccountReadSecretKey() + + return ( + $.exportSecretKeyCopyConfirmDescription)} + onOpenChange={(value) => setOpen(value)} + open={open} + title={t(($) => $.exportSecretKeyCopyConfirmTitle)} + > +
+ {readSecretKeyMutation?.data?.length ? ( +
+ +
+ + $.exportSecretKeyCopy)} + text={readSecretKeyMutation.data} + toast={t(($) => $.exportSecretKeyCopyCopied)} + /> +
+
+ ) : ( + readSecretKeyMutation.mutateAsync({ id: account.id })} + label={t(($) => $.exportSecretKeyShow)} + /> + )} +
+
+ ) +} diff --git a/packages/settings/src/ui/settings-ui-export-account-secret-key.tsx b/packages/settings/src/ui/settings-ui-export-account-secret-key.tsx index f7081367..8c21d3e0 100644 --- a/packages/settings/src/ui/settings-ui-export-account-secret-key.tsx +++ b/packages/settings/src/ui/settings-ui-export-account-secret-key.tsx @@ -1,57 +1,25 @@ import type { Account } from '@workspace/db/account/account' -import { useAccountReadSecretKey } from '@workspace/db-react/use-account-read-secret-key' import { useTranslation } from '@workspace/i18n' import { Button } from '@workspace/ui/components/button' -import { UiBottomSheet } from '@workspace/ui/components/ui-bottom-sheet' import { UiIcon } from '@workspace/ui/components/ui-icon' -import { UiTextCopyButton } from '@workspace/ui/components/ui-text-copy-button' -import { useState } from 'react' -import { SettingsUiExportConfirm } from './settings-ui-export-confirm.tsx' -import { SettingsUiMnemonicBlur } from './settings-ui-mnemonic-blur.tsx' +import { Fragment, useState } from 'react' +import { SettingsUiExportAccountSecretKeySheet } from './settings-ui-export-account-secret-key-sheet.tsx' export function SettingsUiExportAccountSecretKey({ account }: { account: Account }) { const { t } = useTranslation('settings') - const [revealed, setRevealed] = useState(false) - const readSecretKeyMutation = useAccountReadSecretKey() - + const [open, setOpen] = useState(false) return ( - $.exportSecretKeyCopyConfirmDescription)} - title={t(($) => $.exportSecretKeyCopyConfirmTitle)} - trigger={ - - } - > -
- {readSecretKeyMutation?.data?.length ? ( -
- -
- - $.exportSecretKeyCopy)} - text={readSecretKeyMutation.data} - toast={t(($) => $.exportSecretKeyCopyCopied)} - /> -
-
- ) : ( - readSecretKeyMutation.mutateAsync({ id: account.id })} - label={t(($) => $.exportSecretKeyShow)} - /> - )} -
-
+ + + + ) } diff --git a/packages/settings/src/ui/settings-ui-export-wallet-mnemonic-sheet.tsx b/packages/settings/src/ui/settings-ui-export-wallet-mnemonic-sheet.tsx new file mode 100644 index 00000000..d84be49a --- /dev/null +++ b/packages/settings/src/ui/settings-ui-export-wallet-mnemonic-sheet.tsx @@ -0,0 +1,57 @@ +import type { Wallet } from '@workspace/db/wallet/wallet' +import { useWalletReadMnemonic } from '@workspace/db-react/use-wallet-read-mnemonic' +import { useTranslation } from '@workspace/i18n' +import { Button } from '@workspace/ui/components/button' +import { UiBottomSheet } from '@workspace/ui/components/ui-bottom-sheet' +import { UiIcon } from '@workspace/ui/components/ui-icon' +import { UiTextCopyButton } from '@workspace/ui/components/ui-text-copy-button' +import { useState } from 'react' +import { SettingsUiExportConfirm } from './settings-ui-export-confirm.tsx' +import { SettingsUiMnemonicBlur } from './settings-ui-mnemonic-blur.tsx' + +export function SettingsUiExportWalletMnemonicSheet({ + wallet, + open, + setOpen, +}: { + wallet: Wallet + open: boolean + setOpen: (value: boolean) => void +}) { + const { t } = useTranslation('settings') + const [revealed, setRevealed] = useState(false) + const readMnemonicMutation = useWalletReadMnemonic() + + return ( + $.exportMnemonicCopyConfirmDescription)} + onOpenChange={(value) => setOpen(value)} + open={open} + title={t(($) => $.exportMnemonicCopyConfirmTitle)} + > +
+ {readMnemonicMutation.data?.length ? ( +
+ +
+ + $.exportMnemonicCopy)} + text={readMnemonicMutation.data} + toast={t(($) => $.exportMnemonicCopyCopied)} + /> +
+
+ ) : ( + readMnemonicMutation.mutateAsync({ id: wallet.id })} + label={t(($) => $.exportMnemonicShow)} + /> + )} +
+
+ ) +} diff --git a/packages/settings/src/ui/settings-ui-export-wallet-mnemonic.tsx b/packages/settings/src/ui/settings-ui-export-wallet-mnemonic.tsx index 7a1ed0ad..cdd5c4d1 100644 --- a/packages/settings/src/ui/settings-ui-export-wallet-mnemonic.tsx +++ b/packages/settings/src/ui/settings-ui-export-wallet-mnemonic.tsx @@ -1,52 +1,25 @@ import type { Wallet } from '@workspace/db/wallet/wallet' -import { useWalletReadMnemonic } from '@workspace/db-react/use-wallet-read-mnemonic' import { useTranslation } from '@workspace/i18n' import { Button } from '@workspace/ui/components/button' -import { UiBottomSheet } from '@workspace/ui/components/ui-bottom-sheet' import { UiIcon } from '@workspace/ui/components/ui-icon' -import { UiTextCopyButton } from '@workspace/ui/components/ui-text-copy-button' -import { useState } from 'react' -import { SettingsUiExportConfirm } from './settings-ui-export-confirm.tsx' -import { SettingsUiMnemonicBlur } from './settings-ui-mnemonic-blur.tsx' +import { Fragment, useState } from 'react' +import { SettingsUiExportWalletMnemonicSheet } from './settings-ui-export-wallet-mnemonic-sheet.tsx' export function SettingsUiExportWalletMnemonic({ wallet }: { wallet: Wallet }) { const { t } = useTranslation('settings') - const [revealed, setRevealed] = useState(false) - const readMnemonicMutation = useWalletReadMnemonic() + const [open, setOpen] = useState(false) return ( - $.exportMnemonicCopyConfirmDescription)} - title={t(($) => $.exportMnemonicCopyConfirmTitle)} - trigger={ - - } - > -
- {readMnemonicMutation.data?.length ? ( -
- -
- - $.exportMnemonicCopy)} - text={readMnemonicMutation.data} - toast={t(($) => $.exportMnemonicCopyCopied)} - /> -
-
- ) : ( - readMnemonicMutation.mutateAsync({ id: wallet.id })} - label={t(($) => $.exportMnemonicShow)} - /> - )} -
-
+ + + + ) } diff --git a/packages/ui/src/components/ui-bottom-sheet.tsx b/packages/ui/src/components/ui-bottom-sheet.tsx index 8f8a7eb5..3d1cba05 100644 --- a/packages/ui/src/components/ui-bottom-sheet.tsx +++ b/packages/ui/src/components/ui-bottom-sheet.tsx @@ -1,21 +1,19 @@ -import type { ReactNode } from 'react' +import type { ComponentProps, ReactNode } from 'react' -import { Sheet, SheetContent, SheetDescription, SheetHeader, SheetTitle, SheetTrigger } from './sheet.tsx' +import { Sheet, SheetContent, SheetDescription, SheetHeader, SheetTitle } from './sheet.tsx' export function UiBottomSheet({ children, description, title, - trigger, -}: { + ...props +}: ComponentProps & { children: ReactNode description: ReactNode title: ReactNode - trigger: ReactNode }) { return ( - - {trigger} + {title}