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 7.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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
  15. src="{{ $institution->logo_url }}"
  16. alt="{{ $institution->name }}"
  17. class="h-10 object-contain object-left"
  18. >
  19. @endif
  20. <div class="flex-auto">
  21. <h3 class="connected-account-section-header-heading text-lg font-semibold leading-6 text-gray-950 dark:text-white">
  22. {{ $institution->name }}
  23. </h3>
  24. @if($institution->getLastImportDate())
  25. <p class="connected-account-section-header-description text-sm leading-6 text-gray-500 dark:text-gray-400">
  26. {{ __('Last updated') }} {{ $institution->getLastImportDate() }}
  27. </p>
  28. @endif
  29. </div>
  30. {{-- Refresh Transactions --}}
  31. @if($institution->getEnabledConnectedBankAccounts()->isNotEmpty())
  32. {{ ($this->refreshTransactions)(['institution' => $institution->id]) }}
  33. @endif
  34. {{-- Delete Institution --}}
  35. {{ ($this->deleteBankConnection)(['institution' => $institution->id]) }}
  36. </header>
  37. @foreach($institution->connectedBankAccounts as $connectedBankAccount)
  38. @php
  39. $account = $connectedBankAccount->bankAccount?->account;
  40. @endphp
  41. <div class="border-t-2 border-gray-200 dark:border-white/10 px-6 py-4">
  42. <div class="flex flex-col sm:flex-row items-start gap-y-2">
  43. <div class="grid flex-auto gap-y-2">
  44. <span class="account-name text-base font-medium leading-6 text-gray-900 dark:text-white">
  45. {{ $connectedBankAccount->name }}
  46. </span>
  47. <span class="account-type text-sm leading-6 text-gray-600 dark:text-gray-200">
  48. {{ ucwords($connectedBankAccount->subtype) }} {{ $connectedBankAccount->masked_number }}
  49. </span>
  50. </div>
  51. @if($account?->ending_balance)
  52. <div class="account-balance flex text-base leading-6 text-gray-700 dark:text-gray-200 space-x-1">
  53. <strong wire:poll.visible>{{ $account->ending_balance->formatted() }}</strong>
  54. <p>{{ $account->currency_code }}</p>
  55. </div>
  56. @endif
  57. </div>
  58. {{-- Add the toggle button to import transactions or not --}}
  59. <div class="mt-4">
  60. @if($connectedBankAccount->import_transactions)
  61. {{ ($this->stopImportingTransactions)(['connectedBankAccount' => $connectedBankAccount->id]) }}
  62. @else
  63. {{ ($this->startImportingTransactions)(['connectedBankAccount' => $connectedBankAccount->id]) }}
  64. @endif
  65. </div>
  66. </div>
  67. @endforeach
  68. </section>
  69. @empty
  70. <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">
  71. <div class="px-6 py-12 text-center">
  72. <div class="connected-account-empty-state-content mx-auto grid max-w-lg justify-items-center text-center">
  73. <div class="connected-account-empty-state-icon-ctn mb-4 rounded-full bg-platinum p-3 dark:bg-gray-500/20">
  74. <x-filament::icon
  75. icon="heroicon-o-x-mark"
  76. class="connected-account-empty-state-icon h-6 w-6 text-gray-500 dark:text-gray-400"
  77. />
  78. </div>
  79. <h4 class="connected-account-empty-state-heading text-base font-semibold leading-6 text-gray-950 dark:text-white">
  80. {{ __('No Connected Accounts') }}
  81. </h4>
  82. <p class="connected-account-empty-state-description text-sm text-gray-500 dark:text-gray-400 mt-1">
  83. {{ __('Connect your bank account to get started.') }}
  84. </p>
  85. <div class="connected-account-empty-state-action flex shrink-0 items-center gap-3 flex-wrap justify-center mt-6">
  86. <x-filament::button
  87. wire:click="$dispatch('createToken')"
  88. wire:loading.attr="disabled"
  89. >
  90. {{ __('Connect Account') }}
  91. </x-filament::button>
  92. </div>
  93. </div>
  94. </div>
  95. </section>
  96. @endforelse
  97. <x-filament-actions::modals/>
  98. </div>
  99. {{-- Include Plaid's JavaScript SDK CDN --}}
  100. @assets
  101. <script src="https://cdn.plaid.com/link/v2/stable/link-initialize.js"></script>
  102. @endassets
  103. {{-- Include the Plaid script --}}
  104. @script
  105. <script>
  106. {{-- Adjust the modal width based on the screen size --}}
  107. const mobileSize = window.matchMedia("(max-width: 480px)");
  108. let data = Alpine.reactive({windowWidth: 'max-w-2xl'});
  109. // Add a media query change listener
  110. mobileSize.addEventListener('change', (e) => {
  111. data.windowWidth = e.matches ? 'screen' : 'max-w-2xl';
  112. });
  113. Alpine.effect(() => {
  114. $wire.$set('modalWidth', data.windowWidth);
  115. });
  116. {{-- Initialize Plaid Link --}}
  117. $wire.on('initializeLink', token => {
  118. const handler = Plaid.create({
  119. token: token,
  120. onSuccess: (publicToken, metadata) => {
  121. $wire.dispatchSelf('linkSuccess', {publicToken: publicToken, metadata: metadata});
  122. },
  123. onExit: (err, metadata) => {
  124. },
  125. onEvent: (eventName, metadata) => {
  126. },
  127. });
  128. handler.open();
  129. });
  130. </script>
  131. @endscript
  132. </div>