2021-11-08 08:42:55 -08:00
|
|
|
import React, { useCallback, useEffect, useState } from 'react'
|
User account page (#22)
* layout, overview, start on assets, borrows and open orders
* trade history, sortable data hook for tables, borrow page
* handle deposit and withdraw buttons
* borrow modal ui and integration + settle borrow for individual assets
* in orders balance to asset table and totals, responsive css, new connected wallet button + small tweaks
* account switch/creation flow
* accounts modal, update to usebalances hook
* handle settle, deposit before settle, save last account
* disable borrow/withdraw button when no account
2021-06-05 07:11:44 -07:00
|
|
|
import {
|
|
|
|
CurrencyDollarIcon,
|
2021-07-23 07:07:05 -07:00
|
|
|
DuplicateIcon,
|
2021-12-07 20:00:02 -08:00
|
|
|
ExclamationCircleIcon,
|
User account page (#22)
* layout, overview, start on assets, borrows and open orders
* trade history, sortable data hook for tables, borrow page
* handle deposit and withdraw buttons
* borrow modal ui and integration + settle borrow for individual assets
* in orders balance to asset table and totals, responsive css, new connected wallet button + small tweaks
* account switch/creation flow
* accounts modal, update to usebalances hook
* handle settle, deposit before settle, save last account
* disable borrow/withdraw button when no account
2021-06-05 07:11:44 -07:00
|
|
|
ExternalLinkIcon,
|
|
|
|
LinkIcon,
|
2021-07-23 07:07:05 -07:00
|
|
|
PencilIcon,
|
2021-11-08 08:42:55 -08:00
|
|
|
TrashIcon,
|
User account page (#22)
* layout, overview, start on assets, borrows and open orders
* trade history, sortable data hook for tables, borrow page
* handle deposit and withdraw buttons
* borrow modal ui and integration + settle borrow for individual assets
* in orders balance to asset table and totals, responsive css, new connected wallet button + small tweaks
* account switch/creation flow
* accounts modal, update to usebalances hook
* handle settle, deposit before settle, save last account
* disable borrow/withdraw button when no account
2021-06-05 07:11:44 -07:00
|
|
|
} from '@heroicons/react/outline'
|
2021-11-14 10:37:02 -08:00
|
|
|
import useMangoStore, { serumProgramId } from '../stores/useMangoStore'
|
|
|
|
import { copyToClipboard } from '../utils'
|
|
|
|
import PageBodyContainer from '../components/PageBodyContainer'
|
|
|
|
import TopBar from '../components/TopBar'
|
|
|
|
import AccountOrders from '../components/account_page/AccountOrders'
|
|
|
|
import AccountHistory from '../components/account_page/AccountHistory'
|
|
|
|
import AccountsModal from '../components/AccountsModal'
|
|
|
|
import AccountOverview from '../components/account_page/AccountOverview'
|
|
|
|
import AccountInterest from '../components/account_page/AccountInterest'
|
|
|
|
import AccountFunding from '../components/account_page/AccountFunding'
|
2021-12-23 15:05:44 -08:00
|
|
|
import AccountPerformance from '../components/account_page/AccountPerformance'
|
2021-11-14 10:37:02 -08:00
|
|
|
import AccountNameModal from '../components/AccountNameModal'
|
|
|
|
import Button from '../components/Button'
|
|
|
|
import EmptyState from '../components/EmptyState'
|
|
|
|
import Loading from '../components/Loading'
|
|
|
|
import Swipeable from '../components/mobile/Swipeable'
|
|
|
|
import Tabs from '../components/Tabs'
|
|
|
|
import { useViewport } from '../hooks/useViewport'
|
|
|
|
import { breakpoints } from '../components/TradePageGrid'
|
2021-10-20 05:42:40 -07:00
|
|
|
import { serverSideTranslations } from 'next-i18next/serverSideTranslations'
|
|
|
|
import { useTranslation } from 'next-i18next'
|
2021-11-14 10:37:02 -08:00
|
|
|
import Select from '../components/Select'
|
2021-11-09 10:17:03 -08:00
|
|
|
import { useRouter } from 'next/router'
|
|
|
|
import { PublicKey } from '@solana/web3.js'
|
2021-11-08 08:42:55 -08:00
|
|
|
import CloseAccountModal from '../components/CloseAccountModal'
|
2022-01-16 15:16:47 -08:00
|
|
|
import {
|
|
|
|
actionsSelector,
|
|
|
|
mangoAccountSelector,
|
|
|
|
mangoGroupSelector,
|
|
|
|
walletConnectedSelector,
|
|
|
|
} from '../stores/selectors'
|
2021-10-20 05:42:40 -07:00
|
|
|
|
2021-12-26 06:28:46 -08:00
|
|
|
export async function getStaticProps({ locale }) {
|
2021-10-20 05:42:40 -07:00
|
|
|
return {
|
|
|
|
props: {
|
|
|
|
...(await serverSideTranslations(locale, ['common'])),
|
|
|
|
// Will be passed to the page component as props
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
User account page (#22)
* layout, overview, start on assets, borrows and open orders
* trade history, sortable data hook for tables, borrow page
* handle deposit and withdraw buttons
* borrow modal ui and integration + settle borrow for individual assets
* in orders balance to asset table and totals, responsive css, new connected wallet button + small tweaks
* account switch/creation flow
* accounts modal, update to usebalances hook
* handle settle, deposit before settle, save last account
* disable borrow/withdraw button when no account
2021-06-05 07:11:44 -07:00
|
|
|
|
2022-01-16 09:12:59 -08:00
|
|
|
const TABS = [
|
|
|
|
'Portfolio',
|
|
|
|
'Orders',
|
|
|
|
'History',
|
|
|
|
'Interest',
|
|
|
|
'Funding',
|
2022-01-17 09:25:04 -08:00
|
|
|
'Performance',// TOTRANSLATE
|
2022-01-16 09:12:59 -08:00
|
|
|
]
|
User account page (#22)
* layout, overview, start on assets, borrows and open orders
* trade history, sortable data hook for tables, borrow page
* handle deposit and withdraw buttons
* borrow modal ui and integration + settle borrow for individual assets
* in orders balance to asset table and totals, responsive css, new connected wallet button + small tweaks
* account switch/creation flow
* accounts modal, update to usebalances hook
* handle settle, deposit before settle, save last account
* disable borrow/withdraw button when no account
2021-06-05 07:11:44 -07:00
|
|
|
|
|
|
|
export default function Account() {
|
2021-10-20 05:42:40 -07:00
|
|
|
const { t } = useTranslation('common')
|
User account page (#22)
* layout, overview, start on assets, borrows and open orders
* trade history, sortable data hook for tables, borrow page
* handle deposit and withdraw buttons
* borrow modal ui and integration + settle borrow for individual assets
* in orders balance to asset table and totals, responsive css, new connected wallet button + small tweaks
* account switch/creation flow
* accounts modal, update to usebalances hook
* handle settle, deposit before settle, save last account
* disable borrow/withdraw button when no account
2021-06-05 07:11:44 -07:00
|
|
|
const [showAccountsModal, setShowAccountsModal] = useState(false)
|
2021-07-23 07:07:05 -07:00
|
|
|
const [showNameModal, setShowNameModal] = useState(false)
|
2021-11-08 08:42:55 -08:00
|
|
|
const [showCloseAccountModal, setShowCloseAccountModal] = useState(false)
|
2021-07-23 07:07:05 -07:00
|
|
|
const [isCopied, setIsCopied] = useState(false)
|
2021-11-09 10:17:03 -08:00
|
|
|
const [resetOnLeave, setResetOnLeave] = useState(false)
|
2022-01-16 15:16:47 -08:00
|
|
|
const connected = useMangoStore(walletConnectedSelector)
|
|
|
|
const mangoAccount = useMangoStore(mangoAccountSelector)
|
2021-11-09 10:17:03 -08:00
|
|
|
const mangoClient = useMangoStore((s) => s.connection.client)
|
2022-01-16 15:16:47 -08:00
|
|
|
const mangoGroup = useMangoStore(mangoGroupSelector)
|
2021-07-22 04:34:03 -07:00
|
|
|
const wallet = useMangoStore((s) => s.wallet.current)
|
2021-08-20 06:17:02 -07:00
|
|
|
const isLoading = useMangoStore((s) => s.selectedMangoAccount.initialLoad)
|
2022-01-16 15:16:47 -08:00
|
|
|
const actions = useMangoStore(actionsSelector)
|
2021-11-09 10:17:03 -08:00
|
|
|
const setMangoStore = useMangoStore((s) => s.set)
|
2021-09-19 17:36:02 -07:00
|
|
|
const [viewIndex, setViewIndex] = useState(0)
|
2021-09-19 20:21:55 -07:00
|
|
|
const [activeTab, setActiveTab] = useState(TABS[0])
|
|
|
|
const { width } = useViewport()
|
|
|
|
const isMobile = width ? width < breakpoints.sm : false
|
2021-11-09 10:17:03 -08:00
|
|
|
const router = useRouter()
|
|
|
|
const { pubkey } = router.query
|
User account page (#22)
* layout, overview, start on assets, borrows and open orders
* trade history, sortable data hook for tables, borrow page
* handle deposit and withdraw buttons
* borrow modal ui and integration + settle borrow for individual assets
* in orders balance to asset table and totals, responsive css, new connected wallet button + small tweaks
* account switch/creation flow
* accounts modal, update to usebalances hook
* handle settle, deposit before settle, save last account
* disable borrow/withdraw button when no account
2021-06-05 07:11:44 -07:00
|
|
|
|
|
|
|
const handleCloseAccounts = useCallback(() => {
|
|
|
|
setShowAccountsModal(false)
|
|
|
|
}, [])
|
|
|
|
|
2021-07-23 07:07:05 -07:00
|
|
|
const handleCopyPublicKey = (code) => {
|
|
|
|
setIsCopied(true)
|
|
|
|
copyToClipboard(code)
|
|
|
|
}
|
|
|
|
const handleCloseNameModal = useCallback(() => {
|
|
|
|
setShowNameModal(false)
|
|
|
|
}, [])
|
2021-11-08 08:42:55 -08:00
|
|
|
const handleCloseCloseAccountModal = useCallback(() => {
|
|
|
|
setShowCloseAccountModal(false)
|
|
|
|
}, [])
|
2021-07-23 07:07:05 -07:00
|
|
|
|
2021-11-09 10:17:03 -08:00
|
|
|
useEffect(() => {
|
|
|
|
async function loadUnownedMangoAccount() {
|
|
|
|
try {
|
2021-11-14 10:37:02 -08:00
|
|
|
const unownedMangoAccountPubkey = new PublicKey(pubkey)
|
2021-11-09 10:17:03 -08:00
|
|
|
if (mangoGroup) {
|
|
|
|
const unOwnedMangoAccount = await mangoClient.getMangoAccount(
|
|
|
|
unownedMangoAccountPubkey,
|
|
|
|
serumProgramId
|
|
|
|
)
|
|
|
|
setMangoStore((state) => {
|
|
|
|
state.selectedMangoAccount.current = unOwnedMangoAccount
|
|
|
|
})
|
|
|
|
actions.fetchTradeHistory()
|
|
|
|
setResetOnLeave(true)
|
|
|
|
}
|
|
|
|
} catch (error) {
|
|
|
|
router.push('/account')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-18 05:56:11 -08:00
|
|
|
if (pubkey) {
|
|
|
|
loadUnownedMangoAccount()
|
|
|
|
}
|
2021-11-09 10:17:03 -08:00
|
|
|
}, [pubkey, mangoGroup])
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
if (connected) {
|
|
|
|
router.push('/account')
|
|
|
|
}
|
|
|
|
}, [connected])
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
const handleRouteChange = () => {
|
|
|
|
if (resetOnLeave) {
|
|
|
|
setMangoStore((state) => {
|
|
|
|
state.selectedMangoAccount.current = undefined
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
router.events.on('routeChangeStart', handleRouteChange)
|
|
|
|
return () => {
|
|
|
|
router.events.off('routeChangeStart', handleRouteChange)
|
|
|
|
}
|
|
|
|
}, [resetOnLeave])
|
|
|
|
|
2021-07-23 07:07:05 -07:00
|
|
|
useEffect(() => {
|
|
|
|
if (isCopied) {
|
|
|
|
const timer = setTimeout(() => {
|
|
|
|
setIsCopied(false)
|
|
|
|
}, 1500)
|
|
|
|
return () => clearTimeout(timer)
|
|
|
|
}
|
|
|
|
}, [isCopied])
|
2021-07-25 06:54:25 -07:00
|
|
|
|
2021-09-19 17:36:02 -07:00
|
|
|
const handleChangeViewIndex = (index) => {
|
|
|
|
setViewIndex(index)
|
|
|
|
}
|
|
|
|
|
2021-09-19 20:21:55 -07:00
|
|
|
const handleTabChange = (tabName) => {
|
|
|
|
setActiveTab(tabName)
|
|
|
|
}
|
|
|
|
|
User account page (#22)
* layout, overview, start on assets, borrows and open orders
* trade history, sortable data hook for tables, borrow page
* handle deposit and withdraw buttons
* borrow modal ui and integration + settle borrow for individual assets
* in orders balance to asset table and totals, responsive css, new connected wallet button + small tweaks
* account switch/creation flow
* accounts modal, update to usebalances hook
* handle settle, deposit before settle, save last account
* disable borrow/withdraw button when no account
2021-06-05 07:11:44 -07:00
|
|
|
return (
|
|
|
|
<div className={`bg-th-bkg-1 text-th-fgd-1 transition-all`}>
|
|
|
|
<TopBar />
|
|
|
|
<PageBodyContainer>
|
2021-09-19 17:36:02 -07:00
|
|
|
<div className="flex flex-col md:flex-row md:items-end md:justify-between py-4 md:pb-4 md:pt-10">
|
2021-07-06 17:13:17 -07:00
|
|
|
{mangoAccount ? (
|
2021-07-23 07:07:05 -07:00
|
|
|
<>
|
2021-09-19 17:36:02 -07:00
|
|
|
<div className="pb-3 md:pb-0">
|
|
|
|
<h1
|
|
|
|
className={`font-semibold mb-1 mr-3 text-th-fgd-1 text-2xl`}
|
|
|
|
>
|
2021-11-24 00:17:17 -08:00
|
|
|
{mangoAccount?.name || t('account')}
|
2021-07-23 07:07:05 -07:00
|
|
|
</h1>
|
2021-12-07 20:00:02 -08:00
|
|
|
<div className="flex items-center text-th-fgd-3 ">
|
2021-09-19 17:36:02 -07:00
|
|
|
<span className="text-xxs sm:text-xs">
|
2021-09-05 17:20:21 -07:00
|
|
|
{mangoAccount.publicKey.toString()}
|
|
|
|
</span>
|
2021-07-23 07:07:05 -07:00
|
|
|
<DuplicateIcon
|
|
|
|
className="cursor-pointer default-transition h-4 w-4 ml-1.5 hover:text-th-fgd-1"
|
|
|
|
onClick={() => handleCopyPublicKey(mangoAccount.publicKey)}
|
|
|
|
/>
|
|
|
|
{isCopied ? (
|
|
|
|
<div className="ml-2 text-th-fgd-2 text-xs">Copied!</div>
|
|
|
|
) : null}
|
2021-06-07 10:03:51 -07:00
|
|
|
</div>
|
2021-12-07 20:00:02 -08:00
|
|
|
<div className="flex items-center text-th-red text-xxs">
|
|
|
|
<ExclamationCircleIcon className="h-4 mr-1.5 w-4" />
|
|
|
|
{t('account-address-warning')}
|
|
|
|
</div>
|
2021-07-23 07:07:05 -07:00
|
|
|
</div>
|
2021-11-08 08:42:55 -08:00
|
|
|
<div className="grid grid-cols-4 grid-rows-1 gap-2">
|
2021-07-29 12:05:16 -07:00
|
|
|
<Button
|
2021-09-19 17:36:02 -07:00
|
|
|
className="col-span-1 flex items-center justify-center pt-0 pb-0 h-8 pl-3 pr-3 text-xs"
|
2021-07-23 07:07:05 -07:00
|
|
|
onClick={() => setShowNameModal(true)}
|
|
|
|
>
|
|
|
|
<div className="flex items-center">
|
|
|
|
<PencilIcon className="h-4 w-4 mr-1.5" />
|
2021-10-20 05:42:40 -07:00
|
|
|
{mangoAccount?.name ? t('edit-name') : t('add-name')}
|
2021-07-23 07:07:05 -07:00
|
|
|
</div>
|
2021-07-29 12:05:16 -07:00
|
|
|
</Button>
|
2021-11-08 08:42:55 -08:00
|
|
|
<Button
|
|
|
|
className="col-span-1 flex items-center justify-center pt-0 pb-0 h-8 pl-3 pr-3 text-xs"
|
|
|
|
onClick={() => setShowCloseAccountModal(true)}
|
|
|
|
>
|
|
|
|
<div className="flex items-center">
|
|
|
|
<TrashIcon className="h-4 w-4 mr-1.5" />
|
|
|
|
Close Account
|
2022-01-17 09:25:04 -08:00
|
|
|
{/* TOTRANSLATE */}
|
2021-11-08 08:42:55 -08:00
|
|
|
</div>
|
|
|
|
</Button>
|
User account page (#22)
* layout, overview, start on assets, borrows and open orders
* trade history, sortable data hook for tables, borrow page
* handle deposit and withdraw buttons
* borrow modal ui and integration + settle borrow for individual assets
* in orders balance to asset table and totals, responsive css, new connected wallet button + small tweaks
* account switch/creation flow
* accounts modal, update to usebalances hook
* handle settle, deposit before settle, save last account
* disable borrow/withdraw button when no account
2021-06-05 07:11:44 -07:00
|
|
|
<a
|
2021-09-19 17:36:02 -07:00
|
|
|
className="bg-th-bkg-4 col-span-1 default-transition flex font-bold h-8 items-center justify-center pl-3 pr-3 rounded-full text-th-fgd-1 text-xs hover:text-th-fgd-1 hover:brightness-[1.15] focus:outline-none"
|
2021-07-06 17:13:17 -07:00
|
|
|
href={`https://explorer.solana.com/address/${mangoAccount?.publicKey}`}
|
User account page (#22)
* layout, overview, start on assets, borrows and open orders
* trade history, sortable data hook for tables, borrow page
* handle deposit and withdraw buttons
* borrow modal ui and integration + settle borrow for individual assets
* in orders balance to asset table and totals, responsive css, new connected wallet button + small tweaks
* account switch/creation flow
* accounts modal, update to usebalances hook
* handle settle, deposit before settle, save last account
* disable borrow/withdraw button when no account
2021-06-05 07:11:44 -07:00
|
|
|
target="_blank"
|
|
|
|
rel="noopener noreferrer"
|
|
|
|
>
|
2021-10-20 05:42:40 -07:00
|
|
|
<span>{t('explorer')}</span>
|
2021-07-23 07:07:05 -07:00
|
|
|
<ExternalLinkIcon className={`h-4 w-4 ml-1.5`} />
|
User account page (#22)
* layout, overview, start on assets, borrows and open orders
* trade history, sortable data hook for tables, borrow page
* handle deposit and withdraw buttons
* borrow modal ui and integration + settle borrow for individual assets
* in orders balance to asset table and totals, responsive css, new connected wallet button + small tweaks
* account switch/creation flow
* accounts modal, update to usebalances hook
* handle settle, deposit before settle, save last account
* disable borrow/withdraw button when no account
2021-06-05 07:11:44 -07:00
|
|
|
</a>
|
2021-07-23 07:07:05 -07:00
|
|
|
<Button
|
2021-09-19 17:36:02 -07:00
|
|
|
className="col-span-1 flex items-center justify-center pt-0 pb-0 h-8 pl-3 pr-3 text-xs"
|
2021-07-23 07:07:05 -07:00
|
|
|
onClick={() => setShowAccountsModal(true)}
|
|
|
|
>
|
2021-10-20 05:42:40 -07:00
|
|
|
{t('accounts')}
|
2021-07-23 07:07:05 -07:00
|
|
|
</Button>
|
User account page (#22)
* layout, overview, start on assets, borrows and open orders
* trade history, sortable data hook for tables, borrow page
* handle deposit and withdraw buttons
* borrow modal ui and integration + settle borrow for individual assets
* in orders balance to asset table and totals, responsive css, new connected wallet button + small tweaks
* account switch/creation flow
* accounts modal, update to usebalances hook
* handle settle, deposit before settle, save last account
* disable borrow/withdraw button when no account
2021-06-05 07:11:44 -07:00
|
|
|
</div>
|
2021-07-23 07:07:05 -07:00
|
|
|
</>
|
User account page (#22)
* layout, overview, start on assets, borrows and open orders
* trade history, sortable data hook for tables, borrow page
* handle deposit and withdraw buttons
* borrow modal ui and integration + settle borrow for individual assets
* in orders balance to asset table and totals, responsive css, new connected wallet button + small tweaks
* account switch/creation flow
* accounts modal, update to usebalances hook
* handle settle, deposit before settle, save last account
* disable borrow/withdraw button when no account
2021-06-05 07:11:44 -07:00
|
|
|
) : null}
|
|
|
|
</div>
|
2021-09-19 17:36:02 -07:00
|
|
|
{mangoAccount ? (
|
2021-09-19 20:21:55 -07:00
|
|
|
!isMobile ? (
|
|
|
|
<Tabs
|
|
|
|
activeTab={activeTab}
|
|
|
|
onChange={handleTabChange}
|
|
|
|
tabs={TABS}
|
|
|
|
/>
|
|
|
|
) : (
|
2021-11-03 04:28:58 -07:00
|
|
|
<div className="pb-2 pt-3">
|
|
|
|
<Select
|
2021-11-24 00:17:17 -08:00
|
|
|
value={t(TABS[viewIndex].toLowerCase())}
|
2021-11-03 04:28:58 -07:00
|
|
|
onChange={(e) => handleChangeViewIndex(e)}
|
|
|
|
>
|
|
|
|
{TABS.map((tab, index) => (
|
|
|
|
<Select.Option key={index + tab} value={index}>
|
2021-11-24 00:17:17 -08:00
|
|
|
{t(tab.toLowerCase())}
|
2021-11-03 04:28:58 -07:00
|
|
|
</Select.Option>
|
|
|
|
))}
|
|
|
|
</Select>
|
|
|
|
</div>
|
2021-09-19 20:21:55 -07:00
|
|
|
)
|
2021-09-19 17:36:02 -07:00
|
|
|
) : null}
|
|
|
|
<div className="bg-th-bkg-2 p-4 sm:p-6 rounded-lg">
|
2021-07-06 17:13:17 -07:00
|
|
|
{mangoAccount ? (
|
2021-09-19 20:21:55 -07:00
|
|
|
!isMobile ? (
|
|
|
|
<TabContent activeTab={activeTab} />
|
|
|
|
) : (
|
|
|
|
<Swipeable
|
|
|
|
index={viewIndex}
|
|
|
|
onChangeIndex={handleChangeViewIndex}
|
|
|
|
>
|
|
|
|
<div>
|
|
|
|
<AccountOverview />
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<AccountOrders />
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<AccountHistory />
|
|
|
|
</div>
|
2021-11-03 04:28:58 -07:00
|
|
|
<div>
|
|
|
|
<AccountInterest />
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<AccountFunding />
|
|
|
|
</div>
|
2021-09-19 20:21:55 -07:00
|
|
|
</Swipeable>
|
|
|
|
)
|
User account page (#22)
* layout, overview, start on assets, borrows and open orders
* trade history, sortable data hook for tables, borrow page
* handle deposit and withdraw buttons
* borrow modal ui and integration + settle borrow for individual assets
* in orders balance to asset table and totals, responsive css, new connected wallet button + small tweaks
* account switch/creation flow
* accounts modal, update to usebalances hook
* handle settle, deposit before settle, save last account
* disable borrow/withdraw button when no account
2021-06-05 07:11:44 -07:00
|
|
|
) : connected ? (
|
2021-08-20 06:17:02 -07:00
|
|
|
isLoading ? (
|
|
|
|
<div className="flex justify-center py-10">
|
|
|
|
<Loading />
|
|
|
|
</div>
|
|
|
|
) : (
|
|
|
|
<EmptyState
|
2021-11-24 00:17:17 -08:00
|
|
|
buttonText={t('create-account')}
|
2021-08-20 06:17:02 -07:00
|
|
|
icon={<CurrencyDollarIcon />}
|
|
|
|
onClickButton={() => setShowAccountsModal(true)}
|
2021-11-24 00:17:17 -08:00
|
|
|
title={t('no-account-found')}
|
2021-08-20 06:17:02 -07:00
|
|
|
/>
|
|
|
|
)
|
User account page (#22)
* layout, overview, start on assets, borrows and open orders
* trade history, sortable data hook for tables, borrow page
* handle deposit and withdraw buttons
* borrow modal ui and integration + settle borrow for individual assets
* in orders balance to asset table and totals, responsive css, new connected wallet button + small tweaks
* account switch/creation flow
* accounts modal, update to usebalances hook
* handle settle, deposit before settle, save last account
* disable borrow/withdraw button when no account
2021-06-05 07:11:44 -07:00
|
|
|
) : (
|
|
|
|
<EmptyState
|
2021-10-20 05:42:40 -07:00
|
|
|
buttonText={t('connect')}
|
|
|
|
desc={t('connect-view')}
|
User account page (#22)
* layout, overview, start on assets, borrows and open orders
* trade history, sortable data hook for tables, borrow page
* handle deposit and withdraw buttons
* borrow modal ui and integration + settle borrow for individual assets
* in orders balance to asset table and totals, responsive css, new connected wallet button + small tweaks
* account switch/creation flow
* accounts modal, update to usebalances hook
* handle settle, deposit before settle, save last account
* disable borrow/withdraw button when no account
2021-06-05 07:11:44 -07:00
|
|
|
icon={<LinkIcon />}
|
2021-07-22 04:34:03 -07:00
|
|
|
onClickButton={() => wallet.connect()}
|
2021-10-20 05:42:40 -07:00
|
|
|
title={t('connect-wallet')}
|
User account page (#22)
* layout, overview, start on assets, borrows and open orders
* trade history, sortable data hook for tables, borrow page
* handle deposit and withdraw buttons
* borrow modal ui and integration + settle borrow for individual assets
* in orders balance to asset table and totals, responsive css, new connected wallet button + small tweaks
* account switch/creation flow
* accounts modal, update to usebalances hook
* handle settle, deposit before settle, save last account
* disable borrow/withdraw button when no account
2021-06-05 07:11:44 -07:00
|
|
|
/>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
</PageBodyContainer>
|
|
|
|
{showAccountsModal ? (
|
|
|
|
<AccountsModal
|
|
|
|
onClose={handleCloseAccounts}
|
|
|
|
isOpen={showAccountsModal}
|
|
|
|
/>
|
|
|
|
) : null}
|
2021-07-23 07:07:05 -07:00
|
|
|
{showNameModal ? (
|
|
|
|
<AccountNameModal
|
2021-07-30 13:37:00 -07:00
|
|
|
accountName={mangoAccount?.name}
|
2021-07-23 07:07:05 -07:00
|
|
|
isOpen={showNameModal}
|
|
|
|
onClose={handleCloseNameModal}
|
|
|
|
/>
|
|
|
|
) : null}
|
2021-11-08 08:42:55 -08:00
|
|
|
{showCloseAccountModal ? (
|
|
|
|
<CloseAccountModal
|
|
|
|
accountName={mangoAccount?.name}
|
|
|
|
isOpen={showCloseAccountModal}
|
|
|
|
onClose={handleCloseCloseAccountModal}
|
|
|
|
/>
|
|
|
|
) : null}
|
User account page (#22)
* layout, overview, start on assets, borrows and open orders
* trade history, sortable data hook for tables, borrow page
* handle deposit and withdraw buttons
* borrow modal ui and integration + settle borrow for individual assets
* in orders balance to asset table and totals, responsive css, new connected wallet button + small tweaks
* account switch/creation flow
* accounts modal, update to usebalances hook
* handle settle, deposit before settle, save last account
* disable borrow/withdraw button when no account
2021-06-05 07:11:44 -07:00
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
2021-09-19 20:21:55 -07:00
|
|
|
|
|
|
|
const TabContent = ({ activeTab }) => {
|
|
|
|
switch (activeTab) {
|
|
|
|
case 'Portfolio':
|
|
|
|
return <AccountOverview />
|
|
|
|
case 'Orders':
|
|
|
|
return <AccountOrders />
|
2021-11-17 07:51:17 -08:00
|
|
|
case 'History':
|
2021-09-19 20:21:55 -07:00
|
|
|
return <AccountHistory />
|
2021-09-27 21:13:25 -07:00
|
|
|
case 'Interest':
|
|
|
|
return <AccountInterest />
|
2021-10-17 19:34:24 -07:00
|
|
|
case 'Funding':
|
|
|
|
return <AccountFunding />
|
2021-12-23 15:05:44 -08:00
|
|
|
case 'Performance':
|
|
|
|
return <AccountPerformance />
|
2021-09-19 20:21:55 -07:00
|
|
|
default:
|
|
|
|
return <AccountOverview />
|
|
|
|
}
|
|
|
|
}
|