Skip to content

armgit / sure

Public Imported from GitHub
0

The personal finance app for everyone (by everyone)

Ruby
2.0 KB
Raw Blame
<%= turbo_frame_tag "modal" do %>
  <%= render DS::Dialog.new do |dialog| %>
    <% dialog.with_header(title: t(".title")) %>

    <% dialog.with_body do %>
      <% if @available_trade_republic_accounts.blank? %>
        <div class="p-4 text-sm text-secondary">
          <p class="mb-2"><%= t(".no_accounts_available") %></p>
          <ul class="list-disc list-inside space-y-1">
            <li><%= t(".run_sync_hint") %></li>
            <li><%= t(".wait_for_sync") %></li>
          </ul>
        </div>
      <% else %>
        <%= form_with url: link_existing_account_trade_republic_items_path, method: :post, data: { turbo_frame: "_top" }, class: "space-y-4" do %>
          <%= hidden_field_tag :account_id, @account.id %>
          <div class="space-y-2 max-h-64 overflow-auto">
            <% @available_trade_republic_accounts.each do |tr_account| %>
              <label class="flex items-center gap-3 p-2 rounded border border-secondary hover:border-primary cursor-pointer">
                <%= radio_button_tag :trade_republic_account_id, tr_account.id, false, required: true %>
                <div class="flex flex-col">
                  <span class="text-sm text-primary font-medium"><%= tr_account.name.presence || tr_account.trade_republic_account_id %></span>
                  <span class="text-xs text-secondary">
                    <%= tr_account.currency %> • <%= t(".balance") %>: <%= number_to_currency((tr_account.current_balance || 0), unit: Money::Currency.new(tr_account.currency.presence || Current.family.currency).symbol) %>
                  </span>
                </div>
              </label>
            <% end %>
          </div>

          <div class="flex items-center justify-end gap-2">
            <%= 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" }) %>
          </div>
        <% end %>
      <% end %>
    <% end %>
  <% end %>
<% end %>