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.9KB

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