2024-02-08 21:46:27 +00:00
|
|
|
<%# locals: (type:) -%>
|
|
|
|
|
|
|
|
<% accounts = Current.family.accounts.where(accountable_type: type.name) %>
|
|
|
|
|
2024-02-10 16:18:56 -06:00
|
|
|
<% if accounts.sum(&:converted_balance) > 0 %>
|
2024-02-12 02:38:28 +08:00
|
|
|
<details class="mb-1 text-sm group" data-controller="account-collapse" data-account-collapse-type-value="<%= type %>">
|
2024-02-12 17:20:50 -05:00
|
|
|
<summary class="flex gap-4 px-2 py-3 items-center w-full rounded-[10px] font-medium hover:bg-gray-100">
|
|
|
|
<%= lucide_icon("chevron-down", class: "hidden group-open:block text-gray-500 w-5 h-5") %>
|
|
|
|
<%= lucide_icon("chevron-right", class: "group-open:hidden text-gray-500 w-5 h-5") %>
|
2024-02-08 21:46:27 +00:00
|
|
|
<div class="text-left"><%= type.model_name.human %></div>
|
2024-02-10 16:18:56 -06:00
|
|
|
<div class="ml-auto"><%= format_currency accounts.sum(&:converted_balance) %></div>
|
2024-02-08 21:46:27 +00:00
|
|
|
</summary>
|
|
|
|
|
|
|
|
<% accounts.each do |account| %>
|
2024-02-12 17:20:50 -05:00
|
|
|
<%= link_to account_path(account), class: "flex items-center w-full gap-3 px-2 py-3 mb-1 hover:bg-gray-100 rounded-[10px]" do %>
|
2024-02-08 21:46:27 +00:00
|
|
|
<div>
|
|
|
|
<p class="font-medium"><%= account.name %></p>
|
|
|
|
<% if account.subtype %>
|
2024-02-12 17:20:50 -05:00
|
|
|
<p class="text-xs text-gray-500"><%= account.subtype&.humanize %></p>
|
2024-02-08 21:46:27 +00:00
|
|
|
<% end %>
|
|
|
|
</div>
|
2024-02-10 16:18:56 -06:00
|
|
|
<p class="ml-auto font-medium"><%= format_currency account.converted_balance %></p>
|
2024-02-10 19:39:18 -06:00
|
|
|
<% end %>
|
2024-02-08 21:46:27 +00:00
|
|
|
<% end %>
|
|
|
|
|
2024-02-12 17:20:50 -05:00
|
|
|
<%= link_to new_account_path(step: 'method', type: type.name.demodulize), class: "flex items-center gap-4 px-2 py-3 mb-1 text-gray-500 text-sm font-medium rounded-[10px] hover:bg-gray-100", data: { turbo_frame: "modal" } do %>
|
2024-02-08 21:46:27 +00:00
|
|
|
<%= lucide_icon("plus", class: "w-5 h-5") %>
|
|
|
|
<p>New <%= type.model_name.human.downcase %></p>
|
|
|
|
<% end %>
|
|
|
|
</details>
|
2024-02-08 15:52:33 -06:00
|
|
|
<% end %>
|