Skip to content

Commit

Permalink
Add foundations for claims support routing
Browse files Browse the repository at this point in the history
  • Loading branch information
Nitemaeric committed Dec 19, 2023
1 parent 5f5b909 commit 9eb2f06
Show file tree
Hide file tree
Showing 12 changed files with 55 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ def current_user
end

def after_sign_in_path
return support_root_path if current_user.support_user?

root_path
end

Expand Down
2 changes: 2 additions & 0 deletions app/controllers/claims/schools_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class Claims::SchoolsController < ApplicationController
end
13 changes: 13 additions & 0 deletions app/controllers/claims/support/application_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class Claims::Support::ApplicationController < ApplicationController
before_action :authenticate_support_user!

private

def authenticate_support_user!
authenticate_user!

unless current_user.support_user?
redirect_to claims_root_path, alert: "You cannot perform this action"
end
end
end
2 changes: 2 additions & 0 deletions app/controllers/claims/support/claims_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class Claims::Support::ClaimsController < Claims::Support::ApplicationController
end
2 changes: 2 additions & 0 deletions app/controllers/claims/support/schools_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class Claims::Support::SchoolsController < Claims::Support::ApplicationController
end
2 changes: 2 additions & 0 deletions app/controllers/claims/support/users_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class Claims::Support::UsersController < Claims::Support::ApplicationController
end
9 changes: 9 additions & 0 deletions app/helpers/routes_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,13 @@ def root_path
placements_root_path
end
end

def support_root_path
case current_service
when :claims
claims_support_root_path
when :placements
placements_root_path # TODO: Add support root path for placements
end
end
end
1 change: 1 addition & 0 deletions app/views/claims/support/claims/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Support / Claims
5 changes: 5 additions & 0 deletions app/views/claims/support/schools/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Support / Schools

<ul>
<li><%= link_to "School 1", claims_support_school_path(1) %></li>
</ul>
7 changes: 7 additions & 0 deletions app/views/claims/support/schools/show.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Support / Schools / 1

<ul>
<li><%= link_to "Organisation Details", claims_support_school_path(params[:id]) %></li>
<li><%= link_to "Users", claims_support_school_users_path(params[:id]) %></li>
<li><%= link_to "Claims", claims_support_school_claims_path(params[:id]) %></li>
</ul>
1 change: 1 addition & 0 deletions app/views/claims/support/users/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Support / Users
9 changes: 9 additions & 0 deletions config/routes/claims.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
scope module: :claims, as: :claims, constraints: { host: ENV["CLAIMS_HOST"] } do
root to: "pages#index"

namespace :support do
root to: redirect("/support/schools")

resources :schools do
resources :claims
resources :users
end
end
end

0 comments on commit 9eb2f06

Please sign in to comment.