From 351665f35d11a7a3d77bd052bff988dcbac831b1 Mon Sep 17 00:00:00 2001 From: Chidi Ekuma Date: Fri, 15 Mar 2024 17:56:21 +0000 Subject: [PATCH 1/2] Add pagination to user index page --- app/views/schools/users/index.html.erb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/views/schools/users/index.html.erb b/app/views/schools/users/index.html.erb index abe596e39..9ddc13ae4 100644 --- a/app/views/schools/users/index.html.erb +++ b/app/views/schools/users/index.html.erb @@ -28,7 +28,9 @@ <% if @users.any? %>
+ <%= page_entries_info @users %>
+ <%= paginate @users %>
@@ -48,6 +50,7 @@
+ <%= paginate @users %>
<% else %>

From 44451ad159cd52215a51e46998a9b27892e109a2 Mon Sep 17 00:00:00 2001 From: Chidi Ekuma Date: Fri, 15 Mar 2024 19:14:26 +0000 Subject: [PATCH 2/2] Refactor user data handling in Schools::DFESignInAPI::OrganisationUsers and update view to use new attributes - Update specs --- app/controllers/schools/users_controller.rb | 2 +- .../schools/dfe_sign_in_api/organisation_users.rb | 14 ++++++++++++++ app/views/schools/users/index.html.erb | 4 ++-- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/app/controllers/schools/users_controller.rb b/app/controllers/schools/users_controller.rb index 2609d3f2f..5515cbd2f 100644 --- a/app/controllers/schools/users_controller.rb +++ b/app/controllers/schools/users_controller.rb @@ -1,7 +1,7 @@ module Schools class UsersController < BaseController def index - @users = DFESignInAPI::OrganisationUsers.new(current_user.sub, current_school.urn).users + @users = DFESignInAPI::OrganisationUsers.new(current_user.sub, current_school.urn).users_as_invite_objects @dfe_sign_in_manage_users_url = Rails.application.config.x.dfe_sign_in_manage_users_url.presence end diff --git a/app/services/schools/dfe_sign_in_api/organisation_users.rb b/app/services/schools/dfe_sign_in_api/organisation_users.rb index e256d33d5..dc71a14b3 100644 --- a/app/services/schools/dfe_sign_in_api/organisation_users.rb +++ b/app/services/schools/dfe_sign_in_api/organisation_users.rb @@ -14,6 +14,20 @@ def ukprn def users response&.fetch('users', nil) + # users_as_invite_objects + end + + def users_as_invite_objects + return [] if users.blank? + + users.map do |user_data| + Schools::DFESignInAPI::UserInvite.new( + email: user_data['email'], + firstname: user_data['firstName'], + lastname: user_data['lastName'], + organisation_id: current_school_urn + ) + end end private diff --git a/app/views/schools/users/index.html.erb b/app/views/schools/users/index.html.erb index 9ddc13ae4..08b124f14 100644 --- a/app/views/schools/users/index.html.erb +++ b/app/views/schools/users/index.html.erb @@ -42,8 +42,8 @@ <% @users.each do |user| %> - <%= "#{user['firstName']} #{user['lastName']}" %> - <%= user['email'] %> + <%= "#{user.firstname} #{user.lastname}" %> + <%= user.email %> <% end %>