diff --git a/components/account/AccountActions.tsx b/components/account/AccountActions.tsx index d3f418df..ecc7437b 100644 --- a/components/account/AccountActions.tsx +++ b/components/account/AccountActions.tsx @@ -4,16 +4,23 @@ import Button, { LinkButton } from '../shared/Button' import DepositModal from '../modals/DepositModal' import WithdrawModal from '../modals/WithdrawModal' import mangoStore from '../../store/state' -import { DotsHorizontalIcon, TrashIcon, XIcon } from '@heroicons/react/solid' +import { + DotsHorizontalIcon, + PencilIcon, + TrashIcon, + XIcon, +} from '@heroicons/react/solid' import { useTranslation } from 'next-i18next' import IconDropMenu from '../shared/IconDropMenu' import CloseAccountModal from '../modals/CloseAccountModal' +import AccountNameModal from '../modals/AccountNameModal' const AccountActions = () => { const { t } = useTranslation(['common', 'close-account']) const { connected } = useWallet() const [showCloseAccountModal, setShowCloseAccountModal] = useState(false) const [showDepositModal, setShowDepositModal] = useState(false) + const [showEditAccountModal, setShowEditAccountModal] = useState(false) const [showWithdrawModal, setShowWithdrawModal] = useState(false) const handleCloseMangoAccount = async () => { @@ -48,6 +55,14 @@ const AccountActions = () => { {t('withdraw')} } large> + setShowEditAccountModal(true)} + > + + {t('edit-account')} + { onClose={() => setShowDepositModal(false)} /> ) : null} + {showEditAccountModal ? ( + setShowEditAccountModal(false)} + /> + ) : null} {showWithdrawModal ? ( { + const { t } = useTranslation('common') + const mangoAccount = mangoStore((s) => s.mangoAccount.current) + const [loading, setLoading] = useState(false) + const [name, setName] = useState(mangoAccount?.name || '') + + // This doesn't work yet... + const handleUpdateccountName = async () => { + const client = mangoStore.getState().client + const group = mangoStore.getState().group + if (!mangoAccount || !group) return + setLoading(true) + try { + const tx = await client.editMangoAccount(group, mangoAccount, name) + if (tx) { + setLoading(false) + onClose() + notify({ + title: t('account-updated'), + type: 'success', + txid: tx, + }) + } + } catch (e) { + setLoading(false) + notify({ + title: t('account-update-failed'), + type: 'error', + }) + console.log(e) + } + } + + return ( + +
+ {loading ? ( + + ) : ( +
+
+

{t('edit-account')}

+

{t('account-name-desc')}

+
+ +
+ )} +
+
+ ) +} + +export default AccountNameModal diff --git a/components/modals/CloseAccountModal.tsx b/components/modals/CloseAccountModal.tsx index 444f1b06..01387779 100644 --- a/components/modals/CloseAccountModal.tsx +++ b/components/modals/CloseAccountModal.tsx @@ -46,7 +46,7 @@ const CloseAccountModal = ({ isOpen, onClose }: ModalProps) => {

{t('close-account')}

-

Are you sure? Closing your account is irreversible.

+

{t('close-account-desc')}