diff --git a/src/app/(mobile-ui)/history/page.tsx b/src/app/(mobile-ui)/history/page.tsx index 2555e3610..a44d3bee4 100644 --- a/src/app/(mobile-ui)/history/page.tsx +++ b/src/app/(mobile-ui)/history/page.tsx @@ -7,7 +7,7 @@ import * as utils from '@/utils' import NavHeader from '@/components/Global/NavHeader' import { PEANUT_API_URL } from '@/constants' -import { useWallet } from '@/hooks/useWallet' +import { useWallet } from '@/hooks/wallet/useWallet' import { IDashboardItem } from '@/interfaces' import { formatAmountWithSignificantDigits, printableAddress } from '@/utils' import { useInfiniteQuery } from '@tanstack/react-query' diff --git a/src/app/(mobile-ui)/home/page.tsx b/src/app/(mobile-ui)/home/page.tsx index 62f6aac54..757780e36 100644 --- a/src/app/(mobile-ui)/home/page.tsx +++ b/src/app/(mobile-ui)/home/page.tsx @@ -6,8 +6,12 @@ import WalletHeader from '@/components/Global/WalletHeader' import { WalletCard } from '@/components/Home/WalletCard' import ProfileSection from '@/components/Profile/Components/ProfileSection' import { useAuth } from '@/context/authContext' -import { useWallet } from '@/hooks/useWallet' import { useZeroDev } from '@/hooks/useZeroDev' +import { useWallet } from '@/hooks/wallet/useWallet' +import { useWalletConnection } from '@/hooks/wallet/useWalletConnection' +import { WalletProviderType } from '@/interfaces' +import { useAppDispatch } from '@/redux/hooks' +import { walletActions } from '@/redux/slices/wallet-slice' import { getUserPreferences, updateUserPreferences } from '@/utils' import classNames from 'classnames' import { motion, useAnimation } from 'framer-motion' @@ -19,28 +23,39 @@ const cardWidth = 300 const cardMargin = 16 export default function Home() { + const dispatch = useAppDispatch() const controls = useAnimation() const router = useRouter() const carouselRef = useRef(null) + const { connectWallet } = useWalletConnection() const [isBalanceHidden, setIsBalanceHidden] = useState(() => { const prefs = getUserPreferences() return prefs?.balanceHidden ?? false }) - const { addBYOW, username } = useAuth() - const { selectedWallet, wallets, isPeanutWallet, isConnected, setSelectedWallet } = useWallet() + const { username } = useAuth() - const hasWallets = wallets.length > 0 - const { handleLogin, isLoggingIn } = useZeroDev() - const toast = useToast() + const { selectedWallet, wallets, isPeanutWallet, isConnected, setSelectedWallet, isWalletConnected } = useWallet() + // initialize focusedIndex to match selectedWalletIndex const rawIndex = wallets.findIndex((wallet) => wallet.address === selectedWallet?.address) const selectedWalletIndex = rawIndex === -1 ? 0 : rawIndex + const [focusedIndex, setFocusedIndex] = useState(selectedWalletIndex) + // update focusedIndex when selectedWallet changes + useEffect(() => { + const index = wallets.findIndex((wallet) => wallet.address === selectedWallet?.address) + if (index !== -1) { + setFocusedIndex(index) + } + }, [selectedWallet, wallets]) + + const hasWallets = wallets.length > 0 + const { handleLogin, isLoggingIn } = useZeroDev() + const toast = useToast() const totalCards = hasWallets ? wallets.length + 1 : 1 - // hide balance const handleToggleBalanceVisibility = (e: React.MouseEvent) => { e.stopPropagation() setIsBalanceHidden((prev: boolean) => { @@ -59,14 +74,55 @@ export default function Home() { const handleCardClick = (index: number) => { if (index < wallets.length) { - if (selectedWalletIndex === index) { + const wallet = wallets[index] + + if (focusedIndex !== index) { + setFocusedIndex(index) + dispatch(walletActions.setFocusedWallet(wallet)) + controls.start({ + x: -(index * (cardWidth + cardMargin)), + transition: { type: 'spring', stiffness: 300, damping: 30 }, + }) + + if (wallet.walletProviderType === WalletProviderType.PEANUT || isWalletConnected(wallet)) { + setSelectedWallet(wallet) + } + return + } + + if (focusedIndex === index) { router.push('/wallet') - } else { - setSelectedWallet(wallets[index]) } } } + const handleDragEnd = (_e: any, { offset, velocity }: any) => { + const swipe = Math.abs(offset.x) * velocity.x + let targetIndex = focusedIndex + + if (swipe < -10000) { + targetIndex = Math.min(focusedIndex + 1, totalCards - 1) + } else if (swipe > 10000) { + targetIndex = Math.max(focusedIndex - 1, 0) + } + + setFocusedIndex(targetIndex) + + if (targetIndex < wallets.length) { + dispatch(walletActions.setFocusedWallet(wallets[targetIndex])) + + const targetWallet = wallets[targetIndex] + if (targetWallet.walletProviderType === WalletProviderType.PEANUT || isWalletConnected(targetWallet)) { + setSelectedWallet(targetWallet) + } + } + + controls.start({ + x: -(targetIndex * (cardWidth + cardMargin)), + transition: { type: 'spring', stiffness: 300, damping: 30 }, + }) + } + return (
@@ -117,43 +173,29 @@ export default function Home() { right: 0, }} dragElastic={0.2} - onDragEnd={(_e, { offset, velocity }) => { - const swipe = Math.abs(offset.x) * velocity.x - if (swipe < -10000) { - const nextIndex = Math.min(selectedWalletIndex + 1, totalCards - 1) - if (nextIndex < wallets.length) { - setSelectedWallet(wallets[nextIndex]) - } - } else if (swipe > 10000) { - const prevIndex = Math.max(selectedWalletIndex - 1, 0) - setSelectedWallet(wallets[prevIndex]) - } else { - controls.start({ - x: -(selectedWalletIndex * (cardWidth + cardMargin)), - transition: { type: 'spring', stiffness: 300, damping: 30 }, - }) - } - }} + onDragEnd={handleDragEnd} > - {wallets.map((wallet, index) => ( - handleCardClick(index)} - index={index} - isBalanceHidden={isBalanceHidden} - onToggleBalanceVisibility={handleToggleBalanceVisibility} - /> - ))} - - + {!!wallets.length && + wallets.map((wallet, index) => ( + handleCardClick(index)} + index={index} + isBalanceHidden={isBalanceHidden} + onToggleBalanceVisibility={handleToggleBalanceVisibility} + isFocused={focusedIndex === index} + /> + ))} + + ) : (
- +
)}
diff --git a/src/app/(mobile-ui)/layout.tsx b/src/app/(mobile-ui)/layout.tsx index 82dc500f3..d187952ff 100644 --- a/src/app/(mobile-ui)/layout.tsx +++ b/src/app/(mobile-ui)/layout.tsx @@ -5,17 +5,17 @@ import { useToast } from '@/components/0_Bruddle/Toast' import Modal from '@/components/Global/Modal' import WalletNavigation from '@/components/Global/WalletNavigation' import HomeWaitlist from '@/components/Home/HomeWaitlist' +import { ThemeProvider } from '@/config' import { peanutWalletIsInPreview } from '@/constants' import { useAuth } from '@/context/authContext' -import { useWallet } from '@/hooks/useWallet' import { useZeroDev } from '@/hooks/useZeroDev' +import { useWallet } from '@/hooks/wallet/useWallet' import { useAppKit } from '@reown/appkit/react' import classNames from 'classnames' import Link from 'next/link' import { usePathname } from 'next/navigation' import { useEffect, useMemo, useState } from 'react' -import '../../styles/globals.bruddle.css' -import { ThemeProvider } from '@/config' +import '../../styles/globals.css' const publicPathRegex = /^\/(request\/pay|claim)/ diff --git a/src/app/(mobile-ui)/wallet/page.tsx b/src/app/(mobile-ui)/wallet/page.tsx index 9b46cf2f6..68156240f 100644 --- a/src/app/(mobile-ui)/wallet/page.tsx +++ b/src/app/(mobile-ui)/wallet/page.tsx @@ -5,22 +5,25 @@ import { ArrowIcon, Button, Card } from '@/components/0_Bruddle' import Icon from '@/components/Global/Icon' import { HomeLink } from '@/components/Home/HomeLink' import { useAuth } from '@/context/authContext' -import { useWallet } from '@/hooks/useWallet' import { WalletProviderType } from '@/interfaces' +import { useWalletStore } from '@/redux/hooks' import { printableUsdc } from '@/utils' import { motion } from 'framer-motion' import Link from 'next/link' const WalletDetailsPage = () => { - const { selectedWallet } = useWallet() + const { focusedWallet, wallets } = useWalletStore() const { user } = useAuth() - const isActiveWalletPW = selectedWallet?.walletProviderType === WalletProviderType.PEANUT - const isActiveWalletBYOW = selectedWallet?.walletProviderType === WalletProviderType.BYOW + + const walletDetails = wallets.find((wallet) => wallet.address === focusedWallet) + + const isActiveWalletPW = walletDetails?.walletProviderType === WalletProviderType.PEANUT + const isActiveWalletBYOW = walletDetails?.walletProviderType === WalletProviderType.BYOW return (
- {selectedWallet && ( + {focusedWallet && ( @@ -31,7 +34,7 @@ const WalletDetailsPage = () => { )} {isActiveWalletBYOW && (

- {selectedWallet.address}.peanut.wallet + {walletDetails.address}.peanut.wallet

)}
@@ -40,7 +43,7 @@ const WalletDetailsPage = () => { -
$ {printableUsdc(selectedWallet?.balance ?? 0n)}
+
$ {printableUsdc(walletDetails?.balance ?? 0n)}
diff --git a/src/app/(setup)/layout.tsx b/src/app/(setup)/layout.tsx index 972e1c82b..ef56bf54e 100644 --- a/src/app/(setup)/layout.tsx +++ b/src/app/(setup)/layout.tsx @@ -5,7 +5,7 @@ import { useAppDispatch } from '@/redux/hooks' import { setupActions } from '@/redux/slices/setup-slice' import { useEffect } from 'react' import { setupSteps } from '../../components/Setup/Setup.consts' -import '../../styles/globals.bruddle.css' +import '../../styles/globals.css' const SetupLayout = ({ children }: { children?: React.ReactNode }) => { const dispatch = useAppDispatch() diff --git a/src/app/page.tsx b/src/app/page.tsx index 00166390f..b2c652b46 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -1,10 +1,10 @@ 'use client' -import { useState, useEffect } from 'react' import * as assets from '@/assets' import Layout from '@/components/Global/Layout' -import { Hero, FAQs, Features, Mike, Story, BuildOnUs } from '@/components/LandingPage' +import { BuildOnUs, FAQs, Features, Hero, Mike, Story } from '@/components/LandingPage' import { useFooterVisibility } from '@/context/footerVisibility' +import { useEffect, useState } from 'react' export default function LandingPage() { const hero = { @@ -154,7 +154,7 @@ export default function LandingPage() { -
+
diff --git a/src/assets/bg/peanut-bg.svg b/src/assets/bg/peanut-bg.svg index ce64e2f71..baeaee111 100644 --- a/src/assets/bg/peanut-bg.svg +++ b/src/assets/bg/peanut-bg.svg @@ -1,4 +1,4 @@ - + diff --git a/src/components/0_Bruddle/Button.tsx b/src/components/0_Bruddle/Button.tsx index 74b5c5cb5..da3b39a17 100644 --- a/src/components/0_Bruddle/Button.tsx +++ b/src/components/0_Bruddle/Button.tsx @@ -24,7 +24,7 @@ const buttonVariants: Record = { 'transparent-light': 'btn-transparent-light', 'transparent-dark': 'btn-transparent-dark', green: 'bg-green-1', - yellow: 'bg-yellow-1', + yellow: 'bg-secondary-1', } const buttonSizes: Record = { @@ -64,7 +64,7 @@ export const Button = forwardRef( ref ) => { const buttonClasses = twMerge( - 'btn w-full', + 'btn w-full flex items-center gap-2', buttonVariants[variant], size && buttonSizes[size], shape === 'square' && 'btn-square', diff --git a/src/components/0_Bruddle/Card.tsx b/src/components/0_Bruddle/Card.tsx index 56e171bd9..049dce5ad 100644 --- a/src/components/0_Bruddle/Card.tsx +++ b/src/components/0_Bruddle/Card.tsx @@ -47,13 +47,13 @@ const Header = ({ children, className, ...props }: React.HTMLAttributes) => ( -

+

{children}

) const Description = ({ children, className, ...props }: React.HTMLAttributes) => ( -

+

{children}

) diff --git a/src/components/0_Bruddle/Field.tsx b/src/components/0_Bruddle/Field.tsx index 735b7291b..2427c58c8 100644 --- a/src/components/0_Bruddle/Field.tsx +++ b/src/components/0_Bruddle/Field.tsx @@ -1,10 +1,9 @@ 'use client' -import Icon, { IconNameType } from '../Global/Icon' -import { useFormContext } from 'react-hook-form' import classNames from 'classnames' -import React from 'react' -import { DetailedHTMLProps, InputHTMLAttributes, useState } from 'react' +import React, { DetailedHTMLProps, InputHTMLAttributes, useState } from 'react' +import { useFormContext } from 'react-hook-form' +import Icon, { IconNameType } from '../Global/Icon' import BaseInput from './BaseInput' type FieldProps = DetailedHTMLProps, HTMLInputElement> & { @@ -34,7 +33,7 @@ export const Field = React.forwardRef( { 'pr-15': icon || type === 'password', '!border-green-1 pr-15': success, - '!border-pink-1 pr-15': error, + '!border-primary-1 pr-15': error, }, className )} @@ -62,7 +61,7 @@ export const Field = React.forwardRef( {(success || error) && ( diff --git a/src/components/0_Bruddle/Title.tsx b/src/components/0_Bruddle/Title.tsx index a405eac60..fd6a45067 100644 --- a/src/components/0_Bruddle/Title.tsx +++ b/src/components/0_Bruddle/Title.tsx @@ -10,10 +10,10 @@ const Title = ({ } & React.HTMLAttributes) => { return (
-

+

{text}

-

{text}

+

{text}

) } diff --git a/src/components/About/index.tsx b/src/components/About/index.tsx index d7b1b7791..9d4c5bd58 100644 --- a/src/components/About/index.tsx +++ b/src/components/About/index.tsx @@ -1,6 +1,6 @@ import * as assets from '@/assets' -import { MarqueeComp } from '../Global/MarqueeWrapper' import { SmileStars } from '@/assets' +import { MarqueeComp } from '../Global/MarqueeWrapper' const listItems = [ { @@ -20,7 +20,7 @@ const listItems = [ { name: 'Lens', url: 'https://lenster.xyz/u/hugo0.lens' }, { name: 'www', url: 'https://hugomontenegro.com/' }, ], - bg: 'bg-purple-1', + bg: 'bg-primary-1', }, { name: 'Konrad Urban', @@ -37,7 +37,7 @@ const listItems = [ { name: 'Lens', url: 'https://lenster.xyz/u/kkonrad.lens' }, { name: 'www', url: 'https://kkonrad.com/' }, ], - bg: 'bg-yellow-1', + bg: 'bg-secondary-1', }, { name: '______ ______', @@ -51,7 +51,7 @@ const listItems = [ { name: 'dm us', url: 'https://www.peanut.to/jobs' }, { name: 'jobs', url: '/jobs' }, ], - bg: 'bg-pink-1', + bg: 'bg-primary-1', }, ] diff --git a/src/components/Cashout/CashoutStatus.tsx b/src/components/Cashout/CashoutStatus.tsx index 9ccd28a3f..46a1c5385 100644 --- a/src/components/Cashout/CashoutStatus.tsx +++ b/src/components/Cashout/CashoutStatus.tsx @@ -1,11 +1,10 @@ 'use client' -import { useEffect, useState } from 'react' import * as assets from '@/assets' -import { generateKeysFromString } from '@squirrel-labs/peanut-sdk' import * as utils from '@/utils' import Link from 'next/link' -import Icon from '../Global/Icon' +import { useEffect, useState } from 'react' import { Card } from '../0_Bruddle' +import Icon from '../Global/Icon' export const CashoutStatus = () => { const [cashoutStatus, setCashoutStatus] = useState<'FOUND' | 'NOT FOUND' | undefined>(undefined) @@ -47,7 +46,7 @@ export const CashoutStatus = () => { {cashoutStatus === 'FOUND' ? ( -
+