Skip to content

armgit / sure

Public Imported from GitHub
0

The personal finance app for everyone (by everyone)

Ruby
2.5 KB
Raw Blame
<%# locals: (entry:, open:, provider_setup_encryption_warning: false) %>
<%
  status        = entry[:summary][:status]
  meta          = entry[:summary][:meta]
  last_synced   = entry[:summary][:last_synced_at]
  border_class  =
    case status
    when :warn then "border border-warning/25"
    when :err  then "border border-destructive-subtle"
    else            "border border-transparent"
    end
  sync_action   = entry[:partial].present? && entry[:sync_supported] != false ? render("settings/providers/sync_button", provider_key: entry[:provider_key], last_synced_at: last_synced) : nil
  status_pill   = render("settings/providers/status_pill", status: status)
  maturity_lbl  = Settings::ProviderCard.maturity_label(entry[:maturity])
  details_data  = entry[:auto_open_param].present? ? { controller: "auto-open", auto_open_param_value: entry[:auto_open_param] } : {}
%>
<%= tag.details id: ("#{entry[:turbo_id]}-connection" if entry[:turbo_id]),
                open: open,
                class: "group bg-container shadow-border-xs rounded-xl #{border_class}",
                data: details_data do %>
  <summary class="min-h-15 px-4 py-3.5 cursor-pointer rounded-xl list-none [&::-webkit-details-marker]:hidden">
    <div class="flex items-center gap-3">
      <%= icon "chevron-right", size: "sm", class: "!w-3.5 !h-3.5 text-secondary group-open:rotate-90 transition-transform" %>
      <div class="flex items-center flex-wrap gap-2 min-w-0 flex-1">
        <div class="flex items-center gap-2 shrink-0 flex-1">
          <%= render ProviderLogo.new(provider_key: entry[:provider_key], class_name: "w-7 h-7 rounded-lg") %>
          <h3 class="text-sm font-medium text-primary"><%= entry[:title] %></h3>
          <%= render "settings/providers/maturity_badge", label: maturity_lbl %>
        </div>
        <div class="flex items-center gap-2 shrink-0 group-open:hidden">
          <% if meta.present? %>
            <span class="text-xs text-subdued"><%= meta %></span>
          <% end %>
          <%= status_pill %>
        </div>
      </div>
      <div class="group-open:hidden">
        <%= sync_action if sync_action %>
      </div>
    </div>
  </summary>
  <div class="space-y-4 mt-4 px-4 pb-4">
    <% if entry[:configuration] %>
      <%= render "settings/providers/provider_form",
                 configuration: entry[:configuration],
                 provider_setup_encryption_warning: provider_setup_encryption_warning %>
    <% else %>
      <%= render "settings/providers/#{entry[:partial]}" %>
    <% end %>
  </div>
<% end %>