From f51e38f4fcdd5b2cbceff5c76a1a96cfde4f46a5 Mon Sep 17 00:00:00 2001 From: Guillem Arias Date: Mon, 11 May 2026 14:23:00 +0200 Subject: [PATCH] feat(savings_goals): drop Accounts section from index MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Accounts grid duplicated the sidebar account list. Removing it gives the Goals section more breathing room and the page a tighter narrative: header → KPIs → Goals. Delete Savings::AccountCardComponent, Family#savings_subtype_accounts, the @savings_accounts / @account_goal_counts controller refs, and the related locale keys. Sidebar still shows the savings-subtype Depository accounts under "Cash" — no information is lost. --- .../savings/account_card_component.html.erb | 16 --------------- .../savings/account_card_component.rb | 20 ------------------- app/controllers/savings_goals_controller.rb | 13 ------------ app/models/family.rb | 9 --------- app/views/savings_goals/index.html.erb | 17 +--------------- config/locales/views/savings_goals/en.yml | 7 ------- 6 files changed, 1 insertion(+), 81 deletions(-) delete mode 100644 app/components/savings/account_card_component.html.erb delete mode 100644 app/components/savings/account_card_component.rb diff --git a/app/components/savings/account_card_component.html.erb b/app/components/savings/account_card_component.html.erb deleted file mode 100644 index 85927b39c..000000000 --- a/app/components/savings/account_card_component.html.erb +++ /dev/null @@ -1,16 +0,0 @@ -
-
- - <%= initial %> - -
-

<%= account.name %>

-

<%= subtype_label %>

-
-
-

- <%= Money.new(account.balance, account.currency).format %> -

-

<%= funds_label %>

-
diff --git a/app/components/savings/account_card_component.rb b/app/components/savings/account_card_component.rb deleted file mode 100644 index a618f020c..000000000 --- a/app/components/savings/account_card_component.rb +++ /dev/null @@ -1,20 +0,0 @@ -class Savings::AccountCardComponent < ApplicationComponent - def initialize(account:, goals_count: 0) - @account = account - @goals_count = goals_count - end - - attr_reader :account, :goals_count - - def initial - account.name.to_s.strip.first&.upcase || "?" - end - - def subtype_label - (account.subtype || "savings").to_s.titleize - end - - def funds_label - I18n.t("savings_goals.index.account_card.funds", count: goals_count) - end -end diff --git a/app/controllers/savings_goals_controller.rb b/app/controllers/savings_goals_controller.rb index 6bb27d996..33751021e 100644 --- a/app/controllers/savings_goals_controller.rb +++ b/app/controllers/savings_goals_controller.rb @@ -15,8 +15,6 @@ class SavingsGoalsController < ApplicationController @completed_goals = all_goals.select { |g| g.state == "completed" } @linkable_account_count = Current.family.accounts.where(accountable_type: "Depository").visible.count - @savings_accounts = Current.family.savings_subtype_accounts - @account_goal_counts = goal_count_per_account(@savings_accounts) @kpi = kpi_payload(@active_goals) @show_search = @active_goals.size > 6 end @@ -195,17 +193,6 @@ class SavingsGoalsController < ApplicationController } end - def goal_count_per_account(accounts) - return {} if accounts.empty? - - SavingsGoalAccount - .where(account_id: accounts.map(&:id)) - .joins(:savings_goal) - .where.not(savings_goals: { state: %w[archived] }) - .group(:account_id) - .count - end - def stats_for(goal) avg = goal.average_monthly_contribution.to_d sub_avg = if goal.monthly_target_amount && goal.monthly_target_amount.to_d > avg diff --git a/app/models/family.rb b/app/models/family.rb index 78408be95..e74fd531e 100644 --- a/app/models/family.rb +++ b/app/models/family.rb @@ -45,15 +45,6 @@ class Family < ApplicationRecord has_many :savings_goals, dependent: :destroy has_many :savings_contributions, through: :savings_goals - # Depository accounts with subtype = "savings". The /savings_goals - # index hero shows the total + sparkline across just these accounts; - # checking / HSA / CD / money-market are intentionally excluded. - def savings_subtype_accounts - accounts.where(accountable_type: "Depository").visible.alphabetically.select do |account| - account.subtype == "savings" - end - end - # Sum of contribution amounts within the given date range, returned as # a BigDecimal in the family's primary currency. Powers the savings # goals "Contributed · last 30d" KPI. diff --git a/app/views/savings_goals/index.html.erb b/app/views/savings_goals/index.html.erb index 27be9f105..561e92f89 100644 --- a/app/views/savings_goals/index.html.erb +++ b/app/views/savings_goals/index.html.erb @@ -4,7 +4,7 @@

<%= t(".subtitle") %>

- <% if @counts["all"].zero? && @savings_accounts.empty? %> + <% if @counts["all"].zero? %> <%= render "empty_state", linkable_account_count: @linkable_account_count %> <% else %> <%# KPI strip %> @@ -67,21 +67,6 @@ - <%# Accounts section %> - <% if @savings_accounts.any? %> -
-
-

<%= t(".accounts_section.heading") %>

-

<%= t(".accounts_section.subtitle") %>

-
-
- <% @savings_accounts.each do |account| %> - <%= render Savings::AccountCardComponent.new(account: account, goals_count: @account_goal_counts[account.id] || 0) %> - <% end %> -
-
- <% end %> - <%# Goals section %>
" diff --git a/config/locales/views/savings_goals/en.yml b/config/locales/views/savings_goals/en.yml index fa87991aa..497667815 100644 --- a/config/locales/views/savings_goals/en.yml +++ b/config/locales/views/savings_goals/en.yml @@ -30,9 +30,6 @@ en: one: 1 paused other: "%{count} paused" on_track_sub_all_good: All active goals on pace - accounts_section: - heading: Accounts - subtitle: Your savings and emergency reserves goals_section: heading: Goals subtitle: Save toward what matters. @@ -55,10 +52,6 @@ en: behind: Behind no_target_date: Open-ended paused: Paused - account_card: - funds: - one: Funds 1 goal - other: "Funds %{count} goals" new: heading: New savings goal step1_subtitle: Step 1 of 2 · Goal details