import { ModalProps } from '../../types/modal' import Modal from '../shared/Modal' import mangoStore from '@store/mangoStore' import { notify } from '../../utils/notifications' import Button from '../shared/Button' import { useTranslation } from 'next-i18next' import { ChangeEvent, useState } from 'react' import BounceLoader from '../shared/BounceLoader' import Input from '../forms/Input' import Label from '../forms/Label' import useMangoAccount from 'hooks/useMangoAccount' const AccountNameModal = ({ isOpen, onClose }: ModalProps) => { const { t } = useTranslation('common') const { mangoAccount } = useMangoAccount() const [loading, setLoading] = useState(false) const [name, setName] = useState(mangoAccount?.name || '') const handleUpdateccountName = async () => { const client = mangoStore.getState().client const group = mangoStore.getState().group const actions = mangoStore.getState().actions if (!mangoAccount || !group) return setLoading(true) try { const tx = await client.editMangoAccount(group, mangoAccount, name) setLoading(false) onClose() notify({ title: t('account-update-success'), type: 'success', txid: tx, }) await actions.reloadMangoAccount() } catch (e: any) { setLoading(false) notify({ title: t('account-update-failed'), txid: e?.txid, type: 'error', }) console.error(e) } } return (
{loading ? ( ) : (

{t('edit-account')}

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

)}
) } export default AccountNameModal