Skip to content

armgit / sure

Public Imported from GitHub
0

The personal finance app for everyone (by everyone)

Ruby
2.7 KB
Raw Blame
<%= render DS::Dialog.new do |dialog| %>
  <% dialog.with_header(title: t(".title"), subtitle: t(".description")) %>
  <% dialog.with_body do %>
    <%= styled_form_with url: perform_merge_family_merchants_path, method: :post, class: "space-y-4" do |f| %>
      <%= f.collection_select :target_id,
            @merchants,
            :id, :name,
            { prompt: t(".select_target"), label: t(".target_label"), searchable: true, variant: :logo },
            { required: true } %>

      <div class="space-y-2" data-controller="list-filter">
        <p class="text-sm font-medium text-primary"><%= t(".sources_label") %></p>
        <%= render DS::SearchInput.new(
          variant: :embedded,
          placeholder: t(".sources_search_placeholder"),
          data: {
            list_filter_target: "input",
            action: "input->list-filter#filter keydown->list-filter#handleKeydown"
          }
        ) %>
        <div data-list-filter-target="list" class="max-h-64 overflow-y-auto space-y-1 border border-secondary rounded-lg p-2">
          <p class="hidden text-sm text-secondary px-2 py-1" data-list-filter-target="emptyMessage">
            <%= t(".no_merchants_found") %>
          </p>
          <% @merchants.each do |merchant| %>
            <label class="filterable-item flex items-center gap-2 p-2 hover:bg-surface-hover rounded cursor-pointer"
                   data-filter-name="<%= merchant.name %>">
              <%= check_box_tag "source_ids[]", merchant.id, false, class: "rounded border-secondary" %>
              <div class="hidden lg:flex">
                <% if merchant.logo_url.present? %>
                  <%= image_tag Setting.transform_brand_fetch_url(merchant.logo_url),
                      class: "w-6 h-6 rounded-full border border-secondary",
                      loading: "lazy" %>
                <% else %>
                  <%= render DS::FilledIcon.new(
                    variant: :text,
                    hex_color: merchant.color,
                    text: merchant.name,
                    size: "sm",
                    rounded: true
                  ) %>
                <% end %>
              </div>
              <span class="text-sm text-primary"><%= merchant.name %></span>
              <% if merchant.is_a?(ProviderMerchant) %>
                <span class="text-xs text-subdued">(<%= merchant.source&.titleize %>)</span>
              <% end %>
            </label>
          <% end %>
        </div>
        <p class="text-xs text-subdued"><%= t(".sources_hint") %></p>
      </div>

      <%= render DS::Button.new(
        text: t(".submit"),
        type: :submit,
        full_width: true
      ) %>
    <% end %>
  <% end %>
<% end %>