From 9dcb3ec7488bb04147849c54b3d3495c020051da Mon Sep 17 00:00:00 2001 From: Ahmed Ejaz Date: Wed, 4 Feb 2026 03:55:07 +0500 Subject: [PATCH] Refactor report routes to use scoped routes for better organization and readability --- ...prise_fees_with_tax_report_by_order.html.haml | 10 +++++----- ...se_fees_with_tax_report_by_producer.html.haml | 12 ++++++------ config/routes/admin.rb | 16 +++++++++------- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/app/views/admin/reports/filters/_enterprise_fees_with_tax_report_by_order.html.haml b/app/views/admin/reports/filters/_enterprise_fees_with_tax_report_by_order.html.haml index 1001886995..c3aa10070e 100644 --- a/app/views/admin/reports/filters/_enterprise_fees_with_tax_report_by_order.html.haml +++ b/app/views/admin/reports/filters/_enterprise_fees_with_tax_report_by_order.html.haml @@ -7,7 +7,7 @@ options: [], selected_option: params.dig(:q, :distributor_id_in), multiple: true, - remote_url: admin_search_distributors_reports_url)) + remote_url: admin_reports_search_distributors_url)) .row .alpha.two.columns= label_tag nil, t(:report_customers_cycle) @@ -17,7 +17,7 @@ options: [], selected_option: params.dig(:q, :order_cycle_id_in), multiple: true, - remote_url: admin_search_order_cycles_reports_url)) + remote_url: admin_reports_search_order_cycles_url)) .row .alpha.two.columns= label_tag nil, t(:fee_name) @@ -27,7 +27,7 @@ options: [], selected_option: params.dig(:q, :enterprise_fee_id_in), multiple: true, - remote_url: admin_search_enterprise_fees_reports_url(search_url_query))) + remote_url: admin_reports_search_enterprise_fees_url(search_url_query))) .row .alpha.two.columns= label_tag nil, t(:fee_owner) @@ -37,7 +37,7 @@ options: [], selected_option: params.dig(:q, :enterprise_fee_owner_id_in), multiple: true, - remote_url: admin_search_enterprise_fee_owners_reports_url(search_url_query))) + remote_url: admin_reports_search_enterprise_fee_owners_url(search_url_query))) .row .alpha.two.columns= label_tag nil, t(:report_customers) @@ -47,4 +47,4 @@ options: [], selected_option: params.dig(:q, :customer_id_in), multiple: true, - remote_url: admin_search_order_customers_reports_url)) + remote_url: admin_reports_search_order_customers_url)) diff --git a/app/views/admin/reports/filters/_enterprise_fees_with_tax_report_by_producer.html.haml b/app/views/admin/reports/filters/_enterprise_fees_with_tax_report_by_producer.html.haml index c71e92ae58..3eb41c1733 100644 --- a/app/views/admin/reports/filters/_enterprise_fees_with_tax_report_by_producer.html.haml +++ b/app/views/admin/reports/filters/_enterprise_fees_with_tax_report_by_producer.html.haml @@ -7,7 +7,7 @@ options: [], selected_option: params.dig(:q, :distributor_id_in), multiple: true, - remote_url: admin_search_distributors_reports_url)) + remote_url: admin_reports_search_distributors_url)) .row .alpha.two.columns= label_tag nil, t(:report_producers) .omega.fourteen.columns @@ -15,7 +15,7 @@ options: [], selected_option: params.dig(:supplier_id_in), multiple: true, - remote_url: admin_search_suppliers_reports_url)) + remote_url: admin_reports_search_suppliers_url)) .row .alpha.two.columns= label_tag nil, t(:report_customers_cycle) @@ -25,7 +25,7 @@ options: [], selected_option: params.dig(:q, :order_cycle_id_in), multiple: true, - remote_url: admin_search_order_cycles_reports_url)) + remote_url: admin_reports_search_order_cycles_url)) .row .alpha.two.columns= label_tag nil, t(:fee_name) .omega.fourteen.columns @@ -34,7 +34,7 @@ options: [], selected_option: params.dig(:q, :enterprise_fee_id_in), multiple: true, - remote_url: admin_search_enterprise_fees_reports_url(search_url_query))) + remote_url: admin_reports_search_enterprise_fees_url(search_url_query))) .row .alpha.two.columns= label_tag nil, t(:fee_owner) @@ -44,7 +44,7 @@ options: [], selected_option: params.dig(:q, :enterprise_fee_owner_id_in), multiple: true, - remote_url: admin_search_enterprise_fee_owners_reports_url(search_url_query))) + remote_url: admin_reports_search_enterprise_fee_owners_url(search_url_query))) .row .alpha.two.columns= label_tag nil, t(:report_customers) @@ -54,4 +54,4 @@ options: [], selected_option: params.dig(:q, :customer_id_in), multiple: true, - remote_url: admin_search_order_customers_reports_url)) + remote_url: admin_reports_search_order_customers_url)) diff --git a/config/routes/admin.rb b/config/routes/admin.rb index 68c60b29f9..305ef999f6 100644 --- a/config/routes/admin.rb +++ b/config/routes/admin.rb @@ -136,13 +136,15 @@ Openfoodnetwork::Application.routes.draw do put :resume, on: :member, format: :json end - get '/reports', to: 'reports#index', as: :reports - get '/reports/search_enterprise_fees', to: 'reports#search_enterprise_fees', as: :search_enterprise_fees_reports - get '/reports/search_enterprise_fee_owners', to: 'reports#search_enterprise_fee_owners', as: :search_enterprise_fee_owners_reports - get '/reports/search_distributors', to: 'reports#search_distributors', as: :search_distributors_reports - get '/reports/search_suppliers', to: 'reports#search_suppliers', as: :search_suppliers_reports - get '/reports/search_order_cycles', to: 'reports#search_order_cycles', as: :search_order_cycles_reports - get '/reports/search_order_customers', to: 'reports#search_order_customers', as: :search_order_customers_reports + scope :reports, as: :reports do + get '/', to: 'reports#index' + get '/search_enterprise_fees', to: 'reports#search_enterprise_fees', as: :search_enterprise_fees + get '/search_enterprise_fee_owners', to: 'reports#search_enterprise_fee_owners', as: :search_enterprise_fee_owners + get '/search_distributors', to: 'reports#search_distributors', as: :search_distributors + get '/search_suppliers', to: 'reports#search_suppliers', as: :search_suppliers + get '/search_order_cycles', to: 'reports#search_order_cycles', as: :search_order_cycles + get '/search_order_customers', to: 'reports#search_order_customers', as: :search_order_customers + end match '/reports/:report_type(/:report_subtype)', to: 'reports#show', via: :get, as: :report match '/reports/:report_type(/:report_subtype)', to: 'reports#create', via: :post end