<%# locals: (institution:) %>
<%= lucide_icon "chevron-right", class: "group-open:transform group-open:rotate-90 text-gray-500 w-5" %>
<% if institution_logo(institution) %> <%= image_tag institution_logo(institution), class: "rounded-full h-full w-full" %> <% else %>
<%= tag.p institution.name.first.upcase, class: "text-blue-600 text-xs font-medium" %>
<% end %>
<%= link_to institution.name, edit_institution_path(institution), data: { turbo_frame: :modal }, class: "font-medium text-gray-900 hover:underline" %> <% if institution.has_issues? %>
<%= lucide_icon "alert-octagon", class: "shrink-0 w-4 h-4" %> <%= tag.span t(".has_issues") %>
<% elsif institution.syncing? %>
<%= lucide_icon "loader", class: "w-4 h-4 animate-pulse" %> <%= tag.span t(".syncing") %>
<% else %>

<%= institution.last_synced_at ? t(".status", last_synced_at: time_ago_in_words(institution.last_synced_at)) : t(".status_never") %>

<% end %>
<%= button_to sync_institution_path(institution), method: :post, class: "text-gray-900 flex hover:text-gray-800 items-center text-sm font-medium hover:underline" do %> <%= lucide_icon "refresh-cw", class: "w-4 h-4" %> <% end %> <%= contextual_menu do %>
<%= link_to new_account_path(institution_id: institution.id), class: "block w-full py-2 px-3 space-x-2 text-gray-900 hover:bg-gray-50 flex items-center rounded-lg", data: { turbo_frame: :modal } do %> <%= lucide_icon "plus", class: "w-5 h-5 text-gray-500" %> <%= t(".add_account_to_institution") %> <% end %> <%= link_to edit_institution_path(institution), class: "block w-full py-2 px-3 space-x-2 text-gray-900 hover:bg-gray-50 flex items-center rounded-lg", data: { turbo_frame: :modal } do %> <%= lucide_icon "pencil-line", class: "w-5 h-5 text-gray-500" %> <%= t(".edit") %> <% end %> <%= button_to institution_path(institution), method: :delete, class: "block w-full py-2 px-3 space-x-2 text-red-600 hover:bg-red-50 flex items-center rounded-lg", data: { turbo_confirm: { title: t(".confirm_title"), body: t(".confirm_body"), accept: t(".confirm_accept") } } do %> <%= lucide_icon "trash-2", class: "w-5 h-5" %> <%= t(".delete") %> <% end %>
<% end %>
<% if institution.accounts.any? %> <%= render "accountable_group", accounts: institution.accounts %> <% else %>

There are no accounts in this financial institution

<%= link_to new_account_path(institution_id: institution.id), class: "w-fit flex text-white text-sm font-medium items-center gap-1 bg-gray-900 rounded-lg p-1.5 pr-2", data: { turbo_frame: "modal" } do %> <%= lucide_icon("plus", class: "w-4 h-4") %> <%= t(".new_account") %> <% end %>
<% end %>