Skip to content

Commit

Permalink
Move newsletter subscription to backend
Browse files Browse the repository at this point in the history
  • Loading branch information
crutch committed Apr 27, 2024
1 parent a9de1eb commit 17d3d0d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
6 changes: 6 additions & 0 deletions app/controllers/notification_subscriptions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ def create
end
end

def newsletter_subscribe
email = params.permit(:email)[:email]
list_name = 'Návody.Digital'
SubscribeToNewsletterJob.perform_later(email, list_name) if email
end

def confirm
@subscriptions = NotificationSubscription.where(confirmation_token: params[:id])
@subscriptions.each do |subscription|
Expand Down
14 changes: 5 additions & 9 deletions app/views/components/_footer.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,12 @@
<strong></strong>
</p>
</div>
<form id="newsletter-form" role="form" action="https://my.sendinblue.com/users/subscribe/js_id/29wti/id/4" data-action="https://my.sendinblue.com/users/subscribeembed/js_id/29wti/id/4" method="post">
<div class="govuk-form-group sdn-footer__newsletter-form-group">
<input type="hidden" name="js_id" id="js_id" value="29wti">
<input type="hidden" name="listid" id="listid" value="45">
<input type="hidden" name="from_url" id="from_url" value="yes">
<input type="hidden" name="hdn_email_txt" id="hdn_email_txt" value="">
<input type="email" name="email" id="email-input" required class="govuk-input sdn-footer__newsletter-input" autocomplete="email" placeholder="Zadajte emailovú adresu"/>
<button type="submit" class="govuk-button sdn-footer__newsletter-button">Prihlásiť</button>
<%= form_tag newsletter_subscribe_notification_subscription_groups_path do %>
<div class='govuk-form-group sdn-footer__newsletter-form-group'>
<%= email_field_tag :email, '', class: 'govuk-input sdn-footer__newsletter-input', placeholder: 'Zadajte emailovú adresu' %>
<%= submit_tag 'Prihlásiť', class: 'govuk-button sdn-footer__newsletter-button' %>
</div>
</form>
<% end %>
<span class="sdn-footer__newsletter-disclaimer">
Prihlásením dávam dobrovoľný súhlas OZ Slovensko.Digital na zasielanie bezplatného newslettera na mnou zadaný e-mail. Tento súhlas môžem kdykoľvek odvolať na <%= mail_to ENV['DEFAULT_EMAIL_FROM'], ENV['DEFAULT_EMAIL_FROM'], class: 'sdn-footer__link' %>. Oboznámil(a) som sa s informáciami v sekcii <%= link_to 'Ochrana osobných údajov', page_path('ochrana-osobnych-udajov'), class: 'sdn-footer__link' %>.</span>
</div>
Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@
end

resources :notification_subscription_groups, controller: :notification_subscriptions, path: 'notifikacie' do
post :newsletter_subscribe, on: :collection, path: 'novinky'
get :confirm, on: :member, path: 'potvrdit'
end

Expand Down

0 comments on commit 17d3d0d

Please sign in to comment.