From eb82d63774de9aa1816784fa30cfc3fd738dc6be Mon Sep 17 00:00:00 2001 From: Wabo Date: Wed, 3 Jun 2026 11:01:29 -0400 Subject: [PATCH] Fix SMS dropdown JS timing and enable switch logic --- app/views/sms_settings/index.html.erb | 38 ++++++++++++++++++++------- lib/sms.rb | 5 ++++ 2 files changed, 34 insertions(+), 9 deletions(-) diff --git a/app/views/sms_settings/index.html.erb b/app/views/sms_settings/index.html.erb index 72fecae2..055b1fa6 100644 --- a/app/views/sms_settings/index.html.erb +++ b/app/views/sms_settings/index.html.erb @@ -4,6 +4,7 @@

SMS

<% value = @encrypted_config.value || {} %> + <% sms_enabled = Sms.enabled?(current_account) %> <% sms_live = Sms.enabled_for?(current_account) %> <% provider_labels = { @@ -32,6 +33,16 @@

+ <% elsif sms_enabled %> +
+ <%= svg_icon('discount_check_filled', class: 'w-6 h-6') %> +
+

SMS is enabled but not fully configured

+

+ Select a provider below and fill in its credentials, then save. +

+
+
<% else %>
<%= svg_icon('info_circle', class: 'w-6 h-6') %> @@ -187,16 +198,25 @@ diff --git a/lib/sms.rb b/lib/sms.rb index 9a9fe1c7..67a70f11 100644 --- a/lib/sms.rb +++ b/lib/sms.rb @@ -20,6 +20,11 @@ module Sms record&.value end + def enabled?(account) + config = configuration_for(account) + config.is_a?(Hash) && !!config['enabled'] + end + def enabled_for?(account) config = configuration_for(account) return false unless config.is_a?(Hash)