Skip to content

Commit 7c576c0

Browse files
committed
Improve readability of isPaymentButtonEnabled function.
1 parent 0dff142 commit 7c576c0

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

WooCommerce/Classes/POS/ViewHelpers/CollectCashViewHelper.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,16 @@ final class CollectCashViewHelper {
5757
func isPaymentButtonEnabled(orderTotal: String,
5858
textFieldAmountInput: String,
5959
isLoading: Bool) -> Bool {
60+
guard !isLoading else {
61+
return false
62+
}
63+
64+
let inputAmount = textFieldAmountInput.isNotEmpty ? textFieldAmountInput : "0"
6065
guard let orderDecimal = parseCurrency(orderTotal),
61-
let inputDecimal = parseCurrency(textFieldAmountInput.isNotEmpty ? textFieldAmountInput : "0") else {
66+
let inputDecimal = parseCurrency(inputAmount) else {
6267
return false
6368
}
64-
return inputDecimal >= orderDecimal && !isLoading
69+
return inputDecimal >= orderDecimal
6570
}
6671

6772
func parseCurrency(_ amountString: String) -> Decimal? {

0 commit comments

Comments
 (0)