Rails.application.routes.draw do
  devise_for :users
  mount Crono::Engine, at: '/crono'
  mount ActionCable.server => '/cable'

  get 'speakers/show'

  # Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500.
  # Can be used by load balancers and uptime monitors to verify that the app is live.
  get "up" => "rails/health#show", as: :rails_health_check

  # Defines the root path route ("/")
  # root "posts#index"
  root "conferences#index"

  resources :conferences, param: :slug do
    get 'stats', on: :member
    get ':date', action: :show, on: :member, as: :date, date: /\d{4}-\d{2}-\d{2}/
    resources :sessions, param: :ref_id do
      member do
        patch :update_notes
      end
      resources :assignments, only: [:create, :destroy]
      resources :candidates, only: [:create, :destroy]
      delete 'candidates', to: 'candidates#destroy_self'
    end
    resources :speakers, param: :ref_id
  end

  resources :assignments, only: [:index] do
    get 'for/:user_id', action: 'by_user', on: :collection, as: :user
  end
  resources :sessions, param: :ref_id

  # get 'conferences/:slug', to: 'conferences#show', as: :conference
  # get 'conferences/:slug/:date', to: 'conferences#show', as: :conference_day
  # get 'conferences/:slug/session/:ref_id', to: 'sessions#show', as: :conference_session
  # post 'conferences/:slug/session/:ref_id/assignments', to: 'sessions#assign_user', as: :assign_user_session
  # delete 'conferences/:slug/session/:ref_id/assignments', to: 'sessions#unassign_user', as: :unassign_user_session
  # get 'assignments', to: 'assignments#index', as: :assignments
  # get 'assignments/:user_id', to: 'assignments#index', as: :user_assignments
end