diff --git a/app/assets/stylesheets/application.tailwind.css b/app/assets/stylesheets/application.tailwind.css index d78b8f31..1dd427e8 100644 --- a/app/assets/stylesheets/application.tailwind.css +++ b/app/assets/stylesheets/application.tailwind.css @@ -102,6 +102,10 @@ .btn--primary { @apply bg-gray-900 text-white hover:bg-gray-700; } + + .btn--light { + @apply bg-gray-25 border border-alpha-black-200 text-gray-900 hover:bg-gray-50; + } } /* Small, single purpose classes that should take precedence over other styles */ diff --git a/app/controllers/institutions_controller.rb b/app/controllers/institutions_controller.rb index d87d551e..ba5f719d 100644 --- a/app/controllers/institutions_controller.rb +++ b/app/controllers/institutions_controller.rb @@ -23,6 +23,11 @@ class InstitutionsController < ApplicationController redirect_to accounts_path, notice: t(".success") end + def sync + @institution.sync + redirect_back_or_to accounts_path, notice: t(".success") + end + private def institution_params diff --git a/app/models/institution.rb b/app/models/institution.rb index 3d9f13db..d34ecd0e 100644 --- a/app/models/institution.rb +++ b/app/models/institution.rb @@ -4,4 +4,22 @@ class Institution < ApplicationRecord has_one_attached :logo scope :alphabetically, -> { order(name: :asc) } + + def sync + accounts.active.each do |account| + if account.needs_sync? + account.sync + end + end + + update! last_synced_at: Time.now + end + + def syncing? + accounts.active.any? { |account| account.syncing? } + end + + def has_issues? + accounts.active.any? { |account| account.has_issues? } + end end diff --git a/app/views/accounts/_account.html.erb b/app/views/accounts/_account.html.erb index 8a343360..e8627e69 100644 --- a/app/views/accounts/_account.html.erb +++ b/app/views/accounts/_account.html.erb @@ -4,7 +4,17 @@
<%= institution.last_synced_at ? t(".status", last_synced_at: time_ago_in_words(institution.last_synced_at)) : t(".status_never") %>
+ <% end %> +<%= t(".new_account") %>
<% end %> - - <%= render "sync_all_button" %>