mirror of
https://github.com/status-im/safe-react.git
synced 2025-02-17 12:07:09 +00:00
WA-238 disable Withdrawn button
This commit is contained in:
parent
d7ff250c18
commit
e10828e5c4
@ -10,14 +10,16 @@ import { type DailyLimit } from '~/routes/safe/store/model/dailyLimit'
|
||||
type Props = {
|
||||
dailyLimit: DailyLimit,
|
||||
onWithdrawn: () => void,
|
||||
balance: string,
|
||||
}
|
||||
|
||||
export const WITHDRAWN_BUTTON_TEXT = 'Withdrawn'
|
||||
|
||||
const DailyLimitComponent = ({ dailyLimit, onWithdrawn }: Props) => {
|
||||
const DailyLimitComponent = ({ dailyLimit, balance, onWithdrawn }: Props) => {
|
||||
const limit = dailyLimit.get('value')
|
||||
const spentToday = dailyLimit.get('spentToday')
|
||||
const disabled = spentToday >= limit
|
||||
|
||||
const disabled = spentToday >= limit || Number(balance) === 0
|
||||
const text = `${limit} ETH (spent today: ${spentToday} ETH)`
|
||||
|
||||
return (
|
||||
|
@ -71,7 +71,7 @@ class GnoSafe extends React.PureComponent<SafeProps, State> {
|
||||
<Owners owners={safe.owners} />
|
||||
<Confirmations confirmations={safe.get('confirmations')} />
|
||||
<Address address={safe.get('address')} />
|
||||
<DailyLimit dailyLimit={safe.get('dailyLimit')} onWithdrawn={this.onWithdrawn} />
|
||||
<DailyLimit balance={balance} dailyLimit={safe.get('dailyLimit')} onWithdrawn={this.onWithdrawn} />
|
||||
<MultisigTx balance={balance} onAddTx={this.onAddTx} onSeeTxs={this.onListTransactions} />
|
||||
</List>
|
||||
</Col>
|
||||
|
@ -104,4 +104,18 @@ describe('React DOM TESTS > Withdrawn funds from safe', () => {
|
||||
|
||||
expect(addTxButton.props.disabled).toBe(false)
|
||||
})
|
||||
|
||||
it('Withdrawn button disabled when balance is 0', async () => {
|
||||
const Safe = TestUtils.findRenderedComponentWithType(SafeDom, SafeView)
|
||||
// $FlowFixMe
|
||||
const buttons = TestUtils.scryRenderedComponentsWithType(Safe, Button)
|
||||
const addTxButton = buttons[0]
|
||||
expect(addTxButton.props.children).toEqual(WITHDRAWN_BUTTON_TEXT)
|
||||
expect(addTxButton.props.disabled).toBe(true)
|
||||
|
||||
await addEtherTo(address, '0.1')
|
||||
await sleep(1800)
|
||||
|
||||
expect(addTxButton.props.disabled).toBe(false)
|
||||
})
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user