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 %>
<div class="space-y-4">
<% if @fio_account.nil? %>
<%# No account to set up: either the first sync has not reported one yet, or the %>
<%# one account this token reaches is already linked or skipped. %>
<div class="p-8 flex flex-col gap-3 items-center justify-center text-center">
<% if @discovered_account %>
<%= icon "check-circle", size: "lg", class: "text-success" %>
<p class="text-primary font-medium"><%= t(".nothing_to_setup") %></p>
<p class="text-secondary text-sm"><%= t(".account_already_handled") %></p>
<% else %>
<%= icon "landmark", size: "lg", class: "text-secondary" %>
<p class="text-primary font-medium"><%= t(".awaiting_first_sync") %></p>
<p class="text-secondary text-sm"><%= t(".awaiting_first_sync_description") %></p>
<%= render DS::Button.new(
text: t(".sync_now"),
icon: "refresh-cw",
variant: "primary",
href: sync_fio_item_path(@fio_item),
method: :post,
disabled: @fio_item.syncing?,
data: { turbo_frame: "_top" }
) %>
<% end %>
</div>
<div class="flex justify-end">
<%= render DS::Link.new(text: t(".close"), variant: "secondary", href: accounts_path) %>
</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>
<%= form_with url: complete_account_setup_fio_item_path(@fio_item),
method: :post,
data: { turbo_frame: "_top" },
class: "space-y-6" do %>
<%= hidden_field_tag :return_to, @return_to %>
<div class="border border-primary rounded-lg p-4">
<div class="mb-3">
<h3 class="font-medium text-primary"><%= @fio_account.name %></h3>
<p class="text-xs text-secondary">
<%= [ [ @fio_account.fio_account_id, @fio_account.bank_id ].compact_blank.join("/").presence, @fio_account.currency ].compact_blank.join(" · ") %>
</p>
</div>
<%= label_tag :account_type, t(".account_type_label"),
class: "block text-sm font-medium text-primary mb-2" %>
<%= select_tag :account_type,
options_for_select(@account_type_options, @selected_account_type),
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>
<div class="flex gap-3">
<%= render DS::Button.new(
text: t(".create_account"),
variant: "primary",
icon: "plus",
type: "submit",
class: "flex-1"
) %>
<%= render DS::Link.new(
text: t(".cancel"),
variant: "secondary",
href: @return_to || accounts_path
) %>
</div>
<% end %>
<% end %>
</div>
<% end %>
<% end %>