diff --git a/app/components/log_summary_component.html.erb b/app/components/lettings_log_summary_component.html.erb similarity index 66% rename from app/components/log_summary_component.html.erb rename to app/components/lettings_log_summary_component.html.erb index 87e704ae3..988417b6c 100644 --- a/app/components/log_summary_component.html.erb +++ b/app/components/lettings_log_summary_component.html.erb @@ -3,11 +3,11 @@

- <%= govuk_link_to log.lettings? ? lettings_log_path(log) : sales_log_path(log) do %> + <%= govuk_link_to lettings_log_path(log) do %> Log <%= log.id %> <% end %>

- <% if log.lettings? && (log.tenancycode? or log.propcode?) %> + <% if log.tenancycode? or log.propcode? %> <% end %> - <% if log.sales? %> - - <% end %>
- <% if log.lettings? && (log.needstype? or log.startdate?) %> + <% if log.needstype? or log.startdate? %>

<% if log.needstype? %> <%= log.is_general_needs? ? "General needs" : "Supported housing" %>
@@ -44,21 +34,6 @@ <% end %>

<% end %> - <% if log.sales? %> -

- <% if log.ownership_scheme %> - <%= case log.ownership_scheme - when "shared ownership" then "Shared ownership" - when "discounted ownership" then "Discounted ownership" - when "outright sale" then "Outright or other sale" - end %> -
- <% end %> - <% if log.saledate %> - Sale completed - <% end %> -

- <% end %> <% if current_user.support? || current_user.organisation.has_managing_agents? %>
<% if log.owning_organisation %> @@ -67,7 +42,7 @@
<% end %> - <% if log.lettings? && log.managing_organisation %> + <% if log.managing_organisation %>
Managed by
<%= log.managing_organisation&.name %>
diff --git a/app/components/lettings_log_summary_component.rb b/app/components/lettings_log_summary_component.rb new file mode 100644 index 000000000..995e53517 --- /dev/null +++ b/app/components/lettings_log_summary_component.rb @@ -0,0 +1,13 @@ +class LettingsLogSummaryComponent < ViewComponent::Base + attr_reader :current_user, :log + + def initialize(current_user:, log:) + @current_user = current_user + @log = log + super + end + + def log_status + helpers.status_tag(log.status) + end +end diff --git a/app/components/sales_log_summary_component.html.erb b/app/components/sales_log_summary_component.html.erb new file mode 100644 index 000000000..e78659863 --- /dev/null +++ b/app/components/sales_log_summary_component.html.erb @@ -0,0 +1,55 @@ +
+
+
+
+

+ <%= govuk_link_to sales_log_path(log) do %> + Log <%= log.id %> + <% end %> +

+ +
+

+ <% if log.ownership_scheme %> + <%= case log.ownership_scheme + when "shared ownership" then "Shared ownership" + when "discounted ownership" then "Discounted ownership" + when "outright sale" then "Outright or other sale" + end %> +
+ <% end %> + <% if log.saledate %> + Sale completed + <% end %> +

+ <% if current_user.support? || current_user.organisation.has_managing_agents? %> + + <% end %> +
+ +
+
diff --git a/app/components/log_summary_component.rb b/app/components/sales_log_summary_component.rb similarity index 79% rename from app/components/log_summary_component.rb rename to app/components/sales_log_summary_component.rb index bbd504e5d..07249ea6f 100644 --- a/app/components/log_summary_component.rb +++ b/app/components/sales_log_summary_component.rb @@ -1,4 +1,4 @@ -class LogSummaryComponent < ViewComponent::Base +class SalesLogSummaryComponent < ViewComponent::Base attr_reader :current_user, :log def initialize(current_user:, log:) diff --git a/app/views/logs/_log_list.html.erb b/app/views/logs/_log_list.html.erb index df19856e3..95cbcd83d 100644 --- a/app/views/logs/_log_list.html.erb +++ b/app/views/logs/_log_list.html.erb @@ -17,5 +17,9 @@
<% logs.map do |log| %> - <%= render(LogSummaryComponent.new(current_user:, log:)) %> + <% if log.sales? %> + <%= render(SalesLogSummaryComponent.new(current_user:, log:)) %> + <% else %> + <%= render(LettingsLogSummaryComponent.new(current_user:, log:)) %> + <% end %> <% end %> diff --git a/spec/components/log_summary_component_spec.rb b/spec/components/lettings_log_summary_component_spec.rb similarity index 97% rename from spec/components/log_summary_component_spec.rb rename to spec/components/lettings_log_summary_component_spec.rb index 373e5b211..31533ab29 100644 --- a/spec/components/log_summary_component_spec.rb +++ b/spec/components/lettings_log_summary_component_spec.rb @@ -1,6 +1,6 @@ require "rails_helper" -RSpec.describe LogSummaryComponent, type: :component do +RSpec.describe LettingsLogSummaryComponent, type: :component do let(:support_user) { FactoryBot.create(:user, :support) } let(:coordinator_user) { FactoryBot.create(:user) } let(:propcode) { "P3647" }