# frozen_string_literal: true

resources :projects, only: [] do
  resource :ux_toolkit_project_settings,
           only: [:update],
           controller: 'ux_toolkit_project_settings'
end

get 'my/favorite_projects',
    to: 'ux_toolkit_favorite_projects#index',
    as: 'ux_toolkit_my_favorite_projects'

get 'my/favorite_queries',
    to: 'ux_toolkit_favorite_queries#index',
    as: 'ux_toolkit_my_favorite_queries'

get 'my/recent_issues',
    to: 'ux_toolkit_recent_issues#index',
    as: 'ux_toolkit_my_recent_issues'

get 'my/recent_projects',
    to: 'ux_toolkit_recent_projects#index',
    as: 'ux_toolkit_my_recent_projects'

get 'my/work',
    to: 'ux_toolkit_my_work#index',
    as: 'ux_toolkit_my_work'

get 'ux_toolkit/team_workload',
    to: 'ux_toolkit_team_workload#index',
    as: 'ux_toolkit_team_workload'

get 'ux_toolkit/project_health',
    to: 'ux_toolkit_project_health#index',
    as: 'ux_toolkit_project_health'

get 'projects/:project_id/ux_toolkit/team_workload',
    to: 'ux_toolkit_team_workload#index',
    as: 'project_ux_toolkit_team_workload'

get 'my/work/settings',
    to: 'ux_toolkit_my_work#settings',
    as: 'ux_toolkit_my_work_settings'

patch 'my/work/settings',
      to: 'ux_toolkit_my_work#update_settings'

get 'admin/ux_toolkit/logs',
    to: 'ux_toolkit_log_files#index',
    as: 'ux_toolkit_log_files'

get 'admin/ux_toolkit/attachment_storage',
    to: 'ux_toolkit_attachment_storage#index',
    as: 'ux_toolkit_attachment_storage'

post 'admin/ux_toolkit/attachment_storage/bulk_update',
     to: 'ux_toolkit_attachment_storage#bulk_update',
     as: 'bulk_update_ux_toolkit_attachment_storage'

post 'admin/ux_toolkit/logs/flush',
     to: 'ux_toolkit_log_files#flush',
     as: 'flush_ux_toolkit_log_file'

post 'admin/ux_toolkit/cron/run',
     to: 'ux_toolkit_cron_runs#create',
     as: 'run_ux_toolkit_cron'

post 'admin/ux_toolkit/issue_reminders/send',
     to: 'ux_toolkit_issue_reminder_emails#create',
     as: 'send_ux_toolkit_issue_reminders'

post 'admin/ux_toolkit/repository_refresh/:id/refresh',
     to: 'ux_toolkit_repository_refreshes#create',
     as: 'refresh_ux_toolkit_repository'

resources :ux_toolkit_ticket_templates,
          path: 'ux_toolkit/ticket_templates',
          except: [:show] do
  member do
    post :enable
    post :disable
  end
end

resources :ux_toolkit_text_snippets,
          path: 'ux_toolkit/text_snippets',
          except: [:show] do
  member do
    post :enable
    post :disable
  end
end

resources :ux_toolkit_recurring_issue_rules,
          path: 'ux_toolkit/recurring_issue_rules',
          except: [:show]

post 'issues/:id/ux_toolkit/assign_to_me',
     to: 'ux_toolkit_issue_actions#assign_to_me',
     as: 'ux_toolkit_assign_issue_to_me'

post 'issues/:id/ux_toolkit/assign_to_me_and_start',
     to: 'ux_toolkit_issue_actions#assign_to_me_and_start',
     as: 'ux_toolkit_assign_issue_to_me_and_start'

post 'issues/:id/ux_toolkit/change_status',
     to: 'ux_toolkit_issue_actions#change_status',
     as: 'ux_toolkit_change_issue_status'

post 'issues/:issue_id/ux_toolkit/checklist_items',
     to: 'ux_toolkit_checklist_items#create',
     as: 'ux_toolkit_issue_checklist_items'

patch 'issues/:issue_id/ux_toolkit/checklist_items/:id',
      to: 'ux_toolkit_checklist_items#update',
      as: 'ux_toolkit_issue_checklist_item'

delete 'issues/:issue_id/ux_toolkit/checklist_items/:id',
       to: 'ux_toolkit_checklist_items#destroy'

post 'issues/:issue_id/ux_toolkit/checklist_items/:id/toggle',
     to: 'ux_toolkit_checklist_items#toggle',
     as: 'toggle_ux_toolkit_issue_checklist_item'

post 'issues/:issue_id/ux_toolkit/checklist_templates/insert',
     to: 'ux_toolkit_checklist_template_insertions#create',
     as: 'insert_ux_toolkit_issue_checklist_template'

get 'ux_toolkit/checklist_templates/tracker_defaults',
    to: 'ux_toolkit_tracker_checklist_templates#index',
    as: 'ux_toolkit_tracker_checklist_templates'

patch 'ux_toolkit/checklist_templates/tracker_defaults',
      to: 'ux_toolkit_tracker_checklist_templates#update'

resources :ux_toolkit_checklist_templates,
          path: 'ux_toolkit/checklist_templates',
          except: [:show] do
  resources :items,
            controller: 'ux_toolkit_checklist_template_items',
            only: [:create, :update, :destroy],
            as: 'items' do
    member do
      post :move_up
      post :move_down
    end
  end
end

post 'ux_toolkit/favorite_projects/:project_id',
     to: 'ux_toolkit_favorite_projects#create',
     as: 'ux_toolkit_favorite_project'

delete 'ux_toolkit/favorite_projects/:project_id',
       to: 'ux_toolkit_favorite_projects#destroy',
       as: 'remove_ux_toolkit_favorite_project'

post 'ux_toolkit/favorite_queries/:query_id',
     to: 'ux_toolkit_favorite_queries#create',
     as: 'ux_toolkit_favorite_query'

delete 'ux_toolkit/favorite_queries/:query_id',
       to: 'ux_toolkit_favorite_queries#destroy',
       as: 'remove_ux_toolkit_favorite_query'
