From 32f038a969c21022a14f117971a720149a94bc59 Mon Sep 17 00:00:00 2001 From: Amolith Date: Wed, 28 May 2025 14:08:37 -0600 Subject: [PATCH] feat(form): conditionally display max top-up amount Remove range from the form, but pass max_top_up_amount through and only display it if the user isn't tombed. --- forms/top_up.rb | 5 ++++- lib/buy_account_credit_form.rb | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/forms/top_up.rb b/forms/top_up.rb index 9197c1641ff402f817688bb447a39d5c2e969236..5864326ebd50f44446e81852f62884763e913a25 100644 --- a/forms/top_up.rb +++ b/forms/top_up.rb @@ -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: "$", diff --git a/lib/buy_account_credit_form.rb b/lib/buy_account_credit_form.rb index ab5ff1f278e91a252e291d1b6605788f87f760ee..e060ef6e78582aa3debd9d746a355b753c8f0f99 100644 --- a/lib/buy_account_credit_form.rb +++ b/lib/buy_account_credit_form.rb @@ -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