FIX: disable create button if total exceeds balance.

This commit is contained in:
Marcos Rodriguez Velez 2024-06-07 16:11:57 -04:00
parent 34fc84cbdc
commit 7b3a6e2e13
No known key found for this signature in database
GPG key ID: 6030B2F48CCE86D7
2 changed files with 11 additions and 2 deletions

View file

@ -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 nf = networkTransactionFees;
const options = [
@ -1320,12 +1326,15 @@ const SendDetails = () => {
};
const renderCreateButton = () => {
const totalWithFee = calculateTotalAmount();
const isDisabled = totalWithFee === 0 || totalWithFee > balance || balance === 0 || isLoading || addresses.length === 0;
return (
<View style={styles.createButton}>
{isLoading ? (
<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 file

@ -666,7 +666,7 @@ const styles = StyleSheet.create({
},
listHeaderTextRow: {
flex: 1,
marginHorizontal: 16,
margin: 16,
flexDirection: 'row',
justifyContent: 'space-between',
},