mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2025-02-23 07:15:35 +01:00
FIX: disable create button if total exceeds balance.
This commit is contained in:
parent
34fc84cbdc
commit
7b3a6e2e13
2 changed files with 11 additions and 2 deletions
|
@ -1161,6 +1161,12 @@ const SendDetails = () => {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const calculateTotalAmount = () => {
|
||||||
|
const totalAmount = addresses.reduce((total, item) => total + Number(item.amountSats || 0), 0);
|
||||||
|
const totalWithFee = totalAmount + (feePrecalc.current || 0);
|
||||||
|
return totalWithFee;
|
||||||
|
};
|
||||||
|
|
||||||
const renderFeeSelectionModal = () => {
|
const renderFeeSelectionModal = () => {
|
||||||
const nf = networkTransactionFees;
|
const nf = networkTransactionFees;
|
||||||
const options = [
|
const options = [
|
||||||
|
@ -1320,12 +1326,15 @@ const SendDetails = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const renderCreateButton = () => {
|
const renderCreateButton = () => {
|
||||||
|
const totalWithFee = calculateTotalAmount();
|
||||||
|
const isDisabled = totalWithFee === 0 || totalWithFee > balance || balance === 0 || isLoading || addresses.length === 0;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={styles.createButton}>
|
<View style={styles.createButton}>
|
||||||
{isLoading ? (
|
{isLoading ? (
|
||||||
<ActivityIndicator />
|
<ActivityIndicator />
|
||||||
) : (
|
) : (
|
||||||
<Button onPress={createTransaction} title={loc.send.details_next} testID="CreateTransactionButton" />
|
<Button onPress={createTransaction} disabled={isDisabled} title={loc.send.details_next} testID="CreateTransactionButton" />
|
||||||
)}
|
)}
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
|
|
|
@ -666,7 +666,7 @@ const styles = StyleSheet.create({
|
||||||
},
|
},
|
||||||
listHeaderTextRow: {
|
listHeaderTextRow: {
|
||||||
flex: 1,
|
flex: 1,
|
||||||
marginHorizontal: 16,
|
margin: 16,
|
||||||
flexDirection: 'row',
|
flexDirection: 'row',
|
||||||
justifyContent: 'space-between',
|
justifyContent: 'space-between',
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Reference in a new issue