%# Modal: Link an existing manual account to a Coinbase account %>
<%= turbo_frame_tag "modal" do %>
<%= render DS::Dialog.new do |dialog| %>
<% dialog.with_header(title: t(".title")) %>
<% dialog.with_body do %>
<% if @available_coinbase_accounts.blank? %>
<%= t(".no_accounts_found") %>
<%= t(".wait_for_sync") %>
<%= t(".check_provider_health") %>
<% else %>
<%= form_with url: link_existing_account_coinbase_items_path, method: :post, class: "space-y-4" do %>
<%= hidden_field_tag :account_id, @account.id %>
<% @available_coinbase_accounts.each do |ca| %>
<%= radio_button_tag :coinbase_account_id, ca.id, false %>
<%= ca.name.presence || ca.account_id %>
<%= ca.currency %> • <%= t(".balance") %>: <%= number_with_delimiter(ca.current_balance || 0, delimiter: ",") %>
<% if ca.current_account.present? %>
<%= t(".currently_linked_to", account_name: ca.current_account.name) %>
<% end %>
<% end %>
<%= render DS::Button.new(text: t(".link"), variant: :primary, icon: "link-2", type: :submit) %>
<%= render DS::Link.new(text: t(".cancel"), variant: :secondary, href: accounts_path, data: { turbo_frame: "_top" }) %>
<% end %>
<% end %>
<% end %>
<% end %>
<% end %>