<% content_for :title, "Set Up Lunch Flow Accounts" %> <%= render DS::Dialog.new do |dialog| %> <% dialog.with_header(title: t(".title")) do %>
<%= icon "building-2", class: "text-primary" %> <%= t(".subtitle") %>
<% end %> <% dialog.with_body do %> <%= form_with url: complete_account_setup_lunchflow_item_path(@lunchflow_item), method: :post, local: true, data: { controller: "loading-button", action: "submit->loading-button#showLoading", loading_button_loading_text_value: t(".creating_accounts"), turbo_frame: "_top" }, class: "space-y-6" do |form| %>
<% if @api_error.present? %>
<%= icon "alert-circle", size: "lg", class: "text-destructive" %>

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

<%= @api_error %>

<% elsif @lunchflow_accounts.empty? %>
<%= icon "check-circle", size: "lg", class: "text-success" %>

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

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

<% else %>
<%= icon "info", size: "sm", class: "text-primary mt-0.5 flex-shrink-0" %>

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

    <% @account_type_options.reject { |_, type| type == "skip" }.each do |label, type| %>
  • <%= label %>
  • <% end %>
<% @lunchflow_accounts.each do |lunchflow_account| %>

<%= lunchflow_account.name %>

<%= label_tag "account_types[#{lunchflow_account.id}]", t(".account_type_label"), class: "block text-sm font-medium text-primary mb-2" %> <%= select_tag "account_types[#{lunchflow_account.id}]", options_for_select(@account_type_options, "skip"), { class: "appearance-none bg-container border border-primary rounded-md px-3 py-2 text-sm leading-6 text-primary focus:border-primary focus:ring-1 focus:ring-primary focus:outline-none w-full", data: { action: "change->account-type-selector#updateSubtype" } } %>
<% @subtype_options.each do |account_type, subtype_config| %> <%= render "lunchflow_items/subtype_select", account_type: account_type, subtype_config: subtype_config, lunchflow_account: lunchflow_account %> <% end %>
<% end %> <% end %>
<%= render DS::Button.new( text: t(".create_accounts"), variant: "primary", icon: "plus", type: "submit", class: "flex-1", disabled: @api_error.present? || @lunchflow_accounts.empty?, data: { loading_button_target: "button" } ) %> <%= render DS::Link.new( text: t(".cancel"), variant: "secondary", href: accounts_path ) %>
<% end %> <% end %> <% end %>