Skip to content

Commit

Permalink
Refactor user data handling in Schools::DFESignInAPI::OrganisationUse…
Browse files Browse the repository at this point in the history
…rs and update view to use new attributes
  • Loading branch information
ekumachidi committed Mar 15, 2024
1 parent 351665f commit 6d3c36f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
14 changes: 14 additions & 0 deletions app/services/schools/dfe_sign_in_api/organisation_users.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,20 @@ def ukprn

def users
response&.fetch('users', nil)
users_as_invite_objects
end

def users_as_invite_objects
return [] unless users.present?

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
Expand Down
4 changes: 2 additions & 2 deletions app/views/schools/users/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
<tbody class="govuk-table__body">
<% @users.each do |user| %>
<tr class="govuk-table__row">
<td class="govuk-table__cell"><%= "#{user['firstName']} #{user['lastName']}" %></td>
<td class="govuk-table__cell"><%= user['email'] %></td>
<td class="govuk-table__cell"><%= "#{user.firstname} #{user.lastname}" %></td>
<td class="govuk-table__cell"><%= user.email %></td>
</tr>
<% end %>

Expand Down

0 comments on commit 6d3c36f

Please sign in to comment.