diff --git a/app/components/admin/budgets_wizard/headings/group_switcher_component.html.erb b/app/components/admin/budgets_wizard/headings/group_switcher_component.html.erb
index d30ef5e82..28e260f57 100644
--- a/app/components/admin/budgets_wizard/headings/group_switcher_component.html.erb
+++ b/app/components/admin/budgets_wizard/headings/group_switcher_component.html.erb
@@ -2,21 +2,10 @@
<% if other_groups.one? %>
<%= currently_showing_text %>
- <%= link_to t("admin.budget_headings.group_switcher.the_other_group", group: other_groups.first.name),
- headings_path(other_groups.first) %>
+ <%= link_to_group(other_groups.first) %>
<% else %>
<%= currently_showing_text %>
-
- <% other_groups.each do |other_group| %>
- -
- <%= link_to sanitize(t(
- "admin.budget_headings.group_switcher.the_other_group",
- group: tag.strong(other_group.name)
- )),
- headings_path(other_group) %>
-
- <% end %>
-
+ <%= link_list(*other_groups.map { |group| link_to_group(group) }) %>
<% end %>
diff --git a/app/components/admin/budgets_wizard/headings/group_switcher_component.rb b/app/components/admin/budgets_wizard/headings/group_switcher_component.rb
index ffb85ffda..c6cc6f183 100644
--- a/app/components/admin/budgets_wizard/headings/group_switcher_component.rb
+++ b/app/components/admin/budgets_wizard/headings/group_switcher_component.rb
@@ -1,5 +1,6 @@
class Admin::BudgetsWizard::Headings::GroupSwitcherComponent < ApplicationComponent
attr_reader :group
+ use_helpers :link_list
def initialize(group)
@group = group
@@ -26,4 +27,12 @@ class Admin::BudgetsWizard::Headings::GroupSwitcherComponent < ApplicationCompon
def currently_showing_text
sanitize(t("admin.budget_headings.group_switcher.currently_showing", group: group.name))
end
+
+ def link_to_group(group)
+ link_to(link_to_group_text(group), headings_path(group))
+ end
+
+ def link_to_group_text(group)
+ sanitize(t("admin.budget_headings.group_switcher.the_other_group", group: tag.strong(group.name)))
+ end
end