<%= link_to savings_goals_path, class: "inline-flex items-center gap-1 text-secondary hover:text-primary" do %> <%= icon("arrow-left", size: "sm") %> <%= t(".back_to_all") %> <% end %>
<%= render Savings::GoalAvatarComponent.new(goal: @savings_goal, size: "xl") %>

<%= @savings_goal.name %>

<%= render Savings::StatusPillComponent.new(goal: @savings_goal) %>

<% if @savings_goal.target_date %> <%= t(".header.target_by", amount: @savings_goal.target_amount_money.format, date: I18n.l(@savings_goal.target_date, format: :long)) %> <% days = (@savings_goal.target_date - Date.current).to_i %> <% if days > 0 %> · <%= t("savings_goals.goal_card.days_left", count: days, date: I18n.l(@savings_goal.target_date, format: :long)).split(" · ").first %> <% end %> <% else %> <%= t(".header.target", amount: @savings_goal.target_amount_money.format) %> <% end %>

<%= render DS::Link.new( text: t(".edit"), variant: "outline", href: edit_savings_goal_path(@savings_goal), icon: "pencil", frame: :modal ) %> <%= render DS::Link.new( text: t(".add_contribution"), variant: "primary", href: new_savings_goal_contribution_path(@savings_goal), icon: "plus", frame: :modal ) %> <%= render DS::Menu.new do |menu| %> <% if @savings_goal.may_pause? %> <% menu.with_item(variant: "button", text: t(".pause"), icon: "pause", href: pause_savings_goal_path(@savings_goal), method: :patch) %> <% end %> <% if @savings_goal.may_resume? %> <% menu.with_item(variant: "button", text: t(".resume"), icon: "play", href: resume_savings_goal_path(@savings_goal), method: :patch) %> <% end %> <% if @savings_goal.may_complete? %> <% menu.with_item(variant: "button", text: t(".complete"), icon: "circle-check-big", href: complete_savings_goal_path(@savings_goal), method: :patch) %> <% end %> <% if @savings_goal.may_archive? %> <% menu.with_item(variant: "button", text: t(".archive"), icon: "archive", href: archive_savings_goal_path(@savings_goal), method: :patch) %> <% end %> <% if @savings_goal.may_unarchive? %> <% menu.with_item(variant: "button", text: t(".unarchive"), icon: "archive-restore", href: unarchive_savings_goal_path(@savings_goal), method: :patch) %> <% end %> <% if @savings_goal.archived? %> <% menu.with_item( variant: "button", text: t(".delete"), icon: "trash-2", href: savings_goal_path(@savings_goal), method: :delete, destructive: true, confirm: CustomConfirm.for_resource_deletion(@savings_goal.name, high_severity: true) ) %> <% end %> <% end %>
<%# Top row: ring card + projection chart card %>
<%= render Savings::ProgressRingComponent.new(goal: @savings_goal, size: 180) %>

<%= @savings_goal.current_balance_money.format %>

<%= t(".ring.of", target: @savings_goal.target_amount_money.format) %> <% unless @savings_goal.completed? %> · <%= t(".ring.to_go", amount: @savings_goal.remaining_amount_money.format) %> <% end %>

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

<%= @stats[:projection_summary].html_safe %>

<%= t(".projection.legend_saved") %> <%= t(".projection.legend_projection") %>
<%# Stat row %>

<%= t(".stats.avg_monthly") %>

<%= Money.new(@stats[:avg_monthly], @savings_goal.currency).format %>

<%= @stats[:avg_monthly_sub] %>

<%= t(".stats.total_contributions") %>

<%= @stats[:contributions_count] %>

<%= t(".stats.across_all_accounts") %>

<%= t(".stats.linked_balance") %>

<%= Money.new(@stats[:linked_balance], @savings_goal.currency).format %>

<%= @stats[:linked_balance_sub] %>

<%= t(".stats.started") %>

<%= I18n.l(@savings_goal.created_at.to_date, format: :long) %>

<%= @stats[:started_sub] %>

<%# Bottom row: contributions + funding accounts %>

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

<%= @contributions.size %>
<%= render "contributions_list", contributions: @contributions %>

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

<%= render Savings::FundingAccountsBreakdownComponent.new(goal: @savings_goal, rows: @funding_breakdown) %>
<% if @savings_goal.notes.present? %>

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

<%= @savings_goal.notes %>

<% end %>