|
| 1 | +'use client'; |
| 2 | + |
| 3 | +import ConnectWallet from '@/components/ConnectWallet'; |
| 4 | +import Header from '@/components/Header'; |
| 5 | +import RaidGuild from '@/components/icons/RaidGuild'; |
| 6 | +import { Button } from '@/components/ui/button'; |
| 7 | +import { Card } from '@/components/ui/card'; |
| 8 | +import Skeleton from '@/components/ui/skeleton'; |
| 9 | +import WrapperForm from '@/components/WrapperForm'; |
| 10 | +import cn from '@/lib/utils'; |
| 11 | +import '@rainbow-me/rainbowkit/styles.css'; |
| 12 | +import Link from 'next/link'; |
| 13 | +import React, { Suspense, useEffect, useState } from 'react'; |
| 14 | +import { useAccount } from 'wagmi'; |
| 15 | + |
| 16 | +const Home = () => { |
| 17 | + const [deposit, setDeposit] = useState<boolean>(true); |
| 18 | + const { isConnected, chain } = useAccount(); |
| 19 | + const [mounted, setMounted] = useState(false); |
| 20 | + |
| 21 | + useEffect(() => { |
| 22 | + setMounted(true); |
| 23 | + }, []); |
| 24 | + |
| 25 | + const onButtonSelection = (index: number) => { |
| 26 | + switch (index) { |
| 27 | + case 0: |
| 28 | + setDeposit(true); |
| 29 | + break; |
| 30 | + case 1: |
| 31 | + setDeposit(false); |
| 32 | + break; |
| 33 | + default: |
| 34 | + // eslint-disable-next-line no-console |
| 35 | + console.log(`Invalid input: ${index}`); |
| 36 | + } |
| 37 | + }; |
| 38 | + |
| 39 | + return ( |
| 40 | + <div className='container mx-auto max-w-[80ch]'> |
| 41 | + <Header> |
| 42 | + <Suspense fallback={<Skeleton className='h-10 w-20' />}> |
| 43 | + <ConnectWallet /> |
| 44 | + </Suspense> |
| 45 | + </Header> |
| 46 | + <h1 className='font-uncial mt-10 text-center text-7xl font-semibold'> |
| 47 | + Wrap Eth |
| 48 | + </h1> |
| 49 | + <Card className='mt-6 w-full rounded-xs border-2 border-white p-32'> |
| 50 | + <div className='flex items-center justify-center'> |
| 51 | + <Button |
| 52 | + onClick={() => onButtonSelection(0)} |
| 53 | + className={cn( |
| 54 | + 'pointer rounded-xs rounded-r-none uppercase hover:bg-purple-600', |
| 55 | + deposit ? 'hover:bg-primary bg-purple-600' : 'bg-secondary' |
| 56 | + )} |
| 57 | + > |
| 58 | + Wrap {mounted ? chain?.nativeCurrency?.symbol || 'ETH' : 'ETH'} |
| 59 | + </Button> |
| 60 | + <Button |
| 61 | + onClick={() => onButtonSelection(1)} |
| 62 | + className={cn( |
| 63 | + 'pointer rounded-xs rounded-l-none uppercase hover:bg-purple-600', |
| 64 | + deposit ? 'bg-secondary' : 'hover:bg-primary bg-purple-600' |
| 65 | + )} |
| 66 | + > |
| 67 | + Unwrap W{mounted ? chain?.nativeCurrency?.symbol || 'ETH' : 'ETH'} |
| 68 | + </Button> |
| 69 | + </div> |
| 70 | + |
| 71 | + {mounted && isConnected ? ( |
| 72 | + <WrapperForm action={deposit ? 'deposit' : 'withdraw'} /> |
| 73 | + ) : ( |
| 74 | + <h1 className='font-uncial mt-5 text-center text-2xl font-semibold text-white'> |
| 75 | + Connect to {deposit ? 'wrap' : 'unwrap'} ETH |
| 76 | + </h1> |
| 77 | + )} |
| 78 | + </Card> |
| 79 | + |
| 80 | + <div className='my-6 mr-48 flex w-full justify-center md:justify-end'> |
| 81 | + <Link |
| 82 | + className='flex flex-col items-center justify-center gap-1.5' |
| 83 | + href='https://raidguild.org' |
| 84 | + target='_blank' |
| 85 | + rel='noopener noreferrer' |
| 86 | + > |
| 87 | + <h1 className='font-uncial text-xl font-semibold text-white'> |
| 88 | + Brought to you by: |
| 89 | + </h1> |
| 90 | + <RaidGuild className='text-primary h-14 w-50' /> |
| 91 | + </Link> |
| 92 | + </div> |
| 93 | + </div> |
| 94 | + ); |
| 95 | +}; |
| 96 | + |
| 97 | +export default Home; |
0 commit comments