* MP-2801: fund new credit account * tidy: cleanup * tidy: refactor * feat: replaced all possible BN(0) & BN(1) occurrences with constants * fix: adjusted according to feedback * fix: adjustments according to feedback * fix: PR comment updates * fix: reduced complexity * feat: animated the wallet balance for the demo * fix: enhanced wallet connection to select first account * fix: adjusted the calculations and added USD as displayCurrency * fix: adjusted according to feedback * feat: added TFM bridge * fix: changed forceFetchPrice --------- Co-authored-by: Yusuf Seyrek <yusuf@delphilabs.io>
51 lines
1.6 KiB
TypeScript
51 lines
1.6 KiB
TypeScript
import { useCallback, useState } from 'react'
|
|
|
|
import Button from 'components/Button'
|
|
import { CircularProgress } from 'components/CircularProgress'
|
|
import Modal from 'components/Modal'
|
|
import AddVaultAssetsModalContent from 'components/Modals/AddVaultAssets/AddVaultBorrowAssetsModalContent'
|
|
import Text from 'components/Text'
|
|
import useStore from 'store'
|
|
|
|
export default function AddVaultBorrowAssetsModal() {
|
|
const modal = useStore((s) => s.addVaultBorrowingsModal)
|
|
const vaultModal = useStore((s) => s.vaultModal)
|
|
const [selectedDenoms, setSelectedDenoms] = useState<string[]>([])
|
|
|
|
function onClose() {
|
|
if (!vaultModal) return
|
|
|
|
useStore.setState({
|
|
addVaultBorrowingsModal: null,
|
|
vaultModal: { ...vaultModal, selectedBorrowDenoms: selectedDenoms },
|
|
})
|
|
}
|
|
|
|
const updateSelectedDenoms = useCallback((denoms: string[]) => setSelectedDenoms(denoms), [])
|
|
|
|
const showContent = modal && vaultModal?.vault
|
|
|
|
if (!showContent) return null
|
|
return (
|
|
<Modal
|
|
header={<Text>Add Assets</Text>}
|
|
onClose={onClose}
|
|
modalClassName='max-w-modal-xs'
|
|
headerClassName='bg-white/10 border-b-white/5 border-b items-center p-4'
|
|
>
|
|
{showContent ? (
|
|
<AddVaultAssetsModalContent
|
|
vault={vaultModal?.vault}
|
|
defaultSelectedDenoms={modal.selectedDenoms}
|
|
onChangeBorrowDenoms={updateSelectedDenoms}
|
|
/>
|
|
) : (
|
|
<CircularProgress />
|
|
)}
|
|
<div className='flex w-full p-4'>
|
|
<Button className='w-full' onClick={onClose} color='tertiary' text='Select Assets' />
|
|
</div>
|
|
</Modal>
|
|
)
|
|
}
|