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
19 changed files with 155 additions and 123 deletions

View File

@@ -6,16 +6,20 @@ export default class extends Controller {
linkToken: String,
region: { type: String, default: "us" },
isUpdate: { type: Boolean, default: false },
itemId: String
itemId: String,
};
connect() {
this.open();
}
open() {
const handler = Plaid.create({
token: this.linkTokenValue,
onSuccess: this.handleSuccess,
onLoad: this.handleLoad,
onExit: this.handleExit,
onEvent: this.handleEvent
onEvent: this.handleEvent,
});
handler.open();
@@ -27,10 +31,10 @@ export default class extends Controller {
fetch(`/plaid_items/${this.itemIdValue}/sync`, {
method: "POST",
headers: {
"Accept": "application/json",
Accept: "application/json",
"Content-Type": "application/json",
"X-CSRF-Token": document.querySelector('[name="csrf-token"]').content,
}
},
}).then(() => {
// Refresh the page to show the updated status
window.location.href = "/accounts";