<%# locals: (savings_goal:, linkable_accounts:) %>
<% if savings_goal.errors.any? %> <%= render "shared/form_errors", model: savings_goal %> <% end %> <%# Connected stepper %>
1 <%= t("savings_goals.form_stepper.step1.label") %>
2 <%= t("savings_goals.form_stepper.step2.label") %>
<%= styled_form_with model: savings_goal, url: savings_goals_path, class: "space-y-4" do |f| %>

<%= t("savings_goals.form_stepper.step1.heading") %>

<%= t("savings_goals.form_stepper.step1.subheading") %>

<%= render DS::FilledIcon.new(variant: :container, icon: "target", size: "lg", rounded: false) %> <%= f.text_field :name, placeholder: t("savings_goals.form_stepper.step1.fields.name_placeholder"), required: true, autofocus: true, label: "", class: "flex-1" %>
<%= f.money_field :target_amount, label: t("savings_goals.form_stepper.step1.fields.target_amount"), required: true %> <%= f.date_field :target_date, label: t("savings_goals.form_stepper.step1.fields.target_date") %>
<%= t("savings_goals.form_stepper.step1.fields.funding_accounts") %>
<% grouped = linkable_accounts.group_by { |a| a.subtype.to_s.presence || "other" } %> <% grouped.each_with_index do |(subtype, accts), group_idx| %>
<%= t("savings_goals.form_stepper.step1.subtypes.#{subtype}", default: subtype.titleize) %>
"> <% accts.each_with_index do |account, idx| %> <% end %>
<% end %>
<%= f.text_area :notes, label: t("savings_goals.form_stepper.step1.fields.notes"), rows: 2 %> <%# Hidden color (random) %> <%= f.hidden_field :color, value: savings_goal.color || SavingsGoal::COLORS.sample %>
<%= render DS::Button.new( text: t("savings_goals.form_stepper.continue"), variant: "primary", icon: "arrow-right", icon_position: :right, data: { savings_goal_stepper_target: "footerRightButton", action: "click->savings-goal-stepper#footerRight" } ) %>
<% end %>