# frozen_string_literals: true

class ExportsController < ApplicationController
  layout "exports"

  allow_unauthenticated_access only: [ :show ]

  before_action :set_report

  def show
    @failed_success_criteria = @report.pages
                                      .map(&:elements)
                                      .flatten
                                      .map(&:success_criteria)
                                      .flatten
                                      .select(&:failed?)
    respond_to do |format|
      format.html
    end
  end

  private
  def set_report
    @report = Report.find(params[:report_id])
  end
end
