Dunlop::Engine.routes.draw do
  root to: 'dashboard#home'
  get 'badge_info' => 'dashboard#badge_info'
  get 'changelog' => 'dashboard#changelog'
  post 'active_mode' => 'dashboard#active_mode', as: :active_mode
  post 'archived_mode' => 'dashboard#archived_mode', as: :archived_mode

  resources :users do
    member do
      post :become_user
    end

    collection do
      get :permissions_table
      get :profile
      get :edit_profile
      patch :update_profile
    end
  end

  resources :source_files, except: [:edit, :update] do
    get :download, on: :member
    post :schedule, on: :member
  end

  resources :target_files, only: [:index, :show, :destroy] do
    member do
      get :download
    end

    get "/download_latest/:target_file_type", action: :download_latest, on: :collection
  end

  resources :execution_batches

  resources :workflow_instances do
    collection do
      post :categorize_as
      post :archive
      post :revive
      post :reset
    end
  end

  namespace :reports do
    get 'system/workflow_instance_fields'
    get 'system/workflow_instance_workflow_steps'
    get 'system/workflow_step_scenarios'
    get 'system/workflow_steps_in_batch_finished'
    get 'system/workflow_steps_overdue'
    root to: 'system#index', as: 'root'
  end
end
