# frozen_string_literal: true
Rails.application.routes.draw do
  get "/styleguide",       to: "application#styleguide", as: :styleguide
  get "/admin/styleguide", to: "application#styleguide"

  post "/admin/login",              to: "admin/auth#auth",           as: :admin_auth
  get  "/admin/login",              to: "admin/auth#login",          as: :admin_login
  get  "/admin/logout",             to: "admin/auth#logout",         as: :admin_logout
  get  "/admin/reset/:reset_token", to: "admin/auth#reset",          as: :admin_reset
  post "/admin/reset",              to: "admin/auth#reset_password", as: :admin_reset_password
  get  "/admin/reset_request",      to: "admin/auth#reset_request",  as: :admin_reset_request
  post "/admin/reset_request",      to: "admin/auth#send_reset",     as: :admin_send_reset

  get   "/admin/quizzes",            to: "admin/quiz#index",  as: :admin_quizzes
  get   "/admin/quiz/new",           to: "admin/quiz#new",    as: :admin_new_quiz
  post  "/admin/quiz/new",           to: "admin/quiz#create", as: :admin_create_quiz
  get   "/admin/quiz/:quiz_id",      to: "admin/quiz#view",   as: :admin_quiz
  get   "/admin/quiz/:quiz_id/edit", to: "admin/quiz#edit",   as: :admin_edit_quiz
  post  "/admin/quiz/:quiz_id/edit", to: "admin/quiz#update", as: :admin_update_quiz
  patch "/admin/quiz/:quiz_id/edit", to: "admin/quiz#update"

  get   "/admin/users",              to: "admin/user#index",  as: :admin_users
  get   "/admin/user/new",           to: "admin/user#new",    as: :admin_new_user
  post  "/admin/user/new",           to: "admin/user#create", as: :admin_create_user
  get   "/admin/user/:user_id",      to: "admin/user#view",   as: :admin_user
  get   "/admin/user/:user_id/edit", to: "admin/user#edit",   as: :admin_edit_user
  post  "/admin/user/:user_id/edit", to: "admin/user#update", as: :admin_update_user
  patch "/admin/user/:user_id/edit", to: "admin/user#update"

  get   "/admin/questions",                                   to: "admin/question#index",   as: :admin_questions
  get   "/admin/question/new",                                to: "admin/question#new",     as: :admin_new_question
  post  "/admin/question/new",                                to: "admin/question#create",  as: :admin_create_question
  get   "/admin/question(/:question_id)/options/:input_type", to: "admin/question#options", as: :admin_question_option_form
  get   "/admin/question/:question_id",                       to: "admin/question#view",    as: :admin_question
  get   "/admin/question/:question_id/edit",                  to: "admin/question#edit",    as: :admin_edit_question
  post  "/admin/question/:question_id/edit",                  to: "admin/question#update",  as: :admin_update_question
  patch "/admin/question/:question_id/edit",                  to: "admin/question#update"

  get  "/admin/profile",      to: "admin/profile#view",   as: :admin_profile
  post "/admin/profile",      to: "admin/profile#update", as: :admin_update_profile
  get  "/admin/profile/edit", to: "admin/profile#edit",   as: :admin_edit_profile

  get  "/admin/candidates",           to: "admin/candidate#index",          as: :admin_candidates
  get  "/admin/candidate/new",        to: "admin/candidate#new",            as: :admin_new_candidate
  post "/admin/candidate/new",        to: "admin/candidate#create",         as: :admin_create_candidate
  get  "/admin/candidate/:id",        to: "admin/candidate#edit",           as: :admin_edit_candidate
  post "/admin/candidate/:id",        to: "admin/candidate#update",         as: :admin_update_candidate
  get  "/admin/candidate/:id/resend", to: "admin/candidate#resend_welcome", as: :admin_resend_welcome

  get "/admin/results",           to: "admin/result#index", as: :admin_results
  get "/admin/result/:test_hash", to: "admin/result#view",  as: :admin_result

  get "admin/vote/:test_hash/up",      to: "admin/vote#up",      as: :admin_up_vote
  get "admin/vote/:test_hash/down",    to: "admin/vote#down",    as: :admin_down_vote
  get "admin/vote/:test_hash/approve", to: "admin/vote#approve", as: :admin_approve_vote
  get "admin/vote/:test_hash/decline", to: "admin/vote#decline", as: :admin_decline_vote

  get "/admin", to: "admin/dashboard#show", as: :admin

  #########################################################################################

  post "/validate",                to: "candidate#validate",  as: :validate_candidate
  get  "/login(/:test_id)",        to: "candidate#login",     as: :login
  get  "/welcome",                 to: "candidate#welcome",   as: :welcome
  get  "/saved",                   to: "candidate#saved",     as: :saved
  get  "/thankyou",                to: "candidate#thankyou",  as: :thankyou
  get  "/oops",                    to: "candidate#oops",      as: :oops

  post "/question(/:answer_id)",   to: "quiz#update_answer",  as: :post_answer
  get  "/question(/:question_id)", to: "quiz#question",       as: :question
  post "/summary",                 to: "quiz#submit_summary", as: :post_summary
  get  "/summary",                 to: "quiz#summary",        as: :summary

  root to: "candidate#login"

  # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
end
