feat(form): conditionally display max top-up amount
Amolith
created
Remove range from the form, but pass max_top_up_amount through and only display
it if the user isn't tombed.
Change summary
forms/top_up.rb | 5 ++++-
lib/buy_account_credit_form.rb | 2 +-
2 files changed, 5 insertions(+), 2 deletions(-)
Detailed changes
@@ -1,6 +1,10 @@
form!
title "Buy Account Credit"
+if @max_top_up_amount & @max_top_up_amount.positive?
+ instructions "Max amount: $#{@max_top_up_amount}"
+end
+
field(
type: "fixed",
label: "Current balance",
@@ -11,7 +15,6 @@ field(**@payment_methods.to_list_single)
field(
datatype: "xs:decimal",
- range: @range,
var: "amount",
label: "Amount of credit to buy",
prefix: "$",
@@ -50,7 +50,7 @@ class BuyAccountCreditForm
:top_up,
balance: @balance,
payment_methods: @payment_methods,
- range: [15, @max_top_up_amount]
+ max_top_up_amount: @max_top_up_amount
)
end