From 23fb9cf28756873e043ce1849432e2bc1ee7e13a Mon Sep 17 00:00:00 2001 From: Manny Dinssa <44172848+Dinssa@users.noreply.github.com> Date: Tue, 1 Oct 2024 23:44:44 +0100 Subject: [PATCH] Refactor method --- app/components/bulk_upload_summary_component.rb | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/app/components/bulk_upload_summary_component.rb b/app/components/bulk_upload_summary_component.rb index b89b228a7..ec5d6bd1a 100644 --- a/app/components/bulk_upload_summary_component.rb +++ b/app/components/bulk_upload_summary_component.rb @@ -52,15 +52,20 @@ class BulkUploadSummaryComponent < ViewComponent::Base end def view_error_report_link(bulk_upload) - return nil if %w[errors_fixed_in_service logs_uploaded_with_errors logs_uploaded_no_errors wrong_template blank_template].include?(bulk_upload.status.to_s) + status = bulk_upload.status.to_s + return unless %w[important_errors critical_errors potential_errors].include?(status) - return link_to "View error report", send("summary_bulk_upload_#{bulk_upload.log_type}_result_url", bulk_upload), class: "govuk-link" if %w[important_errors].include?(bulk_upload.status.to_s) + path = if status == "important_errors" + "summary_bulk_upload_#{bulk_upload.log_type}_result_url" + else + "bulk_upload_#{bulk_upload.log_type}_result_path" + end - link_to "View error report", send("bulk_upload_#{bulk_upload.log_type}_result_path", bulk_upload.id), class: "govuk-link" + link_to "View error report", send(path, bulk_upload), class: "govuk-link" end def view_logs_link(bulk_upload) - return nil unless %w[logs_uploaded_with_errors].include?(bulk_upload.status.to_s) + return unless bulk_upload.status.to_s == "logs_uploaded_with_errors" link_to "View logs with errors", send("#{bulk_upload.log_type}_logs_path", bulk_upload_id: [bulk_upload.id]), class: "govuk-link" end