<% content_for :title, "#{subsection.id.humanize} - Check your answers" %>
<% content_for :breadcrumbs, govuk_breadcrumbs(breadcrumbs: {
"Logs" => url_for(@log.class),
"Log #{@log.id}" => url_for(@log),
subsection.label => "",
}) %>
<div class="govuk-grid-row">
<div class="govuk-grid-column-three-quarters-from-desktop">
<h1 class="govuk-heading-l">
<span class="govuk-caption-l"><%= subsection.label %></span>
Check your answers
</h1>
<% if subsection.id == "setup" && subsection.status(@log) == :completed %>
<%= govuk_inset_text(text: "Changing these answers might remove answers you’ve already given in other sections.") %>
<% end %>
<%= display_answered_questions_summary(subsection, @log, current_user) %>
<% if any_questions_have_summary_card_number?(subsection, @log) %>
<% subsection.applicable_questions(@log).group_by(&:check_answers_card_number).values.each do |question_group| %>
<%= render CheckAnswersSummaryListCardComponent.new(questions: question_group, log: @log, user: current_user) %>
<% end %>
<% else %>
<%= render partial: "form/check_answers_summary_list", locals: {
subsection:,
lettings_log: @log,
questions: total_applicable_questions(subsection, @log, current_user),
referrer: "check_answers",
} %>
<% end %>
<% if @log.id.nil? %>
<% if @log.lettings? %>
<%= govuk_button_link_to "Return to log", sales_log_path(id: "new"), class: "govuk-!-margin-right-6" %>
<% else %>
<%= govuk_button_link_to "Return to log", lettings_log_path(id: "new"), class: "govuk-!-margin-right-6" %>
<% end %>
<% else %>
<%= form_with model: @log, method: "get" do |f| %>
<%= f.govuk_submit "Save and return to log" do %>
<% next_incomplete_section_redirect_path = @log.form.next_incomplete_section_redirect_path(subsection, @log) %>
<% if @log.status == "in_progress" && next_incomplete_section_redirect_path != "error" %>
<%= govuk_button_link_to "Save and go to next incomplete section", send(next_incomplete_section_path(@log, next_incomplete_section_redirect_path), @log), secondary: true %>
<% end %>
<% end %>
<% end %>
<% end %>
</div>
</div>