2021-11-15 10:27:57 -08:00
|
|
|
import { useCallback, useState, useEffect } 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 PageBodyContainer from '../components/PageBodyContainer'
|
|
|
|
import TopBar from '../components/TopBar'
|
|
|
|
import AccountsModal from '../components/AccountsModal'
|
2021-09-26 06:20:51 -07:00
|
|
|
import AccountBorrows from '../components/account_page/AccountBorrows'
|
2021-10-20 05:42:40 -07:00
|
|
|
import { serverSideTranslations } from 'next-i18next/serverSideTranslations'
|
2022-02-04 09:57:18 -08:00
|
|
|
import useMangoStore from '../stores/useMangoStore'
|
|
|
|
import { mangoGroupSelector } from '../stores/selectors'
|
2021-10-20 05:42:40 -07:00
|
|
|
|
2021-11-14 10:37:02 -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
|
|
|
|
|
|
|
export default function Borrow() {
|
|
|
|
const [showAccountsModal, setShowAccountsModal] = useState(false)
|
2022-02-04 09:57:18 -08:00
|
|
|
const mangoGroup = useMangoStore(mangoGroupSelector)
|
2021-07-22 04:34:03 -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
|
|
|
const handleCloseAccounts = useCallback(() => {
|
|
|
|
setShowAccountsModal(false)
|
|
|
|
}, [])
|
2021-07-22 04:34:03 -07:00
|
|
|
|
2021-11-15 10:27:57 -08:00
|
|
|
useEffect(() => {
|
|
|
|
// @ts-ignore
|
2021-11-15 11:16:03 -08:00
|
|
|
if (window.solana) {
|
|
|
|
// @ts-ignore
|
|
|
|
window.solana.connect({ onlyIfTrusted: true })
|
|
|
|
}
|
2021-11-15 10:27:57 -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
|
|
|
return (
|
|
|
|
<div className={`bg-th-bkg-1 text-th-fgd-1 transition-all`}>
|
|
|
|
<TopBar />
|
|
|
|
<PageBodyContainer>
|
2022-02-04 09:57:18 -08:00
|
|
|
<div className="bg-th-bkg-2 overflow-none p-4 sm:p-6 rounded-lg mt-10 md:mt-12">
|
|
|
|
{mangoGroup ? <AccountBorrows /> : 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>
|
|
|
|
</PageBodyContainer>
|
|
|
|
{showAccountsModal ? (
|
|
|
|
<AccountsModal
|
|
|
|
onClose={handleCloseAccounts}
|
|
|
|
isOpen={showAccountsModal}
|
|
|
|
/>
|
|
|
|
) : null}
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|