From 55da8b1121c02c80903958f8317046c0f03bef0a Mon Sep 17 00:00:00 2001 From: danilo-89 Date: Sat, 20 Apr 2024 14:29:27 +0200 Subject: [PATCH] code cleanup --- app/page.tsx | 64 ++++--------------- components/NFTGallery/Modal/Modal.tsx | 10 ++- components/NFTGallery/NFTGallery.tsx | 8 +-- components/NftCard/NftCard.tsx | 10 +-- components/common/Button/Button.tsx | 2 +- components/common/Footer/Footer.tsx | 5 +- .../common/LoaderSquare/LoaderSquare.tsx | 2 +- components/common/Modal/Modal.tsx | 2 +- components/common/Nav/Nav.tsx | 2 +- components/common/Title/Title.tsx | 2 +- components/index.ts | 27 ++++++++ .../sections/SectionHero/SectionHero.tsx | 7 +- .../SectionMint/ClaimedNFT/ClaimedNFT.tsx | 5 +- .../sections/SectionMint/Faucet/Faucet.tsx | 7 +- .../SectionMint/InfoMessage/InfoMessage.tsx | 4 +- .../InfoMessageWrapper/InfoMessageWrapper.tsx | 2 +- .../SectionMint/InputNft/InputNft.tsx | 9 +-- .../sections/SectionMint/SectionMint.tsx | 42 ++++++------ .../SectionMintBottom/SectionMintBottom.tsx | 2 +- .../StatusMessage/StatusMessage.tsx | 2 +- .../WrongNetworkNotice/WrongNetworkNotice.tsx | 17 +++-- .../SectionRoadmap/SectionRoadmap.tsx | 4 +- .../AngledContentStripe.tsx | 2 +- .../shared/ButtonAccount/ButtonAccount.tsx | 13 ++-- .../shared/ButtonConnect/ButtonConnect.tsx | 4 +- context/ContractContext.tsx | 4 +- context/UserContext.tsx | 6 +- context/index.ts | 2 + contract/index.ts | 2 + hooks/index.ts | 4 ++ hooks/useIsWrongNetwork.tsx | 4 +- hooks/useMint.tsx | 12 ++-- ...ndindicator.tsx => useScrollIndicator.tsx} | 0 requests/index.ts | 2 +- stories/Button.stories.tsx | 2 +- stories/InfoMessageWrapper.stories.tsx | 2 +- stories/LoaderDots.stories.tsx | 2 +- stories/LoaderSquare.stories.tsx | 2 +- stories/NFTCard.stories.tsx | 3 +- stories/Title.stories.tsx | 2 +- types/index.ts | 7 ++ utils/errorHandling.ts | 1 + 42 files changed, 156 insertions(+), 155 deletions(-) create mode 100644 components/index.ts create mode 100644 context/index.ts create mode 100644 contract/index.ts create mode 100644 hooks/index.ts rename hooks/{useScrollIndindicator.tsx => useScrollIndicator.tsx} (100%) create mode 100644 types/index.ts diff --git a/app/page.tsx b/app/page.tsx index 12a47b7..38ae74b 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -2,34 +2,25 @@ import { QueryClient, QueryClientProvider } from '@tanstack/react-query' import { WagmiProvider, http } from 'wagmi' -// import { publicProvider } from 'wagmi/providers/public' import { defineChain } from 'viem' -import { polygonAmoy } from 'viem/chains' -// import { alchemyProvider } from 'wagmi/providers/alchemy' -import { - Locale, - RainbowKitProvider, - connectorsForWallets, - getDefaultConfig, - getDefaultWallets, -} from '@rainbow-me/rainbowkit' - +import { RainbowKitProvider, getDefaultConfig } from '@rainbow-me/rainbowkit' import { metaMaskWallet, injectedWallet } from '@rainbow-me/rainbowkit/wallets' import '@rainbow-me/rainbowkit/styles.css' + // Contexts -import { UserProvider } from '@/context/UserContext' -import { ContractProvider } from '@/context/ContractContext' +import { UserProvider, ContractProvider } from '@/context' // Hooks -import useIsMounted from '@/hooks/useIsMounted' +import { useIsMounted } from '@/hooks' // Components -import Nav from '@/components/common/Nav' -import SectionHero from '@/components/sections/SectionHero' -import SectionMint from '@/components/sections/SectionMint' -import SectionRoadmap from '@/components/sections/SectionRoadmap/SectionRoadmap' -import Footer from '@/components/common/Footer/Footer' -import { useRouter } from 'next/navigation' +import { + Nav, + SectionHero, + SectionMint, + SectionRoadmap, + Footer, +} from '@/components' const RPC_PUBLIC = process.env.NEXT_PUBLIC_RPC_PUBLIC as string const CHAIN_ID = process.env.NEXT_PUBLIC_CHAIN_ID as string @@ -75,14 +66,6 @@ const preferredChain = defineChain({ testnet: true, }) -// const { chains, publicClient, webSocketPublicClient } = configureChains( -// [preferredChain], -// [ -// publicProvider(), -// alchemyProvider({ apiKey: process.env.NEXT_PUBLIC_ALCHEMY || '' }), -// ] -// ) - const config = getDefaultConfig({ appName: 'SittingCatsNFT', projectId: WALLET_CONNECT_PROJECT_ID, @@ -101,26 +84,6 @@ const config = getDefaultConfig({ ssr: true, }) -// const connectors = connectorsForWallets( -// [ -// { -// groupName: 'Recommended', -// wallets: [injectedWallet, metaMaskWallet], -// }, -// ], -// { -// appName: 'My RainbowKit App', -// projectId: 'YOUR_PROJECT_ID', -// } -// ) - -// const config = createConfig({ -// autoConnect: true, -// publicClient, -// webSocketPublicClient, -// connectors, -// }) - const queryClient = new QueryClient() export default function Home() { @@ -129,10 +92,7 @@ export default function Home() { return ( - +
diff --git a/components/NFTGallery/Modal/Modal.tsx b/components/NFTGallery/Modal/Modal.tsx index 0239def..cebe829 100644 --- a/components/NFTGallery/Modal/Modal.tsx +++ b/components/NFTGallery/Modal/Modal.tsx @@ -1,13 +1,11 @@ -import { Dispatch, SetStateAction } from 'react' +import type { Dispatch, SetStateAction } from 'react' import { useAccount, useDisconnect } from 'wagmi' // Hooks -import useIsWrongNetwork from '@/hooks/useIsWrongNetwork' +import { useIsWrongNetwork } from '@/hooks' // Components -import Button from '@/components/common/Button' -import Modal from '@/components/common/Modal' -import NFTGalery from '../NFTGallery' +import { Button, Modal, NFTGallery } from '@/components' interface IProps { isOpen: boolean @@ -22,7 +20,7 @@ const NFTGalleryModal = ({ isOpen, setIsOpen }: IProps) => { if (isOpen && isConnected && !isWrongNetwork) { return ( - +