Extract methods in order links component

This commit is contained in:
Javi Martín
2021-06-27 17:01:18 +02:00
parent 5137913565
commit cdd1e04550
2 changed files with 24 additions and 4 deletions

View File

@@ -5,4 +5,26 @@ class Shared::OrderLinksComponent < ApplicationComponent
def initialize(i18n_namespace)
@i18n_namespace = i18n_namespace
end
private
def html_class(order)
"is-active" if order == current_order
end
def tag_name(order)
if order == current_order
:h2
else
:span
end
end
def link_path(order)
current_path_with_query_params(order: order, page: 1)
end
def link_text(order)
t("#{i18n_namespace}.orders.#{order}")
end
end