The personal finance app for everyone (by everyone)
Ruby
<% content_for :title, t(".title") %>
<%= render DS::Dialog.new do |dialog| %>
<% dialog.with_header(title: t(".title")) do %>
<div class="flex items-center gap-2">
<%= icon "landmark", class: "text-primary" %>
<span class="text-primary"><%= t(".subtitle") %></span>
</div>
<% end %>
<% dialog.with_body do %>
<%= styled_form_with url: complete_account_setup_akahu_item_path(@akahu_item),
method: :post,
scope: :account_types,
local: true,
data: { turbo_frame: "_top" },
class: "space-y-6" do |form| %>
<div class="space-y-4">
<% if @api_error.present? %>
<div class="p-8 flex flex-col gap-3 items-center justify-center text-center">
<%= icon "alert-circle", size: "lg", class: "text-destructive" %>
<p class="text-primary font-medium"><%= t(".fetch_failed") %></p>
<p class="text-destructive text-sm"><%= @api_error %></p>
</div>
<% elsif @akahu_accounts.empty? %>
<div class="p-8 flex flex-col gap-3 items-center justify-center text-center">
<%= icon "check-circle", size: "lg", class: "text-success" %>
<p class="text-primary font-medium"><%= t(".no_accounts_to_setup") %></p>
<p class="text-secondary text-sm"><%= t(".all_accounts_linked") %></p>
</div>
<% else %>
<div class="bg-surface border border-primary p-4 rounded-lg">
<p class="text-sm text-primary"><strong><%= t(".choose_account_type") %></strong></p>
<p class="text-xs text-secondary mt-1"><%= t(".choose_account_type_description") %></p>
</div>
<% @akahu_accounts.each do |akahu_account| %>
<div class="border border-primary rounded-lg p-4">
<div class="mb-3">
<h3 class="font-medium text-primary"><%= akahu_account.name %></h3>
<p class="text-xs text-secondary">
<%= [akahu_account.formatted_account, akahu_account.currency, akahu_account.account_type].compact.join(" · ") %>
</p>
</div>
<%= form.select akahu_account.id,
@account_type_options,
{
label: t(".account_type_label"),
selected: @akahu_account_type_suggestions.fetch(akahu_account.id, "skip")
} %>
</div>
<% end %>
<% end %>
</div>
<div class="flex gap-3">
<%= render DS::Button.new(
text: t(".create_accounts"),
variant: "primary",
icon: "plus",
type: "submit",
class: "flex-1",
disabled: @api_error.present? || @akahu_accounts.empty?
) %>
<%= render DS::Link.new(
text: t(".cancel"),
variant: "secondary",
href: accounts_path
) %>
</div>
<% end %>
<% end %>
<% end %>