% content_for :title, t(".page_title") %>
<%= render DS::Dialog.new(disable_click_outside: true) do |dialog| %>
<% dialog.with_header(title: t(".dialog_title")) do %>
<%= icon "info", size: "sm", class: "text-primary mt-0.5 flex-shrink-0" %>
<%= t(".info_box.title") %>
- <%= t(".info_box.items.item_1") %>
- <%= t(".info_box.items.item_2") %>
- <%= t(".info_box.items.item_3") %>
<%= icon "alert-triangle", size: "xs", class: "inline-block mr-1" %>
<%= t(".info_box.warning") %>
<% if @waiting_for_sync %>
<%= t(".status.fetching_accounts") %>
<%= render DS::Link.new(
text: t(".buttons.refresh"),
variant: "secondary",
icon: "refresh-cw",
href: setup_accounts_ibkr_item_path(@ibkr_item),
frame: "_top"
) %>
<%= render DS::Link.new(
text: t(".buttons.cancel"),
variant: "ghost",
href: accounts_path,
frame: "_top"
) %>
<% elsif @no_accounts_found %>
<%= icon "alert-circle", size: "lg", class: "text-warning" %>
<%= t(".status.no_accounts_found_title") %>
<%= t(".status.no_accounts_found_description") %>
<%= render DS::Link.new(
text: t(".buttons.back_to_settings"),
variant: "secondary",
href: settings_providers_path,
frame: "_top"
) %>
<% else %>
<%= form_with url: complete_account_setup_ibkr_item_path(@ibkr_item), method: :post, data: { turbo_frame: "_top" } do %>
<% if @unlinked_accounts.any? %>
<%= t(".available_accounts.title") %>
<% @unlinked_accounts.each do |ibkr_account| %>
<% end %>
<%= render DS::Button.new(
text: t(".buttons.create_selected_accounts"),
variant: "primary",
icon: "plus",
type: "submit",
class: "flex-1"
) %>
<%= render DS::Link.new(
text: t(".buttons.cancel"),
variant: "secondary",
href: accounts_path,
frame: "_top"
) %>
<% end %>
<% end %>
<% if @unlinked_accounts.any? && @linkable_accounts.any? %>
<%= t(".link_existing.description") %>
<% @unlinked_accounts.each do |ibkr_account| %>
<%= form_with url: link_existing_account_ibkr_items_path, method: :post, data: { turbo_frame: "_top" } do |link_form| %>
<%= link_form.hidden_field :ibkr_account_id, value: ibkr_account.id %>
<%= ibkr_account.name %>
<%= link_form.select :account_id,
options_for_select(@linkable_accounts.map { |account| [t(".link_existing.manual_account_option", name: account.name, balance: number_to_currency(account.balance, unit: Money::Currency.new(account.currency || 'USD').symbol)), account.id] }),
{ prompt: t(".link_existing.select_prompt") },
class: "bg-container border border-primary rounded px-2 py-1 text-sm text-primary flex-1 min-w-0" %>
<%= render DS::Button.new(
text: t(".buttons.link"),
variant: "secondary",
size: "sm",
type: "submit"
) %>
<% end %>
<% end %>
<% end %>
<% if @linked_accounts.any? %>
<%= t(".linked_accounts.title") %>
<% @linked_accounts.each do |ibkr_account| %>
<%= icon "check-circle", class: "text-success" %>
<%= ibkr_account.name %>
<%= t(".linked_accounts.linked_to_html", account: link_to(ibkr_account.current_account.name, account_path(ibkr_account.current_account), class: "link")) %>
<% end %>
<% if @unlinked_accounts.blank? %>
<%= render DS::Link.new(
text: t(".buttons.done"),
variant: "primary",
href: accounts_path,
frame: "_top"
) %>
<% end %>
<% end %>
<% end %>
<% end %>
<% end %>