Skip to content

armgit / sure

Public Imported from GitHub
0

The personal finance app for everyone (by everyone)

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

    <% dialog.with_body do %>
      <div class="space-y-4" data-controller="bank-search">
        <p class="text-sm text-secondary">
          <%= t(".description") %>
        </p>

        <% if @error_message.present? %>
          <div class="p-3 rounded-lg bg-destructive/10 text-destructive text-sm">
            <%= @error_message %>
          </div>
        <% end %>

        <% if @aspsps.present? %>
          <%= render DS::SearchInput.new(
                placeholder: t(".search_placeholder"),
                aria_label: t(".search_label"),
                autofocus: true,
                data: {
                  bank_search_target: "input",
                  action: "input->bank-search#filter"
                }
              ) %>

          <div class="space-y-2 max-h-80 overflow-y-auto">
            <% @aspsps.each do |aspsp| %>
              <div data-bank-search-target="item" data-bank-search="<%= [ aspsp[:name], aspsp[:bic] ].compact_blank.join(" ").downcase(:fold) %>">
                <%= button_to authorize_enable_banking_item_path(@enable_banking_item),
                              method: :post,
                              params: { aspsp_name: aspsp[:name], new_connection: @new_connection, country_code: @country_code },
                              class: "w-full flex items-center gap-4 p-3 rounded-lg border border-primary bg-container hover:bg-subtle transition-colors text-left",
                              data: { turbo: false } do %>
                  <% if aspsp[:logo].present? %>
                    <img src="<%= aspsp[:logo] %>" alt="<%= aspsp[:name] %>" class="w-10 h-10 rounded object-contain">
                  <% else %>
                    <div class="w-10 h-10 rounded bg-container-inset flex items-center justify-center">
                      <%= icon "building-bank", class: "w-5 h-5 text-tertiary" %>
                    </div>
                  <% end %>
                  <div class="flex-1 min-w-0">
                    <div class="flex items-center gap-2 flex-wrap">
                      <p class="font-medium text-sm text-primary"><%= aspsp[:name] %></p>
                      <% if aspsp[:beta] %>
                        <%= render DS::Pill.new(label: t(".beta_label"), tone: :warning, marker: false) %>
                      <% end %>
                    </div>
                    <% if aspsp[:bic].present? %>
                      <p class="text-xs text-secondary truncate">BIC: <%= aspsp[:bic] %></p>
                    <% end %>
                  </div>
                  <%= icon "chevron-right", class: "w-5 h-5 text-secondary flex-shrink-0" %>
                <% end %>
              </div>
            <% end %>
            <div data-bank-search-target="emptyState" class="hidden py-4 text-center text-sm text-secondary">
              <%= t(".no_search_results") %>
            </div>
          </div>
        <% else %>
          <div class="text-center py-8">
            <p class="text-secondary"><%= t(".no_banks") %></p>
            <p class="text-sm text-secondary mt-2"><%= t(".check_country") %></p>
          </div>
        <% end %>

        <div class="flex justify-end pt-4">
          <%= render DS::Link.new(
                text: t(".cancel"),
                variant: :secondary,
                href: settings_providers_path,
                data: { turbo_frame: "_top", action: "DS--dialog#close" }
              ) %>
        </div>
      </div>
    <% end %>
  <% end %>
<% end %>