From c397f1bd2b79ddf50a2515f52e453e6ab297ff53 Mon Sep 17 00:00:00 2001 From: Zach Gollwitzer Date: Mon, 7 Oct 2024 16:20:36 -0400 Subject: [PATCH] Hide infinity trend percentage changes (#1261) --- app/views/pages/dashboard.html.erb | 4 +++- app/views/shared/_trend_change.html.erb | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/views/pages/dashboard.html.erb b/app/views/pages/dashboard.html.erb index ccea86b36e3..72bdc2bd847 100644 --- a/app/views/pages/dashboard.html.erb +++ b/app/views/pages/dashboard.html.erb @@ -135,7 +135,9 @@ <% @top_savers.first(3).each do |account| %> <%= link_to account, class: "border border-alpha-black-25 rounded-full p-1 pr-2 flex items-center gap-1 text-xs text-gray-900 font-medium hover:bg-gray-25" do %> <%= image_tag account_logo_url(account), class: "w-5 h-5" %> - <%= account.savings_rate > 0 ? "+" : "-" %><%= number_to_percentage(account.savings_rate.abs * 100, precision: 2) %> + <% unless account.savings_rate.infinite? %> + <%= account.savings_rate > 0 ? "+" : "-" %><%= number_to_percentage(account.savings_rate.abs * 100, precision: 2) %> + <% end %> <% end %> <% end %> <% if @top_savers.count > 3 %> diff --git a/app/views/shared/_trend_change.html.erb b/app/views/shared/_trend_change.html.erb index a9d1d054c01..8df76179acc 100644 --- a/app/views/shared/_trend_change.html.erb +++ b/app/views/shared/_trend_change.html.erb @@ -1,10 +1,14 @@ <%# locals: { trend: } %> + <% styles = trend_styles(trend) %> +

<% if trend.direction.flat? %> No change <% else %> <%= styles[:symbol] %><%= trend.value.is_a?(Money) ? format_money(trend.value.abs) : trend.value.abs.round(2) %> - (<%= lucide_icon(styles[:icon], class: "w-4 h-4 align-text-bottom inline") %><%= trend.percent.abs %>%) + <% unless trend.percent.infinite? %> + (<%= lucide_icon(styles[:icon], class: "w-4 h-4 align-text-bottom inline") %><%= trend.percent.abs %>%) + <% end %> <% end %>