<%# locals: (outflows_data:, period:) %>
<%= form_with url: root_path, method: :get, data: { controller: "auto-submit-form", turbo_frame: "_top" } do |form| %> <%= form.select :period, Period.as_options, { selected: period.key }, data: { "auto-submit-form-target": "auto" }, class: "bg-container border border-secondary font-medium rounded-lg px-3 py-2 text-sm pr-7 cursor-pointer text-primary focus:outline-hidden focus:ring-0" %> <% end %>
<%= t("pages.dashboard.outflows_donut.total_outflows") %>
<%= format_money Money.new(outflows_data[:total], outflows_data[:currency]) %>
<% outflows_data[:categories].each do |category| %> <% end %>

<%= t("pages.dashboard.outflows_donut.categories") %>·<%= outflows_data[:categories].count %>

<%= t("pages.dashboard.outflows_donut.value") %>

<%= t("pages.dashboard.outflows_donut.weight") %>

<% outflows_data[:categories].each_with_index do |category, idx| %> <% category_content = capture do %>
<% if category[:icon] %> <%= icon(category[:icon], color: "current", size: "sm") %> <% else %> <%= render DS::FilledIcon.new( variant: :text, hex_color: category[:color], text: category[:name], size: "sm", rounded: true ) %> <% end %>
<%= category[:name] %>
<%= format_money Money.new(category[:amount], category[:currency]) %> <%= category[:percentage] %>%
<% end %> <% if category[:clickable] != false %> <%= link_to transactions_path(q: { categories: [category[:name]], start_date: period.date_range.first, end_date: period.date_range.last }), class: "flex items-center justify-between mx-3 p-3 rounded-lg cursor-pointer group gap-3", data: { turbo_frame: "_top", category_id: category[:id], action: "mouseenter->donut-chart#highlightSegment mouseleave->donut-chart#unhighlightSegment" } do %> <%= category_content %> <% end %> <% else %>
<%= category_content %>
<% end %> <% if idx < outflows_data[:categories].size - 1 %> <%= render "shared/ruler", classes: "mx-3 lg:mx-4" %> <% end %> <% end %>