From 3389e6de8fb66a830db360ceb759d7174fd80d88 Mon Sep 17 00:00:00 2001 From: kushagrasarathe <76868364+kushagrasarathe@users.noreply.github.com> Date: Wed, 22 Jan 2025 00:24:39 +0530 Subject: [PATCH 1/2] fix: prev conflict messup when merging pr's --- src/app/(mobile-ui)/home/page.tsx | 6 ++++-- src/app/(mobile-ui)/wallet/page.tsx | 25 ++++++++++++------------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/app/(mobile-ui)/home/page.tsx b/src/app/(mobile-ui)/home/page.tsx index aa2a7ed7..8fda8841 100644 --- a/src/app/(mobile-ui)/home/page.tsx +++ b/src/app/(mobile-ui)/home/page.tsx @@ -43,13 +43,15 @@ export default function Home() { const selectedWalletIndex = rawIndex === -1 ? 0 : rawIndex const [focusedIndex, setFocusedIndex] = useState(selectedWalletIndex) - // update focusedIndex when selectedWallet changes + // update focusedIndex and focused wallet when selectedWallet changes useEffect(() => { const index = wallets.findIndex((wallet) => wallet.address === selectedWallet?.address) if (index !== -1) { setFocusedIndex(index) + // also update the focused wallet when selected wallet changes + dispatch(walletActions.setFocusedWallet(wallets[index])) } - }, [selectedWallet, wallets]) + }, [selectedWallet, wallets, dispatch]) const hasWallets = wallets.length > 0 const { handleLogin, isLoggingIn } = useZeroDev() diff --git a/src/app/(mobile-ui)/wallet/page.tsx b/src/app/(mobile-ui)/wallet/page.tsx index ccf9a884..38e3251d 100644 --- a/src/app/(mobile-ui)/wallet/page.tsx +++ b/src/app/(mobile-ui)/wallet/page.tsx @@ -9,26 +9,25 @@ import NavHeader from '@/components/Global/NavHeader' import { WalletCard } from '@/components/Home/WalletCard' import { useAuth } from '@/context/authContext' import { useWallet } from '@/hooks/wallet/useWallet' -import { IUserBalance, WalletProviderType } from '@/interfaces' +import { IUserBalance } from '@/interfaces' +import { useWalletStore } from '@/redux/hooks' import { formatAmount, getChainName, getUserPreferences, updateUserPreferences } from '@/utils' import { useAppKit, useDisconnect } from '@reown/appkit/react' import { useState } from 'react' import { twMerge } from 'tailwind-merge' const WalletDetailsPage = () => { - const { selectedWallet, isConnected } = useWallet() const { open } = useAppKit() const { disconnect } = useDisconnect() + const { focusedWallet, wallets } = useWalletStore() + const { isConnected } = useWallet() + const { username } = useAuth() const [isBalanceHidden, setIsBalanceHidden] = useState(() => { const prefs = getUserPreferences() return prefs?.balanceHidden ?? false }) - const { username } = useAuth() - const isActiveWalletPW = selectedWallet?.walletProviderType === WalletProviderType.PEANUT - const isActiveWalletBYOW = selectedWallet?.walletProviderType === WalletProviderType.BYOW - - console.log('selectedWallet', selectedWallet) + const walletDetails = wallets.find((wallet) => wallet.address === focusedWallet) const handleToggleBalanceVisibility = (e: React.MouseEvent) => { e.stopPropagation() @@ -46,11 +45,11 @@ const WalletDetailsPage = () => {
- {selectedWallet && ( + {focusedWallet && walletDetails && ( {}} @@ -75,14 +74,14 @@ const WalletDetailsPage = () => {
- {!!selectedWallet?.balances?.length ? ( + {!!walletDetails?.balances?.length ? (
Balance
- {selectedWallet.balances.map((balance: IUserBalance) => ( + {walletDetails.balances.map((balance: IUserBalance) => ( Date: Wed, 22 Jan 2025 00:41:50 +0530 Subject: [PATCH 2/2] feat: add wallet header in req view --- .../Request/Create/Views/Initial.view.tsx | 146 +++++++++--------- 1 file changed, 75 insertions(+), 71 deletions(-) diff --git a/src/components/Request/Create/Views/Initial.view.tsx b/src/components/Request/Create/Views/Initial.view.tsx index 347317b4..3f8f4797 100644 --- a/src/components/Request/Create/Views/Initial.view.tsx +++ b/src/components/Request/Create/Views/Initial.view.tsx @@ -2,6 +2,7 @@ import { Button, Card } from '@/components/0_Bruddle' import { getTokenDetails } from '@/components/Create/Create.utils' import AddressInput from '@/components/Global/AddressInput' import FileUploadInput, { IFileUploadInputProps } from '@/components/Global/FileUploadInput' +import FlowHeader from '@/components/Global/FlowHeader' import Loading from '@/components/Global/Loading' import TokenAmountInput from '@/components/Global/TokenAmountInput' import TokenSelector from '@/components/Global/TokenSelector/TokenSelector' @@ -165,80 +166,83 @@ export const InitialView = ({ }, [isPeanutWallet, selectedWallet?.address]) return ( - - - Request a payment - - Choose the amount, token and chain. You will request a payment to your wallet. Add an invoice if you - want to. - - - -
- { - _setTokenValue(value ?? '') - }} - tokenValue={_tokenValue} - onSubmit={() => { - handleOnNext({ - recipientAddress, - tokenAddress: selectedTokenAddress, - chainId: selectedChainID, - userBalances: selectedWallet?.balances ?? [], - tokenValue, - tokenData: selectedTokenData, - attachmentOptions, - }) - }} - /> - {isExternalWallet && } - - {isExternalWallet && ( - { - setRecipientAddress(update.value) - setInputChanging(update.isChanging) - setIsValidRecipient(update.isValid) - }} +
+ + + + Request a payment + + Choose the amount, token and chain. You will request a payment to your wallet. Add an invoice if + you want to. + + + +
+ { + _setTokenValue(value ?? '') + }} + tokenValue={_tokenValue} + onSubmit={() => { + handleOnNext({ + recipientAddress, + tokenAddress: selectedTokenAddress, + chainId: selectedChainID, + userBalances: selectedWallet?.balances ?? [], + tokenValue, + tokenData: selectedTokenData, + attachmentOptions, + }) + }} /> - )} - -
- {errorState.showError && ( -
- +
- )} -
-
+ {errorState.showError && ( +
+ +
+ )} + + +
) }