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 %>
<%= form_with url: complete_account_setup_monobank_item_path(@monobank_item),
method: :post,
local: true,
data: { turbo_frame: "_top" },
class: "space-y-6" do %>
<div class="space-y-4">
<%# A refresh failure (Monobank allows one request per minute) must not hide the %>
<%# accounts the last sync already stored: the notice is informational and setup %>
<%# carries on with what is on file. %>
<% if @api_error.present? %>
<%= render DS::Alert.new(message: @api_error, variant: :warning) %>
<% end %>
<% if @monobank_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>
<% @monobank_accounts.each do |monobank_account| %>
<div class="border border-primary rounded-lg p-4">
<div class="mb-3">
<h3 class="font-medium text-primary"><%= monobank_account.name %></h3>
<p class="text-xs text-secondary">
<%= [monobank_account.type_label, monobank_account.currency].compact_blank.join(" · ") %>
</p>
</div>
<%= label_tag "account_types[#{monobank_account.id}]", t(".account_type_label"),
class: "block text-sm font-medium text-primary mb-2" %>
<%= select_tag "account_types[#{monobank_account.id}]",
options_for_select(@account_type_options, @monobank_account_type_suggestions.fetch(monobank_account.id, "skip")),
class: "appearance-none bg-container border border-primary rounded-md px-3 py-2 text-sm leading-6 text-primary focus:border-primary focus:ring-1 focus:ring-primary focus:outline-none w-full" %>
</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: @monobank_accounts.empty?
) %>
<%= render DS::Link.new(
text: t(".cancel"),
variant: "secondary",
href: accounts_path
) %>
</div>
<% end %>
<% end %>
<% end %>