Skip to content

Commit

Permalink
Show error on invalid API key
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhilbadyal committed Dec 3, 2024
1 parent 690b4b8 commit bcf02b4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
4 changes: 4 additions & 0 deletions app/models/family.rb
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ def synth_overage?
self.class.synth_provider&.usage&.utilization.to_i >= 100
end

def synth_valid?
self.class.synth_provider&.healthy?
end

def subscribed?
stripe_subscription_status == "active"
end
Expand Down
14 changes: 10 additions & 4 deletions app/views/pages/dashboard.html.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
<div class="space-y-4">
<% if self_hosted? && Current.family&.synth_overage? %>
<div class="bg-yellow-100 border border-yellow-400 text-yellow-700 px-4 py-3 rounded relative" role="alert">
Your Synth API credit limit has been exceeded. Please visit your <a href="https://dashboard.synthfinance.com/settings" class="font-medium underline hover:text-yellow-900">Synth billing settings</a> to upgrade your plan or wait for your credits to reset.
</div>
<% if self_hosted? %>
<% if Current.family&.synth_overage? %>
<div class="bg-yellow-100 border border-yellow-400 text-yellow-700 px-4 py-3 rounded relative" role="alert">
Your Synth API credit limit has been exceeded. Please visit your <a href="https://dashboard.synthfinance.com/settings" class="font-medium underline hover:text-yellow-900">Synth billing settings</a> to upgrade your plan or wait for your credits to reset.
</div>
<% elsif !Current.family&.synth_valid? %>
<div class="bg-yellow-100 border border-yellow-400 text-yellow-700 px-4 py-3 rounded relative" role="alert">
Your Synth API Key is invalid. Please visit your <a href="https://dashboard.synthfinance.com/dashboard" class="font-medium underline hover:text-yellow-900">Synth dashboard</a> and verify that your API key is correct.
</div>
<% end %>
<% end %>
<header class="flex items-center justify-between">
<div>
Expand Down

0 comments on commit bcf02b4

Please sign in to comment.