1import { Controller } from '@hotwired/stimulus'; 2 3export default class extends Controller { 4 initialize() { 5 this.data.set('clicked', 'false'); 6 } 7 8 updateBankAccount(event) { 9 event.preventDefault(); 10 const currentTarget = event.currentTarget; 11 const originalTextContent = currentTarget.textContent; 12 if (this.data.get('clicked') === 'false') { 13 currentTarget.textContent = 'Connecting to Stripe express...'; 14 if (currentTarget.dataset.hurrIos == 'true') this.replaceStripeDashboardButton(currentTarget); 15 this.redirectToStripeExpressDashboard(event, originalTextContent); 16 } 17 } 18 19 redirectToStripeExpressDashboard(event, originalTextContent) { 20 const currentTarget = event.currentTarget; 21 const thisController = this; 22 this.data.set('clicked', 'true'); 23 Rails.ajax({ 24 type: 'get', 25 url: `${event.currentTarget.dataset.updateBankUrl}`, 26 dataType: 'json', 27 success: (data) => { 28 if (data.stripe_connect_url) { 29 currentTarget.textContent = 'Redirecting to Stripe express...'; 30 setTimeout(function () { 31 $(thisController.element).modal('hide'); 32 setTimeout(function () { 33 Turbo.visit(data.stripe_connect_url); 34 if (currentTarget.dataset.hurrIos == 'true') { 35 currentTarget.textContent = originalTextContent; 36 thisController.replaceStripeDashboardButton(currentTarget); 37 } 38 }, 2000); 39 }, 1000); 40 } 41 }, 42 error: () => { 43 setTimeout(function () { 44 currentTarget.textContent = 'Update my bank account'; 45 thisController.data.set('clicked', 'false'); 46 toastr.error("<span>Can't Connect to Stripe Right now.</span>"); 47 }, 100); 48 }, 49 }); 50 } 51 52 replaceStripeDashboardButton(currentTarget) { 53 if (currentTarget.dataset.userDashboardStripeButton) { 54 if (currentTarget.textContent != 'View Payouts Breakdown') { 55 currentTarget.parentNode.classList.add('col-9', 'ml-3'); 56 currentTarget.parentNode.classList.remove('col-8', 'text-right'); 57 } else { 58 currentTarget.parentNode.classList.remove('col-9', 'ml-3'); 59 currentTarget.parentNode.classList.add('col-8', 'text-right'); 60 } 61 } 62 } 63};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.