From 167a503a1ac8b4286aef429bbeae7393b765e14e Mon Sep 17 00:00:00 2001 From: natdeanlewissoftwire Date: Mon, 19 Dec 2022 12:32:50 +0000 Subject: [PATCH] feat: add dynamic cya card titles --- ...swers_summary_list_card_component.html.erb | 7 +---- ...eck_answers_summary_list_card_component.rb | 29 +++++++++++++++++++ 2 files changed, 30 insertions(+), 6 deletions(-) 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