diff --git a/forms/plan_settings.rb b/forms/plan_settings.rb new file mode 100644 index 0000000000000000000000000000000000000000..8b8a1e5e738b17a984c4f645c4435d9d4f6e1a41 --- /dev/null +++ b/forms/plan_settings.rb @@ -0,0 +1,22 @@ +form! + +title "Plan Settings" + +instructions( + "Your plan includes #{@customer.message_limit} and " \ + "#{@customer.minute_limit}. JMP will always prompt for your explicit " \ + "consent before allowing any action which would incur more overage in a " \ + "calendar month than your configured limit below.\n\n" \ + "JMP is not yet billing for overages, but will be soon." +) + +field( + var: "monthly_overage_limit", + type: "text-single", + datatype: "xs:integer", + label: "Dollars of overage to allow each month", + description: + "0 means you will never be automatically charged more " \ + "than your monthly fee", + value: @customer.monthly_overage_limit.to_s +) diff --git a/sgx_jmp.rb b/sgx_jmp.rb index 3129d07332f1229c4e9054706149413cb65f9f5c..f60bb0b9984c31fcc9504f9b55a886a5486e1996 100644 --- a/sgx_jmp.rb +++ b/sgx_jmp.rb @@ -577,6 +577,24 @@ Command.new( end }.register(self).then(&CommandList.method(:register)) +Command.new( + "plan settings", + "Manage your plan, including overage limits", + list_for: ->(customer:, **) { !!customer&.currency } +) { + Command.customer.then do |customer| + Command.reply { |reply| + reply.allowed_actions = [:next] + reply.command << FormTemplate.render("plan_settings", customer: customer) + }.then { |iq| + Command.execution.customer_repo.put_monthly_overage_limit( + customer, + iq.form.field("monthly_overage_limit")&.value.to_i + ) + }.then { Command.finish("Configuration saved!") } + end +}.register(self).then(&CommandList.method(:register)) + Command.new( "referral codes", "Refer a friend for free credit"