Sha256: 9522f73dbc47fe47372ae133a5038e2eff05ec376be60578d767cc6bb04a33c4

Contents?: true

Size: 870 Bytes

Versions: 4

Compression:

Stored size: 870 Bytes

Contents

module Workarea
  class Storefront::InventoryNotificationsController < Storefront::ApplicationController
    before_action :set_product

    def new; end

    def create
      @notification = InventoryNotification.new(notification_params)

      if @notification.save
        flash[:success] = t('workarea.storefront.inventory_notifications.flash_messages.saved')
        redirect_to storefront.product_path(@product)
      else
        flash[:error] = t('workarea.storefront.inventory_notifications.flash_messages.error')
        render :new
      end
    end

    private

      def set_product
        model = Catalog::Product.find_by(slug: params[:product_id])
        @product = Storefront::ProductViewModel.wrap(model, view_model_options)
      end

      def notification_params
        params[:notification].permit(:product_id, :sku, :email)
      end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
workarea-inventory_notifications-2.1.5 app/controllers/workarea/storefront/inventory_notifications_controller.rb
workarea-inventory_notifications-2.1.4 app/controllers/workarea/storefront/inventory_notifications_controller.rb
workarea-inventory_notifications-2.1.3 app/controllers/workarea/storefront/inventory_notifications_controller.rb
workarea-inventory_notifications-2.1.2 app/controllers/workarea/storefront/inventory_notifications_controller.rb