mango-ui-v3/pages/borrow.tsx

70 lines
2.4 KiB
TypeScript
Raw Normal View History

import { useCallback, useState } from 'react'
import { CurrencyDollarIcon, LinkIcon } from '@heroicons/react/outline'
import useMangoStore from '../stores/useMangoStore'
import PageBodyContainer from '../components/PageBodyContainer'
import TopBar from '../components/TopBar'
import EmptyState from '../components/EmptyState'
import AccountsModal from '../components/AccountsModal'
2021-09-26 06:20:51 -07:00
import AccountBorrows from '../components/account_page/AccountBorrows'
2021-08-20 06:17:02 -07:00
import Loading from '../components/Loading'
export default function Borrow() {
const [showAccountsModal, setShowAccountsModal] = useState(false)
const connected = useMangoStore((s) => s.wallet.connected)
2021-06-23 08:32:33 -07:00
const selectedMangoAccount = useMangoStore(
(s) => s.selectedMangoAccount.current
)
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)
2021-07-22 04:34:03 -07:00
const handleCloseAccounts = useCallback(() => {
setShowAccountsModal(false)
}, [])
2021-07-22 04:34:03 -07:00
return (
<div className={`bg-th-bkg-1 text-th-fgd-1 transition-all`}>
<TopBar />
<PageBodyContainer>
2021-09-13 18:32:36 -07:00
<div className="pt-8 pb-3 sm:pb-4 md:pt-10">
<h1 className={`mb-1 text-th-fgd-1 text-2xl font-semibold`}>
Borrow Funds
</h1>
2021-09-13 18:32:36 -07:00
<p>Borrowed funds are withdrawn to your connected wallet.</p>
</div>
2021-09-09 06:14:20 -07:00
<div className="bg-th-bkg-2 overflow-none p-4 sm:p-6 rounded-lg">
2021-06-23 08:32:33 -07:00
{selectedMangoAccount ? (
<AccountBorrows />
) : connected ? (
2021-08-20 06:17:02 -07:00
isLoading ? (
<div className="flex justify-center py-10">
<Loading />
</div>
) : (
<EmptyState
buttonText="Create Account"
icon={<CurrencyDollarIcon />}
onClickButton={() => setShowAccountsModal(true)}
title="No Account Found"
/>
)
) : (
<EmptyState
2021-07-22 04:34:03 -07:00
buttonText="Connect"
desc="Connect a wallet to view your account"
icon={<LinkIcon />}
2021-07-22 04:34:03 -07:00
onClickButton={() => wallet.connect()}
title="Connect Wallet"
/>
)}
</div>
</PageBodyContainer>
{showAccountsModal ? (
<AccountsModal
onClose={handleCloseAccounts}
isOpen={showAccountsModal}
/>
) : null}
</div>
)
}