# frozen_string_literal: true
require_dependency 'c/application_controller'

module C
  class MainApplicationController < ApplicationController
    layout 'c/main_application'
    helper C::NavigationHelper
    helper C::StorefrontHelper
    helper C::PagesHelper
    include C::PagesHelper

    before_action :check_redirects

    private

    def check_redirects
      return unless (redirect = C::Redirect.find_by(old_url: request.path))
      redirect.increment
      redirect_to redirect.new_url
    end
  end
end