<%= form_with model: @organisation_relationship, url: managing_agents_organisation_path, method: "post", local: true do |f| %>
<% if current_user.support? %>
<%= render partial: "organisations/headings", locals: { main: @organisation.name, sub: nil } %>
<%= render SubNavigationComponent.new(items: secondary_items(request.path, @organisation.id)) %>
<h2 class="govuk-visually-hidden">Add Managing Agent</h2>
<%= govuk_back_link(href: :back) %>
<%= render partial: "organisations/headings", locals: { main: "What is the name of this organisation's managing agent?", sub: nil } %>
<p class="govuk-body">Start typing to search for a managing agent</p>
<% else %>
<% content_for :before_content do %>
<%= govuk_back_link(href: :back) %>
<% end %>
<%= render partial: "organisations/headings", locals: { main: "What is the name of your managing agent?", sub: nil } %>
<p class="govuk-body">Start typing to search for your managing agent</p>
<% end %>
<% answer_options = { "" => "Select an option" } %>
<% @organisations.each do |organisation| %>
<% answer_options[organisation[0]] = organisation[1] %>
<% end %>
<%= render partial: "organisation_relationships/related_organisation_select_question", locals: {
field: :child_organisation_id,
label: { hidden: true },
question: Form::Question.new("", { "answer_options" => answer_options }, nil),
f:,
} %>
<div class="govuk-button-group govuk-!-margin-bottom-6">
<%= f.govuk_submit "Add" %>
<%= govuk_button_link_to("Cancel", managing_agents_organisation_path(@organisation), secondary: true) %>
</div>
<%= govuk_details(summary_text: "Can't find the managing agent you're looking for?") do %>
<%= govuk_list [
"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 MHCLG service desk', GlobalConstants::HELPDESK_URL, rel: 'noreferrer noopener', target: '_blank')}",
], type: :bullet %>
<% end %>
<% end %>