diff --git a/app/components/check_answers_summary_list_card_component.html.erb b/app/components/check_answers_summary_list_card_component.html.erb index d04283939..0005ed790 100644 --- a/app/components/check_answers_summary_list_card_component.html.erb +++ b/app/components/check_answers_summary_list_card_component.html.erb @@ -2,12 +2,7 @@
<% if applicable_questions.first.check_answers_card_number != 0 && applicable_questions.first.check_answers_card_number.present? %>
- <% if applicable_questions.first.check_answers_card_number == 1 %> -

Lead tenant

- <% end %> - <% if applicable_questions.first.check_answers_card_number > 1 %> -

Person <%= applicable_questions.first.check_answers_card_number %>

- <% end %> +

<%= check_answers_card_title(applicable_questions.first) %>

<% end %>
diff --git a/app/components/check_answers_summary_list_card_component.rb b/app/components/check_answers_summary_list_card_component.rb index de7fe9685..acfe301de 100644 --- a/app/components/check_answers_summary_list_card_component.rb +++ b/app/components/check_answers_summary_list_card_component.rb @@ -15,4 +15,33 @@ class CheckAnswersSummaryListCardComponent < ViewComponent::Base def get_answer_label(question) question.answer_label(log).presence || "You didn’t answer this question".html_safe end + + def check_answers_card_title(question) + case question.form.type + when "lettings" + case question.check_answers_card_number + when 1 + "Lead tenant" + when 2..8 + "Person #{question.check_answers_card_number}" + end + when "sales" + case log[:jointpur] + when 1 + case question.check_answers_card_number + when 1..2 + "Buyer #{question.check_answers_card_number}" + when 3..6 + "Person #{question.check_answers_card_number - 2}" + end + when 2 + case question.check_answers_card_number + when 1 + "Buyer #{question.check_answers_card_number}" + when 2..5 + "Person #{question.check_answers_card_number - 1}" + end + end + end + end end