Sha256: 0a099a8cabbb8be3c0465119936bb3e4a096877914d833905891cb1077632611

Contents?: true

Size: 826 Bytes

Versions: 4

Compression:

Stored size: 826 Bytes

Contents

module Workarea
  module Api
    module Storefront
      class SearchesController < Api::Storefront::ApplicationController
        before_action :cache_page

        def index
          search_query = QueryString.new(params[:q]).sanitized

          render(nothing: true) && (return) if search_query.blank?
          autocomplete_params = params.permit(:q)
          search = Search::SearchSuggestions.new(autocomplete_params)

          @results = search.results.map do |result|
            SearchSuggestionViewModel.new(result).to_h
          end
        end

        def show
          response = Search::StorefrontSearch.new(params.to_unsafe_h).response
          @search = Workarea::Storefront::SearchViewModel.new(
            response,
            view_model_options
          )
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
workarea-api-4.4.7 storefront/app/controllers/workarea/api/storefront/searches_controller.rb
workarea-api-storefront-4.4.7 app/controllers/workarea/api/storefront/searches_controller.rb
workarea-api-4.4.6 storefront/app/controllers/workarea/api/storefront/searches_controller.rb
workarea-api-storefront-4.4.6 app/controllers/workarea/api/storefront/searches_controller.rb