Refactor report routes to use scoped routes for better organization and readability

This commit is contained in:
Ahmed Ejaz
2026-02-04 03:55:07 +05:00
parent 90c23d0245
commit 9dcb3ec748
3 changed files with 20 additions and 18 deletions

View File

@@ -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))

View File

@@ -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))

View File

@@ -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