1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-08-07 22:45:20 +02:00

Lazy load Plaid link tokens, fix link issues on broadcast (#2302)

* Lazy load Plaid link tokens, fix link issues on broadcast

* Fix alert styles
This commit is contained in:
Zach Gollwitzer 2025-05-25 08:12:54 -04:00 committed by GitHub
parent c701755b02
commit d21e385962
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 155 additions and 123 deletions

View file

@ -0,0 +1,9 @@
<%# locals: (link_token:, region:, item_id:, is_update: false) %>
<%= tag.div data: {
controller: "plaid",
plaid_link_token_value: link_token,
plaid_region_value: region,
plaid_item_id_value: item_id,
plaid_is_update_value: is_update
} %>

View file

@ -30,7 +30,7 @@
</div>
<% elsif plaid_item.requires_update? %>
<div class="text-warning flex items-center gap-1">
<%= icon "alert-triangle", size: "sm" %>
<%= icon "alert-triangle", size: "sm", color: "warning" %>
<%= tag.span t(".requires_update") %>
</div>
<% elsif plaid_item.sync_error.present? %>
@ -48,56 +48,18 @@
<div class="flex items-center gap-2">
<% 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) %>
<%= render ButtonComponent.new(
text: t(".update"),
icon: "refresh-cw",
variant: "secondary",
data: {
controller: "plaid",
action: "plaid#open",
plaid_region_value: plaid_item.plaid_region,
plaid_link_token_value: link_token,
plaid_is_update_value: true,
plaid_item_id_value: plaid_item.id
}
) %>
<% rescue PlaidItem::PlaidConnectionLostError %>
<div class="flex flex-col gap-2">
<div class="text-warning flex items-center gap-1">
<%= icon "alert-triangle", size: "sm", color: "warning" %>
<%= tag.span t(".connection_lost") %>
</div>
<p class="text-sm text-secondary"><%= t(".connection_lost_description") %></p>
<div class="flex items-center gap-2">
<%= render ButtonComponent.new(
text: t(".delete"),
icon: "trash-2",
variant: "destructive",
href: plaid_item_path(plaid_item),
method: :delete,
confirm: CustomConfirm.for_resource_deletion(plaid_item.name, high_severity: true)
) %>
<%= render LinkComponent.new(
text: t(".add_new"),
icon: "plus",
variant: "secondary",
href: new_account_path
) %>
</div>
</div>
<% end %>
<%= render LinkComponent.new(
text: t(".update"),
icon: "refresh-cw",
variant: "secondary",
href: edit_plaid_item_path(plaid_item),
frame: "modal"
) %>
<% elsif Rails.env.development? %>
<%= icon(
"refresh-cw",
as_button: true,
href: sync_plaid_item_path(plaid_item),
disabled: plaid_item.syncing? || plaid_item.scheduled_for_deletion?
href: sync_plaid_item_path(plaid_item)
) %>
<% end %>

View file

@ -0,0 +1,8 @@
<%# We render this in the empty modal frame so if Plaid flow is closed, user stays on same page they were on %>
<%= turbo_frame_tag "modal" do %>
<%= render "plaid_items/auto_link_opener",
link_token: @link_token,
region: @plaid_item.plaid_region,
item_id: @plaid_item.id,
is_update: true %>
<% end %>

View file

@ -0,0 +1,8 @@
<%# We render this in the empty modal frame so if Plaid flow is closed, user stays on same page they were on %>
<%= turbo_frame_tag "modal" do %>
<%= render "plaid_items/auto_link_opener",
link_token: @link_token,
region: params[:region],
item_id: "",
is_update: false %>
<% end %>