Skip to content

armgit / sure

Public Imported from GitHub
0

The personal finance app for everyone (by everyone)

Ruby
1.7 KB
Raw Blame
<%# locals: (cta:) %>
<% message = t(".message", category_name: cta[:category_name]) %>
<% description = t(".description") %>
<%# The X closes just this prompt. "Not today" snoozes rule prompts for 24 hours, the link turns them off. %>
<%= render "shared/notifications/cta", message: message, description: description, close_label: t(".close") do %>
  <%# Full i18n keys inside this block: lazy t(".x") would resolve against the shared cta partial. %>
  <div>
    <%= form_with model: Current.user, url: rule_prompt_settings_user_path(Current.user), method: :patch do |f| %>
      <%= f.hidden_field :rule_prompt_dismissed_at, value: Time.current %>
      <%= tag.div class: "flex flex-wrap gap-2 justify-end" do %>
        <%= render DS::Button.new(text: t("rules.category_rule_cta.not_today"), variant: "secondary", type: :submit) %>
        <% rule_href = new_rule_path(resource_type: "transaction", action_type: "set_transaction_category", action_value: cta[:category_id], name: cta[:merchant_name]) %>
        <%= render DS::Link.new(text: t("rules.category_rule_cta.create_rule"), variant: "primary", href: rule_href, frame: :modal) %>
      <% end %>
    <% end %>
    <%# A separate form, so turning suggestions off doesn't also start the snooze: turning them %>
    <%# back on in Settings > Preferences, whose toggle this is named after, brings prompts back. %>
    <%= form_with model: Current.user, url: rule_prompt_settings_user_path(Current.user), method: :patch, class: "flex justify-end mt-1" do |f| %>
      <%= f.hidden_field :rule_prompts_disabled, value: true %>
      <%= render DS::Button.new(text: t("rules.category_rule_cta.turn_off_suggestions"), variant: "ghost", size: :sm, type: :submit, class: "text-secondary") %>
    <% end %>
  </div>
<% end %>