diff --git a/app/helpers/toggle_active_location_helper.rb b/app/helpers/toggle_active_location_helper.rb new file mode 100644 index 000000000..8d76cb6de --- /dev/null +++ b/app/helpers/toggle_active_location_helper.rb @@ -0,0 +1,17 @@ +module ToggleActiveLocationHelper + def toggle_location_form_path(action, scheme_id, location_id) + if action == "deactivate" + scheme_location_new_deactivation_path(scheme_id:, location_id:) + else + scheme_location_new_reactivation_path(scheme_id:, location_id:) + end + end + + def date_type_question(action) + action == "deactivate" ? :deactivation_date_type : :reactivation_date_type + end + + def date_question(action) + action == "deactivate" ? :deactivation_date : :reactivation_date + end +end \ No newline at end of file diff --git a/app/views/locations/toggle_active.html.erb b/app/views/locations/toggle_active.html.erb index 321ee8665..3df9c511c 100644 --- a/app/views/locations/toggle_active.html.erb +++ b/app/views/locations/toggle_active.html.erb @@ -7,29 +7,26 @@ href: scheme_location_path(@location.scheme, @location), ) %> <% end %> -<% form_path = action == "deactivate" ? scheme_location_new_deactivation_path(scheme_id: @location.scheme.id, location_id: @location.id) : scheme_location_new_reactivation_path(scheme_id: @location.scheme.id, location_id: @location.id) %> -<%= form_with model: @location, url: form_path, method: "patch", local: true do |f| %> +<%= form_with model: @location, url: toggle_location_form_path(action, @location.scheme.id, @location.id), method: "patch", local: true do |f| %>