BathHacked/energy-sparks

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

Summary

Maintainability
Test Coverage
<div class="dashboard-insights-component <%= classes %>">
  <div class="row">
    <div class="col-12">
      <h2 id="<%= id %>" class="scrollable-title"><%= t('components.dashboard_insights.title') %></h2>
    </div>
  </div>

  <div class="row">
    <%# split to 2 column view on larger screens if we are displaying alerts %>
    <div class="col-12 <%= displaying_alerts? ? 'col-lg-6' : '' %>">
      <%= component "#{audience}_reminders",
                    school: school,
                    user: user,
                    id: "#{audience}-reminders" do |c| %>
        <% c.with_title { t('components.dashboard_insights.reminders.title') } %>
      <% end %>
    </div>

    <% if displaying_alerts? %>
      <div class="col-12 col-lg-6">
        <%= component 'alerts',
                      school: school,
                      audience: audience,
                      dashboard_alerts: alerts,
                      user: user,
                      id: "#{audience}-alerts" do |c| %>
          <% c.with_title { t('advice_pages.index.alerts.title') } %>
          <% c.with_link do %>
            <%= link_to t('schools.show.view_more_alerts'), alerts_school_advice_path(school) %>
          <% end %>
          <% if any_failing_targets? %>
            <%= c.with_prompt icon: 'tachometer-alt', status: :negative do |p| %>
              <%= t('schools.show.not_meeting_target',
                    fuels: t_fuels_as_sentence(progress_summary.failing_fuel_targets)) %>
              <% p.with_link do %>
                <%= link_to t('schools.show.review_progress'), school_school_targets_path(school) %>
              <% end %>
            <% end %>
          <% end %>
          <% if any_passing_targets? %>
            <%= c.with_prompt icon: 'tachometer-alt', status: :positive do |p| %>
              <%= t('schools.show.making_progress',
                    fuels: t_fuels_as_sentence(progress_summary.passing_fuel_targets)) %>
              <% p.with_link do %>
                <%= link_to t('schools.show.review_progress'), school_school_targets_path(school) %>
              <% end %>
            <% end %>
          <% end %>
        <% end %>
      </div>
    <% end %>
  </div>
</div>