-
Notifications
You must be signed in to change notification settings - Fork 202
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: use one move funds button only (#1952)
- Loading branch information
1 parent
b9cc692
commit bc69c11
Showing
2 changed files
with
52 additions
and
58 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
packages/arb-token-bridge-ui/src/components/TransferPanel/MoveFundsButton.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { twMerge } from 'tailwind-merge' | ||
|
||
import { useNetworks } from '../../hooks/useNetworks' | ||
import { getBridgeUiConfigForChain } from '../../util/bridgeUiConfig' | ||
import { useAppContextState } from '../App/AppContext' | ||
import { Button } from '../common/Button' | ||
import { useTransferReadiness } from './useTransferReadiness' | ||
import { useAccountType } from '../../hooks/useAccountType' | ||
import { useNetworksRelationship } from '../../hooks/useNetworksRelationship' | ||
import { getNetworkName } from '../../util/networks' | ||
|
||
export function MoveFundsButton({ | ||
onClick | ||
}: Pick<React.ButtonHTMLAttributes<HTMLButtonElement>, 'onClick'>) { | ||
const { layout } = useAppContextState() | ||
const { isTransferring } = layout | ||
|
||
const [networks] = useNetworks() | ||
const { isDepositMode } = useNetworksRelationship(networks) | ||
const { color: destinationChainUIcolor } = getBridgeUiConfigForChain( | ||
networks.destinationChain.id | ||
) | ||
const { isSmartContractWallet } = useAccountType() | ||
const { transferReady } = useTransferReadiness() | ||
|
||
return ( | ||
<Button | ||
variant="primary" | ||
loading={isTransferring} | ||
disabled={ | ||
isDepositMode ? !transferReady.deposit : !transferReady.withdrawal | ||
} | ||
onClick={onClick} | ||
style={{ | ||
borderColor: destinationChainUIcolor, | ||
backgroundColor: `${destinationChainUIcolor}66` | ||
}} | ||
className={twMerge( | ||
'w-full border py-3 text-lg', | ||
'disabled:!border-white/10 disabled:!bg-white/10', | ||
'lg:text-2xl' | ||
)} | ||
> | ||
{isSmartContractWallet && isTransferring | ||
? 'Sending request...' | ||
: `Move funds to ${getNetworkName(networks.destinationChain.id)}`} | ||
</Button> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters