mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-05 05:25:24 +02:00
Enhance Plaid connection management with re-authentication and error handling (#1854)
* Enhance Plaid connection management with re-authentication and error handling - Add support for Plaid item status tracking (good/requires_update) - Implement re-authentication flow for Plaid connections - Handle connection errors and provide user-friendly reconnection options - Update Plaid link token generation to support item updates - Add localization for new connection management states * Remove redundant 'reconnect' localization for Plaid items
This commit is contained in:
parent
08a2d35308
commit
f1f2e103ce
11 changed files with 156 additions and 19 deletions
|
@ -28,6 +28,11 @@
|
|||
<%= lucide_icon "loader", class: "w-4 h-4 animate-pulse" %>
|
||||
<%= tag.span t(".syncing") %>
|
||||
</div>
|
||||
<% elsif plaid_item.requires_update? %>
|
||||
<div class="text-amber-500 flex items-center gap-1">
|
||||
<%= lucide_icon "alert-triangle", class: "w-4 h-4" %>
|
||||
<%= tag.span t(".requires_update") %>
|
||||
</div>
|
||||
<% elsif plaid_item.sync_error.present? %>
|
||||
<div class="text-gray-500 flex items-center gap-1">
|
||||
<%= lucide_icon "alert-circle", class: "w-4 h-4 text-red-500" %>
|
||||
|
@ -42,8 +47,53 @@
|
|||
</div>
|
||||
|
||||
<div class="flex items-center gap-2">
|
||||
<%= button_to sync_plaid_item_path(plaid_item), disabled: plaid_item.syncing? || plaid_item.scheduled_for_deletion?, class: "disabled:text-gray-400 text-gray-900 flex hover:text-gray-800 items-center text-sm font-medium hover:underline" do %>
|
||||
<%= lucide_icon "refresh-cw", class: "w-4 h-4" %>
|
||||
<% if plaid_item.requires_update? %>
|
||||
<% begin %>
|
||||
<% link_token = plaid_item.get_update_link_token(webhooks_url: plaid_webhooks_url(plaid_item.plaid_region), redirect_url: accounts_url) %>
|
||||
<button
|
||||
data-controller="plaid"
|
||||
data-action="plaid#open"
|
||||
data-plaid-region-value="<%= plaid_item.plaid_region %>"
|
||||
data-plaid-link-token-value="<%= link_token %>"
|
||||
data-plaid-is-update-value="true"
|
||||
data-plaid-item-id-value="<%= plaid_item.id %>"
|
||||
class="btn btn--secondary flex items-center gap-2"
|
||||
>
|
||||
<%= lucide_icon "refresh-cw", class: "w-4 h-4" %>
|
||||
<%= tag.span t(".update") %>
|
||||
</button>
|
||||
<% rescue PlaidItem::PlaidConnectionLostError %>
|
||||
<div class="flex flex-col gap-2">
|
||||
<div class="text-amber-500 flex items-center gap-1">
|
||||
<%= lucide_icon "alert-triangle", class: "w-4 h-4" %>
|
||||
<%= tag.span t(".connection_lost") %>
|
||||
</div>
|
||||
<p class="text-sm text-gray-500"><%= t(".connection_lost_description") %></p>
|
||||
<div class="flex items-center gap-2">
|
||||
<%= button_to plaid_item_path(plaid_item),
|
||||
method: :delete,
|
||||
class: "btn btn--danger flex items-center gap-2",
|
||||
data: {
|
||||
turbo_confirm: {
|
||||
title: t(".confirm_title"),
|
||||
body: t(".confirm_body"),
|
||||
accept: t(".confirm_accept")
|
||||
}
|
||||
} do %>
|
||||
<%= lucide_icon "trash-2", class: "w-4 h-4" %>
|
||||
<%= tag.span t(".delete") %>
|
||||
<% end %>
|
||||
<%= link_to new_account_path, class: "btn btn--secondary flex items-center gap-2" do %>
|
||||
<%= lucide_icon "plus", class: "w-4 h-4" %>
|
||||
<%= tag.span t(".add_new") %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<%= button_to sync_plaid_item_path(plaid_item), disabled: plaid_item.syncing? || plaid_item.scheduled_for_deletion?, class: "disabled:text-gray-400 text-gray-900 flex hover:text-gray-800 items-center text-sm font-medium hover:underline" do %>
|
||||
<%= lucide_icon "refresh-cw", class: "w-4 h-4" %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<%= contextual_menu do %>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue