mirror of
https://github.com/we-promise/sure.git
synced 2026-04-08 06:44:52 +00:00
* Add shared sync statistics collection and provider sync summary UI - Introduced `SyncStats::Collector` concern to centralize sync statistics logic, including account, transaction, holdings, and health stats collection. - Added collapsible `ProviderSyncSummary` component for displaying sync summaries across providers. - Updated syncers (e.g., `LunchflowItem::Syncer`) to use the shared collector methods for consistent stats calculation. - Added rake tasks under `dev:sync_stats` for testing and development purposes, including fake stats generation with optional issues. - Enhanced provider-specific views to include sync summaries using the new shared component. * Refactor `ProviderSyncSummary` to improve maintainability - Extracted `severity_color_class` to simplify severity-to-CSS mapping. - Replaced `holdings_label` with `holdings_label_key` for streamlined localization. - Updated locale file to separate `found` and `processed` translations for clarity. --------- Signed-off-by: Juan José Mata <juanjo.mata@gmail.com> Co-authored-by: Josh Waldrep <joshua.waldrep5+github@gmail.com> Co-authored-by: Juan José Mata <juanjo.mata@gmail.com>
121 lines
5.3 KiB
Plaintext
121 lines
5.3 KiB
Plaintext
<%# locals: (enable_banking_item:) %>
|
|
|
|
<%= tag.div id: dom_id(enable_banking_item) do %>
|
|
<details open class="group bg-container p-4 shadow-border-xs rounded-xl">
|
|
<summary class="flex items-center justify-between gap-2 focus-visible:outline-hidden">
|
|
<div class="flex items-center gap-2">
|
|
<%= icon "chevron-right", class: "group-open:transform group-open:rotate-90" %>
|
|
|
|
<div class="flex items-center justify-center h-8 w-8 bg-success/10 rounded-full">
|
|
<% if enable_banking_item.logo.attached? %>
|
|
<%= image_tag enable_banking_item.logo, class: "rounded-full h-full w-full", loading: "lazy" %>
|
|
<% else %>
|
|
<div class="flex items-center justify-center">
|
|
<%= tag.p enable_banking_item.institution_display_name.first.upcase, class: "text-success text-xs font-medium" %>
|
|
</div>
|
|
<% end %>
|
|
</div>
|
|
|
|
<div class="pl-1 text-sm">
|
|
<div class="flex items-center gap-2">
|
|
<%= tag.p enable_banking_item.institution_display_name, class: "font-medium text-primary" %>
|
|
<% if enable_banking_item.scheduled_for_deletion? %>
|
|
<p class="text-destructive text-sm animate-pulse">Deletion in progress</p>
|
|
<% end %>
|
|
</div>
|
|
<p class="text-xs text-secondary">Enable Banking</p>
|
|
<% if enable_banking_item.syncing? %>
|
|
<div class="text-secondary flex items-center gap-1">
|
|
<%= icon "loader", size: "sm", class: "animate-spin" %>
|
|
<%= tag.span "Syncing..." %>
|
|
</div>
|
|
<% elsif enable_banking_item.requires_update? %>
|
|
<div class="text-warning flex items-center gap-1">
|
|
<%= icon "alert-triangle", size: "sm", color: "warning" %>
|
|
<%= tag.span "Reconnect" %>
|
|
</div>
|
|
<% else %>
|
|
<p class="text-secondary">
|
|
<% if enable_banking_item.last_synced_at %>
|
|
Last synced <%= time_ago_in_words(enable_banking_item.last_synced_at) %> ago
|
|
<% if enable_banking_item.sync_status_summary %>
|
|
· <%= enable_banking_item.sync_status_summary %>
|
|
<% end %>
|
|
<% else %>
|
|
Never synced
|
|
<% end %>
|
|
</p>
|
|
<% end %>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="flex items-center gap-2">
|
|
<% if enable_banking_item.requires_update? %>
|
|
<%= button_to reauthorize_enable_banking_item_path(enable_banking_item),
|
|
method: :post,
|
|
class: "inline-flex items-center gap-1 px-3 py-1.5 text-sm font-medium rounded-lg text-white bg-warning hover:opacity-90 transition-colors",
|
|
data: { turbo: false } do %>
|
|
<%= icon "refresh-cw", size: "sm" %>
|
|
Update
|
|
<% end %>
|
|
<% elsif Rails.env.development? %>
|
|
<%= icon(
|
|
"refresh-cw",
|
|
as_button: true,
|
|
href: sync_enable_banking_item_path(enable_banking_item)
|
|
) %>
|
|
<% end %>
|
|
|
|
<%= render DS::Menu.new do |menu| %>
|
|
<% menu.with_item(
|
|
variant: "button",
|
|
text: "Delete",
|
|
icon: "trash-2",
|
|
href: enable_banking_item_path(enable_banking_item),
|
|
method: :delete,
|
|
confirm: CustomConfirm.for_resource_deletion(enable_banking_item.institution_display_name, high_severity: true)
|
|
) %>
|
|
<% end %>
|
|
</div>
|
|
</summary>
|
|
|
|
<% unless enable_banking_item.scheduled_for_deletion? %>
|
|
<div class="space-y-4 mt-4">
|
|
<% if enable_banking_item.accounts.any? %>
|
|
<%= render "accounts/index/account_groups", accounts: enable_banking_item.accounts %>
|
|
<% end %>
|
|
|
|
<%# Sync summary (collapsible) - using shared ProviderSyncSummary component %>
|
|
<% stats = if defined?(@enable_banking_sync_stats_map) && @enable_banking_sync_stats_map
|
|
@enable_banking_sync_stats_map[enable_banking_item.id] || {}
|
|
else
|
|
enable_banking_item.syncs.ordered.first&.sync_stats || {}
|
|
end %>
|
|
<%= render ProviderSyncSummary.new(
|
|
stats: stats,
|
|
provider_item: enable_banking_item
|
|
) %>
|
|
|
|
<% if enable_banking_item.unlinked_accounts_count > 0 %>
|
|
<div class="p-4 flex flex-col gap-3 items-center justify-center">
|
|
<p class="text-primary font-medium text-sm">Setup needed</p>
|
|
<p class="text-secondary text-sm"><%= pluralize(enable_banking_item.unlinked_accounts_count, "account") %> imported from Enable Banking need to be set up</p>
|
|
<%= render DS::Link.new(
|
|
text: "Set up accounts",
|
|
icon: "settings",
|
|
variant: "primary",
|
|
href: setup_accounts_enable_banking_item_path(enable_banking_item),
|
|
frame: :modal
|
|
) %>
|
|
</div>
|
|
<% elsif enable_banking_item.accounts.empty? && enable_banking_item.enable_banking_accounts.empty? %>
|
|
<div class="p-4 flex flex-col gap-3 items-center justify-center">
|
|
<p class="text-primary font-medium text-sm">No accounts found</p>
|
|
<p class="text-secondary text-sm">No accounts were found from Enable Banking. Try syncing again.</p>
|
|
</div>
|
|
<% end %>
|
|
</div>
|
|
<% end %>
|
|
</details>
|
|
<% end %>
|