The personal finance app for everyone (by everyone)
Ruby
<%# locals: (active:) %>
<%# Page title and primary action in the header, view switcher beneath, matching
transactions/index. Bills was the only top-level destination in the app with
no heading at all, which also left screen readers with no outline to navigate. %>
<%# Both halves are addable from every view, but only the one this view is
about earns a header button: Add income on the Income plan, Add bill
everywhere else. The other half and the AI review live in the overflow
menu, so the header carries one action instead of a toolbar of three.
Laid out the way Transactions lays out New transaction: the menu first,
the primary action last, and a round + in its place on a phone. %>
<% income_first = active == "paycheck" %>
<% add_text = income_first ? t("bills.index.add_income") : t("bills.index.add_bill") %>
<% add_href = income_first ? new_recurring_transaction_path(income: true) : new_recurring_transaction_path %>
<header class="flex justify-between items-center gap-2 text-primary font-medium">
<h1 class="text-xl"><%= t("bills.index.title") %></h1>
<div class="flex items-center gap-2 shrink-0">
<%= render DS::Menu.new do |menu| %>
<% menu.with_item(
variant: "link",
text: income_first ? t("bills.index.add_bill") : t("bills.index.add_income"),
icon: "plus",
href: income_first ? new_recurring_transaction_path : new_recurring_transaction_path(income: true),
data: { turbo_frame: :modal }) %>
<%# Seeds a chat with the server-owned review prompt into the sidebar
frame; the audit tool grounds the findings. Needs AI consent plus a
configured provider, or the item leads to a dead chat. %>
<% if bills_ai_chat_available? %>
<% menu.with_item(
variant: "button",
text: t("bills.index.review_with_ai"),
icon: "sparkles",
href: ai_review_bills_path,
method: :post,
frame: chat_frame,
data: { action: "app-layout#openRightSidebar" }) %>
<% end %>
<% end %>
<%= render DS::Link.new(
text: add_text,
icon: "plus",
variant: "primary",
href: add_href,
frame: :modal,
class: "hidden md:inline-flex"
) %>
<%= render DS::Link.new(
icon: "plus",
variant: "icon-inverse",
href: add_href,
frame: :modal,
class: "rounded-full md:hidden",
aria: { label: add_text }
) %>
</div>
</header>
<%# The control's own track is the page's colour in light mode, so on the
page it showed only the selected pill and loose words. surface-inset is the
track DS::Tabs gives Transactions' view switch, and the budgets owner
switcher already overrides it the same way. %>
<%= render DS::SegmentedControl.new(aria_label: t("bills.views.aria_label"), class: "bg-surface-inset") do |control| %>
<% control.with_segment(t("bills.views.overview"), active: active == "overview", href: bills_path) %>
<% control.with_segment(t("bills.views.calendar"), active: active == "calendar", href: bills_path(view: "calendar")) %>
<% control.with_segment(t("bills.views.paycheck"), active: active == "paycheck", href: bills_path(view: "paycheck")) %>
<% control.with_segment(t("bills.views.all"), active: active == "all", href: bills_path(view: "all")) %>
<% end %>