diff --git a/app/controllers/organisations_controller.rb b/app/controllers/organisations_controller.rb index 796c1eded..03368b216 100644 --- a/app/controllers/organisations_controller.rb +++ b/app/controllers/organisations_controller.rb @@ -1,7 +1,18 @@ class OrganisationsController < ApplicationController before_action :authenticate_user! + before_action :find_organisation - def show + def details + render "details" + end + + def users + render "users" + end + +private + + def find_organisation @organisation = Organisation.find(params[:id]) end end diff --git a/app/views/organisations/_details.html.erb b/app/views/organisations/details.html.erb similarity index 100% rename from app/views/organisations/_details.html.erb rename to app/views/organisations/details.html.erb diff --git a/app/views/organisations/show.html.erb b/app/views/organisations/show.html.erb index 193c702bc..34df9ddb6 100644 --- a/app/views/organisations/show.html.erb +++ b/app/views/organisations/show.html.erb @@ -10,6 +10,6 @@ <%= render TabNavigationComponent.new(items: [ - { name: t('Details'), partial: '_details' }, - { name: t('Users'), url: '#' }, + { name: t('Details'), url: details_organisation_path(@organisation) }, + { name: t('Users'), url: users_organisation_path(@organisation) }, ]) %> diff --git a/app/views/organisations/users.html.erb b/app/views/organisations/users.html.erb new file mode 100644 index 000000000..0e18005e6 --- /dev/null +++ b/app/views/organisations/users.html.erb @@ -0,0 +1,18 @@ +<%= govuk_table do |table| %> + <%= table.head do |head| %> + <%= head.row do |row| + row.cell(header: true, text: "Name and email adress") + row.cell(header: true, text: "Organisation and role") + row.cell(header: true, text: "Last logged in") + end %> + <% end %> + <% @organisation.users.each do |user| %> + <%= table.body do |body| %> + <%= body.row do |row| + row.cell(text: simple_format(user.name_email_display, {}, wrapper_tag: "div")) + row.cell(text: simple_format(user.org_role_display, {}, wrapper_tag: "div")) + row.cell(text: user.last_sign_in_at_display ) + end %> + <% end %> + <% end %> +<% end %> diff --git a/config/routes.rb b/config/routes.rb index af7981407..7c16c0708 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -18,7 +18,12 @@ Rails.application.routes.draw do form_handler = FormHandler.instance form = form_handler.get_form("2021_2022") - resources :organisations + resources :organisations do + member do + get "details", to: "organisations#details" + get "users", to: "organisations#users" + end + end resources :case_logs do collection do