BathHacked/energy-sparks

View on GitHub
app/components/comparison_overview_component/comparison_overview_component.html.erb

Summary

Maintainability
Test Coverage
<%= component 'titled_section', classes: classes do |section| %>
  <%= section.with_title do %>
    <h2 id="<%= id %>" class="scrollable-title"><%= t('components.comparison_overview.title') %></h2>
  <% end %>
  <%= section.with_intro do %>
    <p>
      <%= t('components.comparison_overview.intro',
            group_type: t("school_groups.clusters.group_type.#{school.school_group.group_type}")) %>
    </p>
  <% end %>
  <%= section.with_link do %>
    <p>
    <%= link_to t('schools.schools.compare_schools'),
                "#{compare_index_path(school_group_ids: [school.school_group.id])}#groups",
                class: 'btn btn-default' %>
    </p>
  <% end %>
  <% section.with_body do %>
    <% if can_benchmark_electricity? %>
      <h4><%= t('common.electricity') %></h4>
      <p>
        <%= t('advice_pages.electricity_long_term.insights.comparison.how_do_you_compare',
              school_type: t("common.school_types.#{school.school_type}")) %>
      </p>
      <div class="col">
        <%= component 'school_comparison',
                      id: 'electricity-comparison',
                      comparison: electricity_benchmarked_usage do |c| %>
          <% c.with_footer { advice_t('electricity_long_term.insights.comparison.callout_footer') } %>
        <% end %>
      </div>
    <% end %>

    <% if can_benchmark_gas? %>
      <h4><%= t('common.gas') %></h4>
      <p>
        <%= t('advice_pages.gas_long_term.insights.comparison.how_do_you_compare',
              school_type: t("common.school_types.#{school.school_type}")) %>
      </p>
      <div class="col">
        <%= component 'school_comparison',
                      id: 'gas-comparison',
                      comparison: gas_benchmarked_usage do |c| %>
          <% c.with_footer { advice_t('gas_long_term.insights.comparison.callout_footer') } %>
        <% end %>
      </div>
    <% end %>
  <% end %>
<% end %>