diff --git a/app/controllers/newsletters_controller.rb b/app/controllers/newsletters_controller.rb new file mode 100644 index 00000000..37cc8645 --- /dev/null +++ b/app/controllers/newsletters_controller.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +class NewslettersController < ApplicationController + def show; end + + def update + Faraday.post(Docuseal::NEWSLETTER_URL, newsletter_params.to_json, 'Content-Type' => 'application/json') + rescue StandardError => e + Rails.logger.error(e) + ensure + redirect_to root_path + end + + private + + def newsletter_params + params.require(:user).permit(:email) + end +end diff --git a/app/controllers/setup_controller.rb b/app/controllers/setup_controller.rb index 83bb3788..2b42cc9d 100644 --- a/app/controllers/setup_controller.rb +++ b/app/controllers/setup_controller.rb @@ -30,7 +30,7 @@ class SetupController < ApplicationController sign_in(@user) - redirect_to root_path + redirect_to newsletter_path else render :index, status: :unprocessable_entity end diff --git a/app/views/newsletters/show.html.erb b/app/views/newsletters/show.html.erb new file mode 100644 index 00000000..da3730e5 --- /dev/null +++ b/app/views/newsletters/show.html.erb @@ -0,0 +1,14 @@ +