class Admin::Settings::SchoolBrandingsController < Admin::Controller
  def show
    render_success :ok, json: branding_props(branding)
  end

  def update
    if branding.update(branding_params)
      render_success :ok
    else
      render_error :unprocessable_entity, errors: branding
    end
  end

  private
    def branding
      @branding ||= current_school.find_or_build_school_branding
    end

    def branding_params
      params.permit(:color)
    end

    def branding_props(branding)
      {
        color: branding.decorate.format_color
      }
    end
end
