add copy account address
This commit is contained in:
parent
f3dc836b0a
commit
4383fefd1f
|
@ -5,6 +5,7 @@ import WithdrawModal from '../modals/WithdrawModal'
|
||||||
import {
|
import {
|
||||||
ArrowDownTrayIcon,
|
ArrowDownTrayIcon,
|
||||||
ArrowUpTrayIcon,
|
ArrowUpTrayIcon,
|
||||||
|
DocumentDuplicateIcon,
|
||||||
EllipsisHorizontalIcon,
|
EllipsisHorizontalIcon,
|
||||||
PencilIcon,
|
PencilIcon,
|
||||||
TrashIcon,
|
TrashIcon,
|
||||||
|
@ -14,6 +15,8 @@ import IconDropMenu from '../shared/IconDropMenu'
|
||||||
import CloseAccountModal from '../modals/CloseAccountModal'
|
import CloseAccountModal from '../modals/CloseAccountModal'
|
||||||
import AccountNameModal from '../modals/AccountNameModal'
|
import AccountNameModal from '../modals/AccountNameModal'
|
||||||
import mangoStore from '@store/mangoStore'
|
import mangoStore from '@store/mangoStore'
|
||||||
|
import { copyToClipboard } from 'utils'
|
||||||
|
import { notify } from 'utils/notifications'
|
||||||
|
|
||||||
const AccountActions = () => {
|
const AccountActions = () => {
|
||||||
const { t } = useTranslation(['common', 'close-account'])
|
const { t } = useTranslation(['common', 'close-account'])
|
||||||
|
@ -23,9 +26,17 @@ const AccountActions = () => {
|
||||||
const [showEditAccountModal, setShowEditAccountModal] = useState(false)
|
const [showEditAccountModal, setShowEditAccountModal] = useState(false)
|
||||||
const [showWithdrawModal, setShowWithdrawModal] = useState(false)
|
const [showWithdrawModal, setShowWithdrawModal] = useState(false)
|
||||||
|
|
||||||
|
const handleCopyAddress = (address: string) => {
|
||||||
|
copyToClipboard(address)
|
||||||
|
notify({
|
||||||
|
title: t('copy-address-success'),
|
||||||
|
type: 'success',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="flex space-x-3">
|
<div className="flex items-center space-x-2 md:space-x-3">
|
||||||
<Button
|
<Button
|
||||||
className="flex items-center"
|
className="flex items-center"
|
||||||
disabled={!mangoAccount}
|
disabled={!mangoAccount}
|
||||||
|
@ -49,12 +60,22 @@ const AccountActions = () => {
|
||||||
icon={<EllipsisHorizontalIcon className="h-5 w-5" />}
|
icon={<EllipsisHorizontalIcon className="h-5 w-5" />}
|
||||||
large
|
large
|
||||||
>
|
>
|
||||||
|
<LinkButton
|
||||||
|
className="whitespace-nowrap"
|
||||||
|
disabled={!mangoAccount}
|
||||||
|
onClick={() =>
|
||||||
|
handleCopyAddress(mangoAccount!.publicKey.toString())
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<DocumentDuplicateIcon className="h-4 w-4" />
|
||||||
|
<span className="ml-2">{t('copy-address')}</span>
|
||||||
|
</LinkButton>
|
||||||
<LinkButton
|
<LinkButton
|
||||||
className="whitespace-nowrap"
|
className="whitespace-nowrap"
|
||||||
disabled={!mangoAccount}
|
disabled={!mangoAccount}
|
||||||
onClick={() => setShowEditAccountModal(true)}
|
onClick={() => setShowEditAccountModal(true)}
|
||||||
>
|
>
|
||||||
<PencilIcon className="h-5 w-5" />
|
<PencilIcon className="h-4 w-4" />
|
||||||
<span className="ml-2">{t('edit-account')}</span>
|
<span className="ml-2">{t('edit-account')}</span>
|
||||||
</LinkButton>
|
</LinkButton>
|
||||||
<LinkButton
|
<LinkButton
|
||||||
|
@ -62,7 +83,7 @@ const AccountActions = () => {
|
||||||
disabled={!mangoAccount}
|
disabled={!mangoAccount}
|
||||||
onClick={() => setShowCloseAccountModal(true)}
|
onClick={() => setShowCloseAccountModal(true)}
|
||||||
>
|
>
|
||||||
<TrashIcon className="h-5 w-5" />
|
<TrashIcon className="h-4 w-4" />
|
||||||
<span className="ml-2">{t('close-account')}</span>
|
<span className="ml-2">{t('close-account')}</span>
|
||||||
</LinkButton>
|
</LinkButton>
|
||||||
</IconDropMenu>
|
</IconDropMenu>
|
||||||
|
|
|
@ -18,10 +18,12 @@ import {
|
||||||
} from '../../utils/constants'
|
} from '../../utils/constants'
|
||||||
import useLocalStorageState from 'hooks/useLocalStorageState'
|
import useLocalStorageState from 'hooks/useLocalStorageState'
|
||||||
import { EXPLORERS } from 'pages/settings'
|
import { EXPLORERS } from 'pages/settings'
|
||||||
|
import { useTranslation } from 'next-i18next'
|
||||||
|
|
||||||
const setMangoStore = mangoStore.getState().set
|
const setMangoStore = mangoStore.getState().set
|
||||||
|
|
||||||
const NotificationList = () => {
|
const NotificationList = () => {
|
||||||
|
const { t } = useTranslation()
|
||||||
const notifications = mangoStore((s) => s.notifications)
|
const notifications = mangoStore((s) => s.notifications)
|
||||||
const walletTokens = mangoStore((s) => s.wallet.tokens)
|
const walletTokens = mangoStore((s) => s.wallet.tokens)
|
||||||
const notEnoughSoLMessage = 'Not enough SOL'
|
const notEnoughSoLMessage = 'Not enough SOL'
|
||||||
|
@ -99,7 +101,7 @@ const NotificationList = () => {
|
||||||
onClick={clearAll}
|
onClick={clearAll}
|
||||||
>
|
>
|
||||||
<XMarkIcon className="mr-1 h-3.5 w-3.5" />
|
<XMarkIcon className="mr-1 h-3.5 w-3.5" />
|
||||||
Clear All
|
{t('clear-all')}
|
||||||
</button>
|
</button>
|
||||||
) : null}
|
) : null}
|
||||||
{reversedNotifications.map((n) => (
|
{reversedNotifications.map((n) => (
|
||||||
|
|
|
@ -23,12 +23,15 @@
|
||||||
"borrow-value": "Borrow Value",
|
"borrow-value": "Borrow Value",
|
||||||
"buy": "Buy",
|
"buy": "Buy",
|
||||||
"cancel": "Cancel",
|
"cancel": "Cancel",
|
||||||
|
"clear-all": "Clear All",
|
||||||
"close-account": "Close Account",
|
"close-account": "Close Account",
|
||||||
"close-account-desc": "Are you sure? Closing your account is irreversible.",
|
"close-account-desc": "Are you sure? Closing your account is irreversible.",
|
||||||
"closing-account": "Closing your account...",
|
"closing-account": "Closing your account...",
|
||||||
"collateral-value": "Collateral Value",
|
"collateral-value": "Collateral Value",
|
||||||
"connect": "Connect",
|
"connect": "Connect",
|
||||||
"connect-helper": "Connect to get started",
|
"connect-helper": "Connect to get started",
|
||||||
|
"copy-address": "Copy Address",
|
||||||
|
"copy-address-success": "Copied Mango Account address",
|
||||||
"create-account": "Create Account",
|
"create-account": "Create Account",
|
||||||
"creating-account": "Creating Account...",
|
"creating-account": "Creating Account...",
|
||||||
"cumulative-interest-value": "Cumulative Interest Earned",
|
"cumulative-interest-value": "Cumulative Interest Earned",
|
||||||
|
|
|
@ -23,12 +23,15 @@
|
||||||
"borrow-value": "Borrow Value",
|
"borrow-value": "Borrow Value",
|
||||||
"buy": "Buy",
|
"buy": "Buy",
|
||||||
"cancel": "Cancel",
|
"cancel": "Cancel",
|
||||||
|
"clear-all": "Clear All",
|
||||||
"close-account": "Close Account",
|
"close-account": "Close Account",
|
||||||
"close-account-desc": "Are you sure? Closing your account is irreversible.",
|
"close-account-desc": "Are you sure? Closing your account is irreversible.",
|
||||||
"closing-account": "Closing your account...",
|
"closing-account": "Closing your account...",
|
||||||
"collateral-value": "Collateral Value",
|
"collateral-value": "Collateral Value",
|
||||||
"connect": "Connect",
|
"connect": "Connect",
|
||||||
"connect-helper": "Connect to get started",
|
"connect-helper": "Connect to get started",
|
||||||
|
"copy-address": "Copy Address",
|
||||||
|
"copy-address-success": "Copied Mango Account address",
|
||||||
"create-account": "Create Account",
|
"create-account": "Create Account",
|
||||||
"creating-account": "Creating Account...",
|
"creating-account": "Creating Account...",
|
||||||
"cumulative-interest-value": "Cumulative Interest Earned",
|
"cumulative-interest-value": "Cumulative Interest Earned",
|
||||||
|
|
|
@ -23,12 +23,15 @@
|
||||||
"borrow-value": "Borrow Value",
|
"borrow-value": "Borrow Value",
|
||||||
"buy": "Buy",
|
"buy": "Buy",
|
||||||
"cancel": "Cancel",
|
"cancel": "Cancel",
|
||||||
|
"clear-all": "Clear All",
|
||||||
"close-account": "Close Account",
|
"close-account": "Close Account",
|
||||||
"close-account-desc": "Are you sure? Closing your account is irreversible.",
|
"close-account-desc": "Are you sure? Closing your account is irreversible.",
|
||||||
"closing-account": "Closing your account...",
|
"closing-account": "Closing your account...",
|
||||||
"collateral-value": "Collateral Value",
|
"collateral-value": "Collateral Value",
|
||||||
"connect": "Connect",
|
"connect": "Connect",
|
||||||
"connect-helper": "Connect to get started",
|
"connect-helper": "Connect to get started",
|
||||||
|
"copy-address": "Copy Address",
|
||||||
|
"copy-address-success": "Copied Mango Account address",
|
||||||
"create-account": "Create Account",
|
"create-account": "Create Account",
|
||||||
"creating-account": "Creating Account...",
|
"creating-account": "Creating Account...",
|
||||||
"cumulative-interest-value": "Cumulative Interest Value",
|
"cumulative-interest-value": "Cumulative Interest Value",
|
||||||
|
|
|
@ -23,12 +23,15 @@
|
||||||
"borrow-value": "Borrow Value",
|
"borrow-value": "Borrow Value",
|
||||||
"buy": "Buy",
|
"buy": "Buy",
|
||||||
"cancel": "Cancel",
|
"cancel": "Cancel",
|
||||||
|
"clear-all": "Clear All",
|
||||||
"close-account": "Close Account",
|
"close-account": "Close Account",
|
||||||
"close-account-desc": "Are you sure? Closing your account is irreversible.",
|
"close-account-desc": "Are you sure? Closing your account is irreversible.",
|
||||||
"closing-account": "Closing your account...",
|
"closing-account": "Closing your account...",
|
||||||
"collateral-value": "Collateral Value",
|
"collateral-value": "Collateral Value",
|
||||||
"connect": "Connect",
|
"connect": "Connect",
|
||||||
"connect-helper": "Connect to get started",
|
"connect-helper": "Connect to get started",
|
||||||
|
"copy-address": "Copy Address",
|
||||||
|
"copy-address-success": "Copied Mango Account address",
|
||||||
"create-account": "Create Account",
|
"create-account": "Create Account",
|
||||||
"creating-account": "Creating Account...",
|
"creating-account": "Creating Account...",
|
||||||
"cumulative-interest-value": "Cumulative Interest Earned",
|
"cumulative-interest-value": "Cumulative Interest Earned",
|
||||||
|
|
|
@ -23,12 +23,15 @@
|
||||||
"borrow-value": "Borrow Value",
|
"borrow-value": "Borrow Value",
|
||||||
"buy": "Buy",
|
"buy": "Buy",
|
||||||
"cancel": "Cancel",
|
"cancel": "Cancel",
|
||||||
|
"clear-all": "Clear All",
|
||||||
"close-account": "Close Account",
|
"close-account": "Close Account",
|
||||||
"close-account-desc": "Are you sure? Closing your account is irreversible.",
|
"close-account-desc": "Are you sure? Closing your account is irreversible.",
|
||||||
"closing-account": "Closing your account...",
|
"closing-account": "Closing your account...",
|
||||||
"collateral-value": "Collateral Value",
|
"collateral-value": "Collateral Value",
|
||||||
"connect": "Connect",
|
"connect": "Connect",
|
||||||
"connect-helper": "Connect to get started",
|
"connect-helper": "Connect to get started",
|
||||||
|
"copy-address": "Copy Address",
|
||||||
|
"copy-address-success": "Copied Mango Account address",
|
||||||
"create-account": "Create Account",
|
"create-account": "Create Account",
|
||||||
"creating-account": "Creating Account...",
|
"creating-account": "Creating Account...",
|
||||||
"cumulative-interest-value": "Cumulative Interest Earned",
|
"cumulative-interest-value": "Cumulative Interest Earned",
|
||||||
|
|
|
@ -34,3 +34,12 @@ export function isEqual(obj1: any, obj2: any, keys: Array<string>) {
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const copyToClipboard = (copyThis: string) => {
|
||||||
|
const el = document.createElement('textarea')
|
||||||
|
el.value = copyThis.toString()
|
||||||
|
document.body.appendChild(el)
|
||||||
|
el.select()
|
||||||
|
document.execCommand('copy')
|
||||||
|
document.body.removeChild(el)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue