Skip to content

Commit

Permalink
Merge pull request #206 from concero/fix/deposit-card-states
Browse files Browse the repository at this point in the history
Fix deposit button state in swap input card
  • Loading branch information
babamovandrej authored Jan 9, 2025
2 parents 8beace7 + 2bee2bd commit 70786b6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/components/pool/PoolCard/SwapButton/SwapButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,22 @@ import { useAppKit } from '@reown/appkit/react'
import { useAccount } from 'wagmi'
import { Button } from '../../../buttons/Button/Button'

export const SwapButton = ({ error, onClick, isLoading, isDeposit }: SwapButtonProps) => {
export const SwapButton = ({ onClick, isLoading, isDeposit, isDepositDisabled }: SwapButtonProps) => {
const { isConnected } = useAccount()
const { open } = useAppKit()

const actionText: string = isDeposit ? 'Request Deposit' : 'Request Withdrawal'
const isDisabled: boolean = (isDeposit && isDepositDisabled) || !isConnected

return (
<Button isFull size="lg" variant="primary" isLoading={isLoading} onClick={isConnected ? onClick : open}>
<Button
isFull
size="lg"
variant="primary"
isLoading={isLoading}
onClick={isConnected ? e => onClick(e) : () => open()}
isDisabled={isDisabled}
>
{isConnected ? actionText : 'Connect Wallet'}
</Button>
)
Expand Down
1 change: 1 addition & 0 deletions src/components/pool/PoolCard/SwapButton/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { type ErrorType } from './constants'

export interface SwapButtonProps {
isLoading: boolean
isDepositDisabled: boolean
error: ErrorType | null
onClick: (e: React.MouseEvent<HTMLButtonElement>) => void
isDeposit: boolean
Expand Down
1 change: 1 addition & 0 deletions src/components/pool/PoolCard/SwapInput/SwapInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export const SwapInput = ({ swapState, swapDispatch, onClose }: SwapInputProps)
<SwapDetails swapState={swapState} swapDispatch={swapDispatch} />

<SwapButton
isDepositDisabled={!amountIsAvailable}
isDeposit={isDeposit}
isLoading={swapState.isLoading}
error={swapState.inputError}
Expand Down

0 comments on commit 70786b6

Please sign in to comment.