diff --git a/app/components/related_organisation_search_component.html.erb b/app/components/related_organisation_search_component.html.erb
new file mode 100644
index 000000000..e77881bc9
--- /dev/null
+++ b/app/components/related_organisation_search_component.html.erb
@@ -0,0 +1,14 @@
+<%= form_with model: @user, url: path(current_user), method: "get", local: true do |f| %>
+
+ <%= f.govuk_text_field :search,
+ form_group: {
+ class: "app-search__form-group",
+ },
+ label: { text: search_label },
+ type: "search",
+ value:,
+ autocomplete: "off",
+ class: "app-search__input" %>
+
+ <%= f.govuk_submit "Add" %>
+<% end %>
diff --git a/app/components/related_organisation_search_component.rb b/app/components/related_organisation_search_component.rb
new file mode 100644
index 000000000..95ffe66cf
--- /dev/null
+++ b/app/components/related_organisation_search_component.rb
@@ -0,0 +1,2 @@
+class RelatedOrganisationSearchComponent < SearchComponent
+end
diff --git a/app/controllers/organisation_relationships_controller.rb b/app/controllers/organisation_relationships_controller.rb
index 98456ac7b..e228edef8 100644
--- a/app/controllers/organisation_relationships_controller.rb
+++ b/app/controllers/organisation_relationships_controller.rb
@@ -18,6 +18,19 @@ class OrganisationRelationshipsController < ApplicationController
end
end
+ def add_housing_provider
+ housing_providers = organisation.housing_providers
+ unpaginated_filtered_housing_providers = filtered_collection(housing_providers, search_term)
+ respond_to do |format|
+ format.html do
+ @pagy, @housing_providers = pagy(unpaginated_filtered_housing_providers)
+ @searched = search_term.presence
+ @total_count = housing_providers.size
+ render "organisation_relationships/add_housing_provider", layout: "application"
+ end
+ end
+ end
+
private
def organisation
diff --git a/app/views/organisation_relationships/add_housing_provider.html.erb b/app/views/organisation_relationships/add_housing_provider.html.erb
new file mode 100644
index 000000000..2735591a4
--- /dev/null
+++ b/app/views/organisation_relationships/add_housing_provider.html.erb
@@ -0,0 +1,11 @@
+<%= render partial: "organisations/headings", locals: { main: "What is the name of your housing provider?", sub: nil } %>
+<%= render RelatedOrganisationSearchComponent.new(current_user:, search_label: "Start typing to search for your housing provider", value: @searched) %>
+<%= govuk_details(summary_text: "Can't find the housing provider you're looking for?") do %>
+
+ - Double check the spelling and try again
+ - Type the first few letters to see the suggestions
+ - If you still can't find it,
+ <%= govuk_link_to("contact the DLUHC service desk", "https://digital.dclg.gov.uk/jira/servicedesk/customer/portal/4/group/21", rel: "noreferrer noopener", target: "_blank") %>
+
+
+<% end %>
diff --git a/app/views/organisation_relationships/housing_providers.html.erb b/app/views/organisation_relationships/housing_providers.html.erb
index 84f38cde6..31b4afb54 100644
--- a/app/views/organisation_relationships/housing_providers.html.erb
+++ b/app/views/organisation_relationships/housing_providers.html.erb
@@ -1,6 +1,4 @@
<% item_label = format_label(@pagy.count, "housing providers") %>
-<% title = "Housing Providers" %>
-<% content_for :title, title %>
<% if current_user.support? %>
<%= render partial: "organisations/headings", locals: { main: @organisation.name, sub: nil } %>
<%= render SubNavigationComponent.new(items: secondary_items(request.path, @organisation.id)) %>
@@ -10,12 +8,13 @@
<%= render partial: "organisations/headings", locals: { main: "Your housing providers", sub: nil } %>
Your organisation can submit logs for its housing providers.
<% end %>
-
<% if @total_count == 0 %>
This organisation does not currently have any housing providers.
<% end %>
-<% if current_user.data_coordinator? || current_user.support? %>
- <%= govuk_button_link_to "Add a housing provider", housing_providers_organisation_path(organisation_id: @organisation.id), html: { method: :get } %>
+<% if current_user.support? %>
+ <%= govuk_button_link_to "Add a housing provider", add_housing_provider_organisation_path(organisation_id: @organisation.id), html: { method: :get } %>
+ <% elsif current_user.data_coordinator? %>
+ <%= govuk_button_link_to "Add a housing provider", add_housing_provider_organisation_path, html: { method: :get } %>
<% end %>
<% if @total_count != 0 %>
<%= render SearchComponent.new(current_user:, search_label: "Search for a housing provider", value: @searched) %>
diff --git a/config/routes.rb b/config/routes.rb
index e703b853d..ef447b426 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -80,6 +80,7 @@ Rails.application.routes.draw do
get "logs/csv-confirmation", to: "lettings_logs#csv_confirmation"
get "schemes", to: "organisations#schemes"
get "housing-providers", to: "organisation_relationships#housing_providers"
+ get "add-housing-provider", to: "organisation_relationships#add_housing_provider"
end
end