2022-07-20 21:50:56 -07:00
|
|
|
import { Transition } from '@headlessui/react'
|
|
|
|
import { useTranslation } from 'next-i18next'
|
2022-08-18 13:50:34 -07:00
|
|
|
import { ChangeEvent, useCallback, useEffect, useMemo, useState } from 'react'
|
2022-07-20 21:50:56 -07:00
|
|
|
import { ModalProps } from '../../types/modal'
|
2022-08-16 04:23:43 -07:00
|
|
|
// import { PROFILE_CATEGORIES } from '../../utils/profile'
|
2022-07-20 21:50:56 -07:00
|
|
|
import Input from '../forms/Input'
|
|
|
|
import Label from '../forms/Label'
|
2022-08-16 04:23:43 -07:00
|
|
|
// import Select from '../forms/Select'
|
2022-07-20 21:50:56 -07:00
|
|
|
import Button, { LinkButton } from '../shared/Button'
|
|
|
|
import InlineNotification from '../shared/InlineNotification'
|
|
|
|
import Modal from '../shared/Modal'
|
|
|
|
import useLocalStorageState from '../../hooks/useLocalStorageState'
|
2022-07-28 19:51:50 -07:00
|
|
|
import { CheckCircleIcon, PencilIcon } from '@heroicons/react/solid'
|
2022-07-21 22:09:04 -07:00
|
|
|
import { useWallet } from '@solana/wallet-adapter-react'
|
2022-08-20 11:17:57 -07:00
|
|
|
import mangoStore from '../../store/mangoStore'
|
2022-07-28 19:51:50 -07:00
|
|
|
import { EnterRightExitLeft, FadeInFadeOut } from '../shared/Transitions'
|
2022-07-27 23:35:18 -07:00
|
|
|
import Image from 'next/image'
|
2022-07-28 03:51:36 -07:00
|
|
|
import BounceLoader from '../shared/BounceLoader'
|
2022-07-28 19:51:50 -07:00
|
|
|
import { notify } from '../../utils/notifications'
|
2022-08-11 21:20:17 -07:00
|
|
|
import { Wallet } from '@project-serum/anchor'
|
2022-08-17 22:58:44 -07:00
|
|
|
import ActionTokenList from '../account/ActionTokenList'
|
|
|
|
import { walletBalanceForToken } from './DepositModal'
|
|
|
|
import { floorToDecimal } from '../../utils/numbers'
|
2022-08-19 23:06:00 -07:00
|
|
|
import { handleWalletConnect } from '../wallet/ConnectWalletButton'
|
2022-08-20 19:57:07 -07:00
|
|
|
import { IS_ONBOARDED_KEY } from '../../utils/constants'
|
2022-07-20 21:50:56 -07:00
|
|
|
|
|
|
|
const UserSetupModal = ({ isOpen, onClose }: ModalProps) => {
|
|
|
|
const { t } = useTranslation()
|
2022-08-17 22:58:44 -07:00
|
|
|
const group = mangoStore((s) => s.group)
|
2022-08-11 21:20:17 -07:00
|
|
|
const { connected, select, wallet, wallets } = useWallet()
|
2022-07-27 23:35:18 -07:00
|
|
|
const mangoAccount = mangoStore((s) => s.mangoAccount.current)
|
2022-08-19 14:17:30 -07:00
|
|
|
const mangoAccountLoading = mangoStore((s) => s.mangoAccount.initialLoad)
|
2022-08-11 21:20:17 -07:00
|
|
|
const [accountName, setAccountName] = useState('')
|
|
|
|
const [loadingAccount, setLoadingAccount] = useState(false)
|
2022-08-15 22:10:17 -07:00
|
|
|
// const [profileName, setProfileName] = useState('')
|
|
|
|
// const [profileCategory, setProfileCategory] = useState('')
|
2022-07-21 22:09:04 -07:00
|
|
|
const [showSetupStep, setShowSetupStep] = useState(0)
|
2022-07-26 18:21:17 -07:00
|
|
|
// const [acceptRisks, setAcceptRisks] = useState(false)
|
2022-07-21 22:09:04 -07:00
|
|
|
const [depositToken, setDepositToken] = useState('')
|
2022-07-28 19:51:50 -07:00
|
|
|
const [depositAmount, setDepositAmount] = useState('')
|
|
|
|
const [submitDeposit, setSubmitDeposit] = useState(false)
|
|
|
|
const [, setIsOnboarded] = useLocalStorageState(IS_ONBOARDED_KEY)
|
2022-08-17 22:58:44 -07:00
|
|
|
const walletTokens = mangoStore((s) => s.wallet.tokens)
|
2022-07-21 22:09:04 -07:00
|
|
|
|
|
|
|
const handleNextStep = () => {
|
|
|
|
setShowSetupStep(showSetupStep + 1)
|
|
|
|
}
|
2022-07-20 21:50:56 -07:00
|
|
|
|
|
|
|
const handleSaveProfile = () => {
|
2022-07-21 22:09:04 -07:00
|
|
|
// save profile details to db then:
|
2022-07-27 23:35:18 -07:00
|
|
|
setShowSetupStep(2)
|
2022-07-20 21:50:56 -07:00
|
|
|
}
|
|
|
|
|
2022-07-21 22:09:04 -07:00
|
|
|
const handleEndOnboarding = () => {
|
2022-07-20 21:50:56 -07:00
|
|
|
onClose()
|
|
|
|
}
|
|
|
|
|
2022-07-27 23:35:18 -07:00
|
|
|
const connectWallet = async () => {
|
2022-07-21 22:09:04 -07:00
|
|
|
if (wallet) {
|
2022-08-22 10:27:03 -07:00
|
|
|
try {
|
|
|
|
await handleWalletConnect(wallet)
|
|
|
|
setIsOnboarded(true)
|
|
|
|
setShowSetupStep(2)
|
|
|
|
} catch (e) {
|
|
|
|
notify({
|
|
|
|
title: 'Setup failed. Refresh and try again.',
|
|
|
|
type: 'error',
|
|
|
|
})
|
|
|
|
}
|
2022-07-21 22:09:04 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-18 13:50:34 -07:00
|
|
|
const handleCreateAccount = useCallback(async () => {
|
2022-08-11 21:20:17 -07:00
|
|
|
const client = mangoStore.getState().client
|
|
|
|
const group = mangoStore.getState().group
|
|
|
|
const actions = mangoStore.getState().actions
|
|
|
|
if (!group || !wallet) return
|
|
|
|
setLoadingAccount(true)
|
|
|
|
try {
|
|
|
|
const tx = await client.createMangoAccount(
|
|
|
|
group,
|
|
|
|
0,
|
|
|
|
accountName || 'Account 1'
|
|
|
|
)
|
2022-08-19 14:17:30 -07:00
|
|
|
actions.fetchMangoAccounts(wallet!.adapter as unknown as Wallet)
|
2022-08-11 21:20:17 -07:00
|
|
|
if (tx) {
|
|
|
|
setLoadingAccount(false)
|
2022-08-15 22:10:17 -07:00
|
|
|
setShowSetupStep(3)
|
2022-08-11 21:20:17 -07:00
|
|
|
notify({
|
|
|
|
title: t('new-account-success'),
|
|
|
|
type: 'success',
|
|
|
|
txid: tx,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
} catch (e: any) {
|
|
|
|
setLoadingAccount(false)
|
|
|
|
notify({
|
|
|
|
title: t('new-account-failed'),
|
|
|
|
txid: e?.signature,
|
|
|
|
type: 'error',
|
|
|
|
})
|
2022-08-20 17:09:36 -07:00
|
|
|
console.error(e)
|
2022-07-21 22:09:04 -07:00
|
|
|
}
|
2022-08-18 13:50:34 -07:00
|
|
|
}, [accountName, wallet, t])
|
2022-07-21 22:09:04 -07:00
|
|
|
|
2022-08-18 13:50:34 -07:00
|
|
|
const handleDeposit = useCallback(async () => {
|
2022-07-28 19:51:50 -07:00
|
|
|
const client = mangoStore.getState().client
|
|
|
|
const group = mangoStore.getState().group
|
|
|
|
const actions = mangoStore.getState().actions
|
|
|
|
const mangoAccount = mangoStore.getState().mangoAccount.current
|
|
|
|
|
|
|
|
if (!mangoAccount || !group) return
|
2022-08-18 13:50:34 -07:00
|
|
|
const bank = group.banksMapByName.get(depositToken)![0]
|
2022-07-28 19:51:50 -07:00
|
|
|
try {
|
|
|
|
setSubmitDeposit(true)
|
|
|
|
const tx = await client.tokenDeposit(
|
|
|
|
group,
|
|
|
|
mangoAccount,
|
2022-08-18 13:50:34 -07:00
|
|
|
bank.mint,
|
2022-07-28 19:51:50 -07:00
|
|
|
parseFloat(depositAmount)
|
|
|
|
)
|
|
|
|
notify({
|
|
|
|
title: 'Transaction confirmed',
|
|
|
|
type: 'success',
|
|
|
|
txid: tx,
|
|
|
|
})
|
|
|
|
|
|
|
|
await actions.reloadAccount()
|
|
|
|
setIsOnboarded(true)
|
|
|
|
onClose()
|
|
|
|
setSubmitDeposit(false)
|
|
|
|
} catch (e: any) {
|
|
|
|
notify({
|
|
|
|
title: 'Transaction failed',
|
|
|
|
description: e.message,
|
|
|
|
txid: e?.txid,
|
|
|
|
type: 'error',
|
|
|
|
})
|
|
|
|
setSubmitDeposit(false)
|
2022-08-02 11:04:00 -07:00
|
|
|
console.error(e)
|
2022-07-28 19:51:50 -07:00
|
|
|
}
|
2022-08-18 13:50:34 -07:00
|
|
|
}, [depositAmount, depositToken, onClose, setIsOnboarded])
|
2022-07-28 19:51:50 -07:00
|
|
|
|
2022-08-11 21:20:17 -07:00
|
|
|
useEffect(() => {
|
2022-08-22 10:27:03 -07:00
|
|
|
if (mangoAccount && showSetupStep === 2) {
|
2022-08-11 21:20:17 -07:00
|
|
|
onClose()
|
|
|
|
}
|
2022-08-22 10:27:03 -07:00
|
|
|
}, [mangoAccount, showSetupStep, onClose])
|
2022-08-11 21:20:17 -07:00
|
|
|
|
2022-08-17 22:58:44 -07:00
|
|
|
const banks = useMemo(() => {
|
2022-08-18 13:50:34 -07:00
|
|
|
return group?.banksMapByName
|
|
|
|
? Array.from(group?.banksMapByName, ([key, value]) => {
|
2022-08-17 22:58:44 -07:00
|
|
|
const walletBalance = walletBalanceForToken(walletTokens, key)
|
|
|
|
return {
|
|
|
|
key,
|
|
|
|
value,
|
|
|
|
walletBalance: floorToDecimal(
|
|
|
|
walletBalance.maxAmount,
|
|
|
|
walletBalance.maxDecimals
|
|
|
|
),
|
|
|
|
}
|
|
|
|
})
|
|
|
|
: []
|
2022-08-18 13:50:34 -07:00
|
|
|
}, [group?.banksMapByName, walletTokens])
|
2022-08-17 22:58:44 -07:00
|
|
|
|
2022-07-20 21:50:56 -07:00
|
|
|
return (
|
2022-08-16 21:49:20 -07:00
|
|
|
<Modal isOpen={isOpen} onClose={onClose} disableOutsideClose hideClose>
|
2022-07-23 04:20:08 -07:00
|
|
|
<div className="absolute top-0 left-0 flex h-0.5 w-full flex-grow bg-th-bkg-4">
|
2022-07-22 04:22:35 -07:00
|
|
|
<div
|
|
|
|
style={{
|
2022-08-11 21:20:17 -07:00
|
|
|
width: `${(showSetupStep / 4) * 100}%`,
|
2022-07-22 04:22:35 -07:00
|
|
|
}}
|
2022-07-23 04:20:08 -07:00
|
|
|
className="default-transition flex rounded bg-th-primary"
|
2022-07-22 04:22:35 -07:00
|
|
|
></div>
|
|
|
|
</div>
|
|
|
|
<div className="h-[392px]">
|
2022-07-21 22:09:04 -07:00
|
|
|
<Transition
|
|
|
|
appear={true}
|
2022-07-23 04:20:08 -07:00
|
|
|
className="absolute top-0.5 left-0 z-20 h-full w-full bg-th-bkg-1 p-6"
|
2022-07-21 22:09:04 -07:00
|
|
|
show={showSetupStep === 0}
|
2022-08-16 15:58:03 -07:00
|
|
|
enter="transition ease-in duration-500"
|
2022-07-21 22:09:04 -07:00
|
|
|
enterFrom="opacity-0"
|
|
|
|
enterTo="opacity-100"
|
2022-08-16 15:58:03 -07:00
|
|
|
leave="transition ease-out duration-500"
|
|
|
|
leaveFrom="translate-x-0"
|
|
|
|
leaveTo="-translate-x-full"
|
2022-07-21 22:09:04 -07:00
|
|
|
>
|
|
|
|
<h2 className="mb-1">Welcome.</h2>
|
|
|
|
<p className="mb-4">
|
2022-07-22 10:53:23 -07:00
|
|
|
{
|
|
|
|
"You're seconds away from trading the most liquid dex markets on Solana."
|
|
|
|
}
|
2022-07-20 21:50:56 -07:00
|
|
|
</p>
|
2022-07-21 22:09:04 -07:00
|
|
|
<div className="mb-6 space-y-2 border-y border-th-bkg-4 py-4">
|
|
|
|
<div className="flex items-center space-x-2">
|
|
|
|
<CheckCircleIcon className="h-5 w-5 text-th-green" />
|
|
|
|
<p className="text-th-fgd-1">Trusted by 1,000s of DeFi users</p>
|
|
|
|
</div>
|
|
|
|
<div className="flex items-center space-x-2">
|
|
|
|
<CheckCircleIcon className="h-5 w-5 text-th-green" />
|
|
|
|
<p className="text-th-fgd-1">Deeply liquid markets</p>
|
2022-07-20 21:50:56 -07:00
|
|
|
</div>
|
2022-07-21 22:09:04 -07:00
|
|
|
<div className="flex items-center space-x-2">
|
|
|
|
<CheckCircleIcon className="h-5 w-5 text-th-green" />
|
|
|
|
<p className="text-th-fgd-1">
|
|
|
|
Up to 20x leverage across 100s of tokens
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
<div className="flex items-center space-x-2">
|
|
|
|
<CheckCircleIcon className="h-5 w-5 text-th-green" />
|
|
|
|
<p className="text-th-fgd-1">Earn interest on your deposits</p>
|
|
|
|
</div>
|
|
|
|
<div className="flex items-center space-x-2">
|
|
|
|
<CheckCircleIcon className="h-5 w-5 text-th-green" />
|
|
|
|
<p className="text-th-fgd-1">
|
|
|
|
Borrow 100s of tokens with many collateral options
|
|
|
|
</p>
|
2022-07-20 21:50:56 -07:00
|
|
|
</div>
|
|
|
|
</div>
|
2022-07-21 22:09:04 -07:00
|
|
|
<Button className="w-full" onClick={handleNextStep} size="large">
|
2022-07-22 10:53:23 -07:00
|
|
|
{"Let's Go"}
|
2022-07-21 22:09:04 -07:00
|
|
|
</Button>
|
|
|
|
</Transition>
|
2022-07-23 04:20:08 -07:00
|
|
|
<EnterRightExitLeft
|
|
|
|
className="absolute top-0.5 left-0 z-20 w-full bg-th-bkg-1 p-6"
|
2022-07-21 22:09:04 -07:00
|
|
|
show={showSetupStep === 1}
|
2022-07-23 04:20:08 -07:00
|
|
|
style={{ height: 'calc(100% - 12px)' }}
|
2022-07-21 22:09:04 -07:00
|
|
|
>
|
2022-08-11 21:20:17 -07:00
|
|
|
{connected && mangoAccountLoading ? (
|
2022-07-27 23:35:18 -07:00
|
|
|
<div className="flex h-full items-center justify-center">
|
2022-07-28 03:51:36 -07:00
|
|
|
<BounceLoader />
|
2022-07-21 22:09:04 -07:00
|
|
|
</div>
|
2022-07-27 23:35:18 -07:00
|
|
|
) : (
|
|
|
|
<div className="flex h-full flex-col justify-between">
|
|
|
|
<div>
|
|
|
|
<div className="mb-4">
|
|
|
|
<h2 className="mb-1">Connect Wallet</h2>
|
|
|
|
</div>
|
|
|
|
<p className="mb-2 font-bold">Choose Wallet</p>
|
|
|
|
<div className="thin-scroll grid max-h-56 grid-flow-row grid-cols-3 gap-2 overflow-y-auto">
|
|
|
|
{wallets?.map((w) => (
|
|
|
|
<button
|
|
|
|
className={`col-span-1 rounded-md border py-3 px-4 text-base font-normal focus:outline-none md:hover:cursor-pointer md:hover:border-th-fgd-4 ${
|
|
|
|
w.adapter.name === wallet?.adapter.name
|
|
|
|
? 'border-th-primary md:hover:border-th-primary'
|
|
|
|
: 'border-th-bkg-4'
|
|
|
|
}`}
|
|
|
|
onClick={() => {
|
|
|
|
select(w.adapter.name)
|
|
|
|
}}
|
|
|
|
key={w.adapter.name}
|
|
|
|
>
|
2022-08-15 22:10:17 -07:00
|
|
|
<div className="flex items-center text-th-fgd-4">
|
2022-07-27 23:35:18 -07:00
|
|
|
<img
|
|
|
|
src={w.adapter.icon}
|
|
|
|
className="mr-2 h-5 w-5"
|
|
|
|
alt={`${w.adapter.name} icon`}
|
|
|
|
/>
|
|
|
|
{w.adapter.name}
|
|
|
|
</div>
|
|
|
|
</button>
|
|
|
|
))}
|
|
|
|
</div>
|
|
|
|
</div>
|
2022-08-11 21:20:17 -07:00
|
|
|
<Button className="w-full" onClick={connectWallet} size="large">
|
|
|
|
Connect Wallet
|
|
|
|
</Button>
|
2022-07-27 23:35:18 -07:00
|
|
|
</div>
|
|
|
|
)}
|
2022-07-23 04:20:08 -07:00
|
|
|
</EnterRightExitLeft>
|
2022-08-15 22:10:17 -07:00
|
|
|
{/* <EnterRightExitLeft
|
2022-07-23 04:20:08 -07:00
|
|
|
className="absolute top-0.5 left-0 z-20 w-full bg-th-bkg-1 p-6"
|
2022-07-21 22:09:04 -07:00
|
|
|
show={showSetupStep === 2}
|
2022-07-23 04:20:08 -07:00
|
|
|
style={{ height: 'calc(100% - 12px)' }}
|
2022-07-21 22:09:04 -07:00
|
|
|
>
|
|
|
|
<div className="flex h-full flex-col justify-between">
|
|
|
|
<div>
|
|
|
|
<div className="pb-4">
|
|
|
|
<h2 className="mb-1">Create Profile</h2>
|
|
|
|
<p>Your public facing identity on Mango...</p>
|
|
|
|
</div>
|
|
|
|
<div className="pb-4">
|
|
|
|
<Label text="Profile Name" />
|
|
|
|
<Input
|
|
|
|
type="text"
|
|
|
|
value={profileName}
|
|
|
|
onChange={(e: ChangeEvent<HTMLInputElement>) =>
|
|
|
|
setProfileName(e.target.value)
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div className="pb-6">
|
|
|
|
<Label text="Profile Category" />
|
|
|
|
<Select
|
|
|
|
value={profileCategory}
|
|
|
|
onChange={(cat: string) => setProfileCategory(cat)}
|
|
|
|
className="w-full"
|
|
|
|
>
|
|
|
|
{PROFILE_CATEGORIES.map((cat) => (
|
|
|
|
<Select.Option key={cat} value={cat}>
|
|
|
|
{cat}
|
|
|
|
</Select.Option>
|
|
|
|
))}
|
|
|
|
</Select>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div className="flex flex-col items-center">
|
|
|
|
<Button
|
2022-07-22 04:22:35 -07:00
|
|
|
className="mb-4 w-full"
|
2022-07-21 22:09:04 -07:00
|
|
|
onClick={handleSaveProfile}
|
|
|
|
size="large"
|
|
|
|
>
|
|
|
|
Save Profile
|
|
|
|
</Button>
|
|
|
|
<LinkButton onClick={handleNextStep}>Skip for now</LinkButton>
|
|
|
|
</div>
|
|
|
|
</div>
|
2022-08-15 22:10:17 -07:00
|
|
|
</EnterRightExitLeft> */}
|
2022-07-23 04:20:08 -07:00
|
|
|
<EnterRightExitLeft
|
|
|
|
className="absolute top-0.5 left-0 z-20 w-full bg-th-bkg-1 p-6"
|
2022-08-15 22:10:17 -07:00
|
|
|
show={showSetupStep === 2}
|
2022-07-23 04:20:08 -07:00
|
|
|
style={{ height: 'calc(100% - 12px)' }}
|
2022-07-21 22:09:04 -07:00
|
|
|
>
|
2022-08-11 21:20:17 -07:00
|
|
|
{loadingAccount ? (
|
2022-07-28 19:51:50 -07:00
|
|
|
<div className="flex h-full items-center justify-center">
|
2022-08-11 21:20:17 -07:00
|
|
|
<BounceLoader loadingMessage="Creating Account..." />
|
2022-07-21 22:09:04 -07:00
|
|
|
</div>
|
2022-07-28 19:51:50 -07:00
|
|
|
) : (
|
|
|
|
<div className="flex h-full flex-col justify-between">
|
|
|
|
<div>
|
2022-08-11 21:20:17 -07:00
|
|
|
<div className="pb-4">
|
|
|
|
<h2 className="mb-1">Create Account</h2>
|
|
|
|
<p>You need a Mango Account to get started.</p>
|
|
|
|
</div>
|
|
|
|
<div className="pb-4">
|
|
|
|
<Label text="Account Name" optional />
|
|
|
|
<Input
|
|
|
|
type="text"
|
|
|
|
name="name"
|
|
|
|
id="name"
|
|
|
|
placeholder="Account"
|
|
|
|
value={accountName}
|
|
|
|
onChange={(e: ChangeEvent<HTMLInputElement>) =>
|
|
|
|
setAccountName(e.target.value)
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div className="space-y-6">
|
|
|
|
<InlineNotification type="info" desc={t('insufficient-sol')} />
|
|
|
|
<Button
|
|
|
|
className="mb-4 w-full"
|
|
|
|
onClick={() => handleCreateAccount()}
|
|
|
|
size="large"
|
|
|
|
>
|
|
|
|
Create Account
|
|
|
|
</Button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
</EnterRightExitLeft>
|
|
|
|
<EnterRightExitLeft
|
|
|
|
className="absolute top-0.5 left-0 z-20 w-full bg-th-bkg-1 p-6"
|
2022-08-15 22:10:17 -07:00
|
|
|
show={showSetupStep === 3}
|
2022-08-11 21:20:17 -07:00
|
|
|
style={{ height: 'calc(100% - 12px)' }}
|
|
|
|
>
|
|
|
|
{submitDeposit ? (
|
|
|
|
<div className="flex h-full items-center justify-center">
|
|
|
|
<BounceLoader loadingMessage="Funding your account..." />
|
|
|
|
</div>
|
|
|
|
) : (
|
|
|
|
<div className="flex h-full flex-col justify-between">
|
|
|
|
<div className="relative">
|
2022-07-28 19:51:50 -07:00
|
|
|
<h2 className="mb-4">Fund Your Account</h2>
|
2022-08-11 21:20:17 -07:00
|
|
|
<FadeInFadeOut show={!!depositToken}>
|
2022-07-28 19:51:50 -07:00
|
|
|
<Label text="Amount" />
|
|
|
|
<div className="grid grid-cols-2">
|
|
|
|
<button
|
|
|
|
className="col-span-1 flex items-center rounded-lg rounded-r-none border border-r-0 border-th-bkg-4 bg-th-bkg-1 px-4 hover:bg-th-bkg-2"
|
|
|
|
onClick={() => setDepositToken('')}
|
|
|
|
>
|
|
|
|
<div className="ml-1.5 flex w-full items-center justify-between">
|
|
|
|
<div className="flex items-center">
|
|
|
|
<Image
|
|
|
|
alt=""
|
|
|
|
width="20"
|
|
|
|
height="20"
|
|
|
|
src={`/icons/${depositToken.toLowerCase()}.svg`}
|
|
|
|
/>
|
|
|
|
<p className="ml-1.5 text-xl font-bold text-th-fgd-1">
|
|
|
|
{depositToken}
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
<PencilIcon className="ml-2 h-5 w-5 text-th-fgd-3" />
|
|
|
|
</div>
|
|
|
|
</button>
|
|
|
|
<Input
|
|
|
|
className="col-span-1 w-full rounded-lg rounded-l-none border border-th-bkg-4 bg-th-bkg-1 p-3 text-right text-xl font-bold tracking-wider text-th-fgd-1 focus:outline-none"
|
|
|
|
type="text"
|
|
|
|
name="deposit"
|
|
|
|
id="deposit"
|
|
|
|
placeholder="0.00"
|
|
|
|
value={depositAmount}
|
|
|
|
onChange={(e: ChangeEvent<HTMLInputElement>) =>
|
|
|
|
setDepositAmount(e.target.value)
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</FadeInFadeOut>
|
|
|
|
{!depositToken ? (
|
2022-08-11 21:20:17 -07:00
|
|
|
<div className="absolute top-10 mt-2 h-56 w-full overflow-auto">
|
2022-08-17 22:58:44 -07:00
|
|
|
<div className="flex px-4 pb-2">
|
|
|
|
<div className="w-1/5">
|
|
|
|
<p className="text-xs">{t('token')}</p>
|
|
|
|
</div>
|
|
|
|
<div className="w-2/5 text-right">
|
|
|
|
<p className="text-xs">{t('deposit-rate')}</p>
|
|
|
|
</div>
|
|
|
|
<div className="w-2/5 text-right">
|
|
|
|
<p className="whitespace-nowrap text-xs">
|
|
|
|
{t('wallet-balance')}
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<ActionTokenList
|
|
|
|
banks={banks}
|
|
|
|
onSelect={setDepositToken}
|
|
|
|
showDepositRates
|
|
|
|
sortByKey="walletBalance"
|
|
|
|
/>
|
2022-07-28 19:51:50 -07:00
|
|
|
</div>
|
|
|
|
) : null}
|
|
|
|
</div>
|
|
|
|
<div className="flex flex-col items-center">
|
|
|
|
<Button
|
|
|
|
className="mb-4 w-full"
|
|
|
|
disabled={!depositAmount || !depositToken}
|
|
|
|
onClick={handleDeposit}
|
|
|
|
size="large"
|
|
|
|
>
|
|
|
|
Deposit
|
|
|
|
</Button>
|
|
|
|
<LinkButton onClick={handleEndOnboarding}>
|
|
|
|
Skip for now
|
|
|
|
</LinkButton>
|
|
|
|
</div>
|
2022-07-21 22:09:04 -07:00
|
|
|
</div>
|
2022-07-28 19:51:50 -07:00
|
|
|
)}
|
2022-07-23 04:20:08 -07:00
|
|
|
</EnterRightExitLeft>
|
2022-07-21 22:09:04 -07:00
|
|
|
</div>
|
2022-07-20 21:50:56 -07:00
|
|
|
</Modal>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default UserSetupModal
|