Rails.application.routes.draw do

  WorkflowInstance.possible_workflow_step_names.each do |workflow_step|
    namespace workflow_step do
      WorkflowInstance.scenario_names.each do |scenario_name|
        collection_resources scenario_name.to_s.pluralize, only: [:edit, :update]
      end
    end
  end

  mount Dunlop::Engine => "/dunlop"

  namespace :workflow_instance do
    WorkflowInstance.scenario_names.each do |scenario_name|
      collection_resources scenario_name.to_s.pluralize do
        collection do
          match :selection, via: [:get, :post]
        end
        post :reset, on: :member
      end
    end
  end

  namespace :workflow_instance_batch do
    WorkflowInstance.scenario_names.each do |scenario_name|
      resources scenario_name.to_s.pluralize
    end
  end

  root to: 'dashboard#home'
  get 'dashboard/render_as_dunlop_modal_test'

  devise_for :users
end
