Sha256: 82674db30ddccbe2786c72d3d9e0d1cd59568bd46ed22cdd57251327f5cc17ac

Contents?: true

Size: 932 Bytes

Versions: 3

Compression:

Stored size: 932 Bytes

Contents

module Workarea
  module Storefront
    class SharesController < Storefront::ApplicationController
      before_action :find_share

      def new
      end

      def create
        if verify_recaptcha(model: @share, env: Rails.env) && @share.save
          flash[:success] = t(
            'workarea.storefront.flash_messages.share_message_sent',
            recipient: @share.friendly_to
          )
          ShareMailer.share(@share.id.to_s).deliver_later
          redirect_to @share.url
        else
          render :new
        end
      end

      private

      def find_share
        model = Email::Share.new(share_params)
        @share = ShareViewModel.wrap(model, view_model_options)
      end

      def share_params
        params.permit(
          :url,
          :title,
          :to_email,
          :to_name,
          :from_email,
          :from_name,
          :message
        )
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
workarea-share-1.3.1 app/controllers/workarea/storefront/shares_controller.rb
workarea-share-1.3.0 app/controllers/workarea/storefront/shares_controller.rb
workarea-share-1.2.4 app/controllers/workarea/storefront/shares_controller.rb