<%# locals: (simplefin_item:) %> <%= tag.div id: dom_id(simplefin_item) do %>
<%= icon "chevron-right", class: "group-open:transform group-open:rotate-90" %>
<% if simplefin_item.logo.attached? %> <%= image_tag simplefin_item.logo, class: "rounded-full h-full w-full", loading: "lazy" %> <% else %>
<%= tag.p simplefin_item.name.first.upcase, class: "text-primary text-xs font-medium" %>
<% end %>
<%= tag.p simplefin_item.name, class: "font-medium text-primary" %> <% if simplefin_item.scheduled_for_deletion? %>

(deletion in progress...)

<% end %>
<% if simplefin_item.syncing? %>
<%= icon "loader", size: "sm", class: "animate-pulse" %> <%= tag.span "Syncing..." %>
<% elsif simplefin_item.requires_update? %>
<%= icon "alert-triangle", size: "sm", color: "warning" %> <%= tag.span "Requires Update" %>
<% elsif simplefin_item.sync_error.present? %>
<%= icon "alert-circle", size: "sm", color: "destructive" %> <%= tag.span "Error", class: "text-destructive" %>
<% else %>

<%= simplefin_item.last_synced_at ? "Last synced #{time_ago_in_words(simplefin_item.last_synced_at)} ago" : "Never synced" %>

<% end %>
<% if Rails.env.development? %> <%= icon( "refresh-cw", as_button: true, href: sync_simplefin_item_path(simplefin_item) ) %> <% end %> <%= render DS::Menu.new do |menu| %> <% menu.with_item( variant: "button", text: "Delete", icon: "trash-2", href: simplefin_item_path(simplefin_item), method: :delete, confirm: CustomConfirm.for_resource_deletion(simplefin_item.name, high_severity: true) ) %> <% end %>
<% unless simplefin_item.scheduled_for_deletion? %>
<% if simplefin_item.accounts.any? %> <%= render "accounts/index/account_groups", accounts: simplefin_item.accounts %> <% elsif simplefin_item.pending_account_setup? %>

Accounts ready to set up

Choose account types for your imported SimpleFin accounts.

<%= render DS::Link.new( text: "Set Up Accounts", icon: "settings", variant: "primary", href: setup_accounts_simplefin_item_path(simplefin_item) ) %>
<% else %>

No accounts found

This connection doesn't have any synchronized accounts yet.

<% end %>
<% end %>
<% end %>