<%# locals: (goal:, linkable_accounts:) %>
<% if goal.errors[:base].any? %> <%= render "shared/form_errors", model: goal %> <% end %> <%# Connected stepper %>
1 <%= t("goals.form_stepper.step1.label") %>
2 <%= t("goals.form_stepper.step2.label") %>
<%= styled_form_with model: goal, url: goals_path, class: "space-y-4", data: { action: "keydown.enter->goal-stepper#blockEnter" } do |f| %>

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

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

<%= render Goals::AvatarComponent.new(name: goal.name, color: goal.color, size: "md") %> <%= f.text_field :name, placeholder: t("goals.form_stepper.step1.fields.name_placeholder"), autofocus: true, label: t("goals.form_stepper.step1.fields.name"), container_class: "flex-1", data: { goal_stepper_target: "nameInput", action: "input->goal-stepper#nameChanged" } %>
<%= f.money_field :target_amount, label: t("goals.form_stepper.step1.fields.target_amount"), hide_currency: true, amount_data: { goal_stepper_target: "amountInput", action: "input->goal-stepper#amountChanged" } %>
<%= f.date_field :target_date, label: t("goals.form_stepper.step1.fields.target_date") %>
<%= t("goals.form_stepper.step1.fields.funding_accounts") %>

<%= t("goals.form_stepper.step1.fields.funding_accounts_hint") %>

<% grouped = linkable_accounts.group_by { |a| a.subtype.to_s.presence || "other" } %> <% grouped.each_with_index do |(subtype, accts), group_idx| %>
<%= t("goals.form_stepper.step1.subtypes.#{subtype}", default: subtype.titleize) %>
"> <% accts.each_with_index do |account, idx| %> <% end %>
<% end %>
<%= render DS::Disclosure.new(title: t("goals.form_stepper.step1.fields.notes_summary"), align: "right") do %> <%= f.text_area :notes, label: t("goals.form_stepper.step1.fields.notes"), rows: 3, placeholder: t("goals.form_stepper.step1.fields.notes_placeholder") %> <% end %> <%= f.hidden_field :color %>
<%= render DS::Button.new( text: t("goals.form_stepper.continue"), variant: "primary", icon: "arrow-right", icon_position: :right, data: { goal_stepper_target: "footerRightButton", action: "click->goal-stepper#footerRight" } ) %>
<% end %>