You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

list-institutions.blade.php 6.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <div>
  2. <div class="grid grid-cols-1 gap-4">
  3. @forelse($this->connectedInstitutions as $institution)
  4. <section class="connected-account-section overflow-hidden rounded-xl bg-white shadow-sm ring-1 ring-gray-950/5 dark:bg-gray-900 dark:ring-white/10">
  5. <header class="connected-account-header bg-primary-300/10 px-6 py-4 flex flex-col sm:flex-row sm:items-center gap-3">
  6. @if($institution->logo_url === null)
  7. <div class="flex-shrink-0 bg-platinum p-2 rounded-full dark:bg-gray-500/20">
  8. <x-filament::icon
  9. icon="heroicon-o-building-library"
  10. class="h-6 w-6 text-gray-500 dark:text-gray-400"
  11. />
  12. </div>
  13. @else
  14. <img src="{{ $institution->logo_url }}" alt="{{ $institution->name }}" class="h-10 object-contain object-left">
  15. @endif
  16. <div class="flex-auto">
  17. <h3 class="connected-account-section-header-heading text-lg font-semibold leading-6 text-gray-950 dark:text-white">
  18. {{ $institution->name }}
  19. </h3>
  20. {{-- Eventually we will need to assert last updated time based on when the last time one of the accounts for the institution last has transactions imported --}}
  21. <p class="connected-account-section-header-description text-sm leading-6 text-gray-500 dark:text-gray-400">
  22. {{ __('Last Updated') }} {{ $institution->updated_at->diffForHumans() }}
  23. </p>
  24. </div>
  25. {{ ($this->deleteBankConnection)(['institution' => $institution->id]) }}
  26. </header>
  27. @foreach($institution->connectedBankAccounts as $connectedBankAccount)
  28. <div class="border-t-2 border-gray-200 dark:border-white/10 px-6 py-4">
  29. <div class="flex flex-col sm:flex-row items-start gap-y-2">
  30. <div class="grid flex-auto gap-y-2">
  31. <span class="account-name text-base font-medium leading-6 text-gray-900 dark:text-white">{{ $connectedBankAccount->name }}</span>
  32. <span class="account-type text-sm leading-6 text-gray-600 dark:text-gray-200">{{ ucwords($connectedBankAccount->subtype) }} {{ $connectedBankAccount->masked_number }}</span>
  33. </div>
  34. @if($connectedBankAccount->bankAccount?->account)
  35. <div class="account-balance flex text-base leading-6 text-gray-700 dark:text-gray-200 space-x-1">
  36. <strong>{{ $this->getAccountBalance($connectedBankAccount->bankAccount->account) }}</strong>
  37. <p>{{ $connectedBankAccount->bankAccount->account->currency_code }}</p>
  38. </div>
  39. @endif
  40. </div>
  41. {{-- Add the toggle button to import transactions or not --}}
  42. <div class="mt-4">
  43. @if($connectedBankAccount->import_transactions)
  44. {{ ($this->stopImportingTransactions)(['connectedBankAccount' => $connectedBankAccount->id]) }}
  45. @else
  46. {{ ($this->startImportingTransactions)(['connectedBankAccount' => $connectedBankAccount->id]) }}
  47. @endif
  48. </div>
  49. </div>
  50. @endforeach
  51. </section>
  52. @empty
  53. <section class="connected-account-section overflow-hidden rounded-xl bg-white shadow-sm ring-1 ring-gray-950/5 dark:bg-gray-900 dark:ring-white/10">
  54. <div class="px-6 py-12 text-center">
  55. <div class="connected-account-empty-state-content mx-auto grid max-w-lg justify-items-center text-center">
  56. <div class="connected-account-empty-state-icon-ctn mb-4 rounded-full bg-platinum p-3 dark:bg-gray-500/20">
  57. <x-filament::icon
  58. icon="heroicon-o-x-mark"
  59. class="connected-account-empty-state-icon h-6 w-6 text-gray-500 dark:text-gray-400"
  60. />
  61. </div>
  62. <h4 class="connected-account-empty-state-heading text-base font-semibold leading-6 text-gray-950 dark:text-white">
  63. {{ __('No Connected Accounts') }}
  64. </h4>
  65. <p class="connected-account-empty-state-description text-sm text-gray-500 dark:text-gray-400 mt-1">
  66. {{ __('Connect your bank account to get started.') }}
  67. </p>
  68. <div class="connected-account-empty-state-action flex shrink-0 items-center gap-3 flex-wrap justify-center mt-6">
  69. <x-filament::button
  70. wire:click="$dispatch('createToken')"
  71. wire:loading.attr="disabled"
  72. >
  73. {{ __('Connect Account') }}
  74. </x-filament::button>
  75. </div>
  76. </div>
  77. </div>
  78. </section>
  79. @endforelse
  80. <x-filament-actions::modals />
  81. </div>
  82. {{-- Include Plaid's JavaScript SDK --}}
  83. @assets
  84. <script src="https://cdn.plaid.com/link/v2/stable/link-initialize.js"></script>
  85. @endassets
  86. {{-- Initialize Plaid Link --}}
  87. @script
  88. <script>
  89. let data = Alpine.reactive({ windowWidth: 'max-w-2xl' });
  90. Alpine.effect(() => {
  91. $wire.$set('modalWidth', data.windowWidth);
  92. });
  93. window.addEventListener('resize', () => {
  94. data.windowWidth = window.innerWidth <= 480 ? 'screen' : 'max-w-2xl';
  95. });
  96. $wire.on('initializeLink', token => {
  97. const handler = Plaid.create({
  98. token: token,
  99. onSuccess: (publicToken, metadata) => {
  100. $wire.dispatchSelf('linkSuccess', {publicToken: publicToken, metadata: metadata});
  101. },
  102. onExit: (err, metadata) => {},
  103. onEvent: (eventName, metadata) => {},
  104. });
  105. handler.open();
  106. });
  107. </script>
  108. @endscript
  109. </div>