Skip to content

armgit / sure

Public Imported from GitHub
0

The personal finance app for everyone (by everyone)

Ruby
1.8 KB
Raw Blame
<div id="coinstats-providers-panel" class="space-y-4">
  <%= render "settings/providers/setup_steps",
             steps: [
               t("coinstats_items.new.step1_html").html_safe,
               t("coinstats_items.new.step2"),
               t("coinstats_items.new.step3_html", accounts_url: accounts_path).html_safe
             ] %>

  <% error_msg = local_assigns[:error_message] || @error_message %>
  <% if error_msg.present? %>
    <%= render DS::Alert.new(message: error_msg, variant: :error) %>
  <% end %>

  <%
    # Get or initialize a coinstats_item for this family
    # - If family has an item WITH credentials, use it (for updates)
    # - If family has an item WITHOUT credentials, use it (to add credentials)
    # - If family has no items at all, create a new one
    coinstats_item = Current.family.coinstats_items.first_or_initialize(name: t("coinstats_items.new.default_name"))
    is_new_record = coinstats_item.new_record?
  %>

  <%= styled_form_with model: coinstats_item,
                       url: is_new_record ? coinstats_items_path : coinstats_item_path(coinstats_item),
                       scope: :coinstats_item,
                       method: is_new_record ? :post : :patch,
                       data: { turbo: true },
                       class: "space-y-3" do |form| %>
    <%= form.text_field :api_key,
                        label: t("coinstats_items.new.api_key_label"),
                        placeholder: is_new_record ? t("coinstats_items.new.api_key_placeholder") : t("coinstats_items.new.api_key_placeholder_update"),
                        type: :password,
                        value: nil %>

    <div class="flex justify-end">
      <%= form.submit is_new_record ? t("coinstats_items.new.configure") : t("coinstats_items.new.update_configuration") %>
    </div>
  <% end %>

</div>