diff --git a/app/components/search_component.rb b/app/components/search_component.rb index e97398f9e..36d621240 100644 --- a/app/components/search_component.rb +++ b/app/components/search_component.rb @@ -23,7 +23,7 @@ class SearchComponent < ViewComponent::Base user_path(current_user) elsif request.path.include?("organisations") organisations_path - elsif FeatureToggle.sales_log_enabled? && request.path.include?("sales-logs") + elsif request.path.include?("sales-logs") sales_logs_path elsif request.path.include?("logs") lettings_logs_path diff --git a/app/helpers/logs_helper.rb b/app/helpers/logs_helper.rb index 88ab2b314..628a9067d 100644 --- a/app/helpers/logs_helper.rb +++ b/app/helpers/logs_helper.rb @@ -23,4 +23,20 @@ module LogsHelper array = bulk_upload ? [bulk_upload.id] : [] array.index_with { |_bulk_upload_id| "With logs from bulk upload" } end + + def search_label_for_controller(controller) + case log_type_for_controller(controller) + when "lettings" + "Search by log ID, tenant code, property reference or postcode" + when "sales" + "Search by log ID, purchaser code or postcode" + end + end + + def csv_download_url_for_controller(controller) + case log_type_for_controller(controller) + when "lettings" + csv_download_lettings_logs_path(search: @search_term) + end + end end diff --git a/app/views/logs/index.html.erb b/app/views/logs/index.html.erb index 349d9f29d..0e4cd76df 100644 --- a/app/views/logs/index.html.erb +++ b/app/views/logs/index.html.erb @@ -64,24 +64,9 @@ <%= render partial: "log_filters" %>
- <% if current_page?(controller: 'lettings_logs', action: 'index') %> - <%= render SearchComponent.new(current_user:, search_label: "Search by log ID, tenant code, property reference or postcode", value: @searched) %> - <% end %> - - <% if FeatureToggle.sales_log_enabled? && current_page?(controller: 'sales_logs', action: 'index') %> - <%= render SearchComponent.new(current_user:, search_label: "Search by log ID, purchaser code or postcode", value: @searched) %> - <% end %> - + <%= render SearchComponent.new(current_user:, search_label: search_label_for_controller(controller), value: @searched) %> <%= govuk_section_break(visible: true, size: "m") %> - - <% if current_page?(controller: 'lettings_logs', action: 'index') %> - <%= render partial: "log_list", locals: { logs: @logs, title: "Logs", pagy: @pagy, searched: @searched, item_label:, total_count: @total_count, csv_download_url: csv_download_lettings_logs_path(search: @search_term) } %> - <% end %> - - <% if FeatureToggle.sales_log_enabled? && current_page?(controller: 'sales_logs', action: 'index') %> - <%= render partial: "log_list", locals: { logs: @logs, title: "Logs", pagy: @pagy, searched: @searched, item_label:, total_count: @total_count } %> - <% end %> - + <%= render partial: "log_list", locals: { logs: @logs, title: "Logs", pagy: @pagy, searched: @searched, item_label:, total_count: @total_count, csv_download_url: csv_download_url_for_controller(controller) } %> <%== render partial: "pagy/nav", locals: { pagy: @pagy, item_name: "logs" } %>