Skip to content

Commit

Permalink
Fix bugs with send form and home buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
youngkidwarrior committed Sep 23, 2024
1 parent 102557c commit d6997bb
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
8 changes: 6 additions & 2 deletions packages/app/components/FormFields/CoinField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ import { useSendAccount } from 'app/utils/send-accounts'
import { useId, useState } from 'react'
import { useBalance, type UseBalanceReturnType } from 'wagmi'
import { IconCoin } from '../icons/IconCoin'
export const CoinField = ({ native = false, ...props }: Pick<SelectProps, 'size' | 'native'>) => {
export const CoinField = ({
native = false,
...props
}: Pick<SelectProps, 'size' | 'native' | 'defaultValue'>) => {
const [isOpen, setIsOpen] = useState(false)

const {
Expand All @@ -48,9 +51,10 @@ export const CoinField = ({ native = false, ...props }: Pick<SelectProps, 'size'
<Select
native={native}
id={id}
value={field.value || usdcAddress[baseMainnet.id]}
value={field.value}
onValueChange={field.onChange}
onOpenChange={setIsOpen}
defaultValue={usdcAddress[baseMainnet.id]}
open={isOpen}
{...props}
>
Expand Down
2 changes: 1 addition & 1 deletion packages/app/components/TopNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ export function TopNav({
<Separator w={'100%'} borderColor="$jet" $lg={{ display: 'none' }} />
</Container>
)}
<Separator w={'100%'} borderColor="$decay" $gtLg={{ display: 'none' }} />
<Separator w={'100%'} borderColor="$decay" $gtLg={{ display: 'none' }} mt="$2" />
{!media.gtLg && selectedCoin && selectedCoin.label !== 'USDC' && (
<Container pos="relative">
<View
Expand Down
4 changes: 3 additions & 1 deletion packages/app/features/home/HomeButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
useMedia,
type LinkableButtonProps,
} from '@my/ui'
import { useSendAccount } from 'app/utils/send-accounts'

const Row = styled(XStack, {
w: '100%',
Expand All @@ -35,6 +36,7 @@ export const HomeButtonRow = ({
}: XStackProps & { isVisible?: boolean }) => {
const isPwa = usePwa()
const media = useMedia()
const { isLoading: isSendAccountLoading } = useSendAccount()
const { balances, isLoading: balancesIsLoading } = useSendAccountBalances()
const usdcBalance = balances?.USDC
const canSend =
Expand All @@ -43,7 +45,7 @@ export const HomeButtonRow = ({

return (
<AnimatePresence>
{!balancesIsLoading && isVisible && (
{!balancesIsLoading && !isSendAccountLoading && isVisible && (
<Stack
w={'100%'}
pb={isPwa ? '$1' : '$5'}
Expand Down
6 changes: 4 additions & 2 deletions packages/app/features/send/SendAmountForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ export function SendAmountForm() {

async function onSubmit() {
if (!canSubmit) return
const sendToken = sendParams.sendToken || usdcAddress[baseMainnet.id]

const amount = formatUnits(parsedAmount, selectedCoin.decimals)
router.push({
Expand Down Expand Up @@ -127,6 +126,9 @@ export function SendAmountForm() {
form.setValue('amount', formattedText)
},
},
token: {
defaultValue: sendToken,
},
}}
formProps={{
testID: 'SendForm',
Expand All @@ -137,7 +139,7 @@ export function SendAmountForm() {
height: '100%',
}}
defaultValues={{
token: sendParams.sendToken || usdcAddress[baseMainnet.id],
token: sendToken,
amount: sendParams.amount,
}}
renderAfter={({ submit }) => (
Expand Down

0 comments on commit d6997bb

Please sign in to comment.