mirror of
https://github.com/we-promise/sure.git
synced 2026-04-07 14:31:25 +00:00
- Handle blank series in trend method to avoid nil errors (#357)
- Add Turbo Stream rendering for SimpleFIN items to address missing content - Update dashboard view to render correctly when trend data is unavailable Co-authored-by: Josh Waldrep <joshua.waldrep5+github@gmail.com>
This commit is contained in:
@@ -515,6 +515,17 @@ class SimplefinItemsController < ApplicationController
|
||||
@simplefin_item = Current.family.simplefin_items.build(setup_token: setup_token)
|
||||
end
|
||||
@error_message = message
|
||||
render context, status: :unprocessable_entity
|
||||
|
||||
if turbo_frame_request?
|
||||
# Re-render the SimpleFIN providers panel in place to avoid "Content missing"
|
||||
@simplefin_items = Current.family.simplefin_items.ordered
|
||||
render turbo_stream: turbo_stream.replace(
|
||||
"simplefin-providers-panel",
|
||||
partial: "settings/providers/simplefin_panel",
|
||||
locals: { simplefin_items: @simplefin_items }
|
||||
), status: :unprocessable_entity
|
||||
else
|
||||
render context, status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -57,6 +57,7 @@ class Series
|
||||
end
|
||||
|
||||
def trend
|
||||
return nil if values.blank?
|
||||
@trend ||= Trend.new(
|
||||
current: values.last&.value,
|
||||
previous: values.first&.value,
|
||||
|
||||
@@ -9,14 +9,13 @@
|
||||
<h2 class="text-lg font-medium"><%= t(".title") %></h2>
|
||||
</div>
|
||||
|
||||
<p class="text-primary -space-x-0.5 text-3xl font-medium <%= "animate-pulse" if balance_sheet.syncing? %>">
|
||||
<%= series.trend.current.format %>
|
||||
</p>
|
||||
|
||||
<% if series.trend.nil? %>
|
||||
<p class="text-sm text-secondary"><%= t(".data_not_available") %></p>
|
||||
<% else %>
|
||||
<% if series.trend.present? %>
|
||||
<p class="text-primary -space-x-0.5 text-3xl font-medium <%= "animate-pulse" if balance_sheet.syncing? %>">
|
||||
<%= series.trend.current.format %>
|
||||
</p>
|
||||
<%= render partial: "shared/trend_change", locals: { trend: series.trend, comparison_label: period.comparison_label } %>
|
||||
<% else %>
|
||||
<p class="text-sm text-secondary"><%= t(".data_not_available") %></p>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user