Skip to content

Commit

Permalink
Closes #14
Browse files Browse the repository at this point in the history
  • Loading branch information
dngst committed Feb 15, 2024
1 parent f5a19e8 commit 448703c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
6 changes: 6 additions & 0 deletions app/controllers/subscriptions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
class SubscriptionsController < ApplicationController
include RequireAdmin

rescue_from SocketError, with: :handle_offline

before_action :require_admin
before_action :authenticate_user!
before_action :initialize_paystack_service
Expand Down Expand Up @@ -69,4 +71,8 @@ def manage_subscription
def initialize_paystack_service
@paystack_service = PaystackService.new(ENV.fetch('PAYSTACK_SECRET_KEY', nil))
end

def handle_offline
redirect_to user_path(current_user), alert: t('subscriptions.offline')
end
end
2 changes: 1 addition & 1 deletion app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<%= render "layouts/confirm_modal" %>

<main class="flex flex-col mx-auto container <%= 'mt-24' if !@home_page %> px-5 h-screen container">
<div class="flash" data-turbo-temporary>
<div class="flash">
<%= render "layouts/flash" %>
</div>

Expand Down
1 change: 1 addition & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ en:
failed: 'Subscription unsuccessful'
failed_to_initialize: 'Failed to initialize transaction'
failed_verification: 'Transaction verification unsuccessful'
offline: "You're offline. Failed to connect to Paystack"
users:
saved:
updated: 'Tenant updated'
Expand Down

0 comments on commit 448703c

Please sign in to comment.