import { Transition } from '@headlessui/react' import { useTranslation } from 'next-i18next' import { ChangeEvent, useEffect, useState } from 'react' import { ModalProps } from '../../types/modal' import { PROFILE_CATEGORIES } from '../../utils/profile' import Input from '../forms/Input' import Label from '../forms/Label' import Select from '../forms/Select' import Button, { LinkButton } from '../shared/Button' import InlineNotification from '../shared/InlineNotification' import Modal from '../shared/Modal' import useLocalStorageState from '../../hooks/useLocalStorageState' import { CheckCircleIcon, PencilIcon } from '@heroicons/react/solid' import { useWallet } from '@solana/wallet-adapter-react' import { handleWalletConnect } from '../../utils/wallet' import mangoStore from '../../store/state' import { IS_ONBOARDED_KEY } from '../Layout' import DepositTokenList from '../shared/DepositTokenList' import { EnterRightExitLeft, FadeInFadeOut } from '../shared/Transitions' import Image from 'next/image' import BounceLoader from '../shared/BounceLoader' import { notify } from '../../utils/notifications' const UserSetupModal = ({ isOpen, onClose }: ModalProps) => { const { t } = useTranslation() const { select, wallet, wallets } = useWallet() const mangoAccount = mangoStore((s) => s.mangoAccount.current) const mangoAccountLoading = mangoStore((s) => s.mangoAccount.loading) const [profileName, setProfileName] = useState('') const [profileCategory, setProfileCategory] = useState('') const [showSetupStep, setShowSetupStep] = useState(0) // const [acceptRisks, setAcceptRisks] = useState(false) const [depositToken, setDepositToken] = useState('') const [depositAmount, setDepositAmount] = useState('') const [submitDeposit, setSubmitDeposit] = useState(false) const [, setIsOnboarded] = useLocalStorageState(IS_ONBOARDED_KEY) const handleNextStep = () => { setShowSetupStep(showSetupStep + 1) } const handleSaveProfile = () => { // save profile details to db then: setShowSetupStep(2) } const handleEndOnboarding = () => { setIsOnboarded(true) onClose() } const connectWallet = async () => { if (wallet) { handleWalletConnect(wallet) } } useEffect(() => { if (mangoAccount) { setShowSetupStep(3) } }, [mangoAccount]) const handleDeposit = async () => { 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 try { setSubmitDeposit(true) const tx = await client.tokenDeposit( group, mangoAccount, depositToken, 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) console.log('Error depositing:', e) } } return (

Welcome.

{ "You're seconds away from trading the most liquid dex markets on Solana." }

Trusted by 1,000s of DeFi users

Deeply liquid markets

Up to 20x leverage across 100s of tokens

Earn interest on your deposits

Borrow 100s of tokens with many collateral options

{mangoAccountLoading ? (
) : (

Connect Wallet

If you don't have a Mango Account yet, we'll create one for you.

Choose Wallet

{wallets?.map((w) => ( ))}
)}

Create Profile

Your public facing identity on Mango...

Skip for now
{submitDeposit ? (
) : (

Fund Your Account

{!depositToken ? (
) : null}
Skip for now
)}
) } export default UserSetupModal