mirror of
https://github.com/we-promise/sure.git
synced 2026-05-25 21:44:56 +00:00
* feat(providers): add Kraken exchange sync Adds family-scoped Kraken API-key connections, read-only balance and trade import, account setup/linking flows, provider status wiring, and focused test coverage. Closes #1758 * test(providers): avoid Kraken sample secret false positive * fix(providers): address Kraken review findings * fix(providers): address Kraken review cleanup * test(imports): stabilize transaction import ordering
116 lines
4.7 KiB
Plaintext
116 lines
4.7 KiB
Plaintext
<%# locals: (kraken_item:, unlinked_count: kraken_item.unlinked_accounts_count) %>
|
|
|
|
<%= tag.div id: dom_id(kraken_item) do %>
|
|
<details open class="group bg-container p-4 shadow-border-xs rounded-xl">
|
|
<summary 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 rounded-full bg-surface-inset">
|
|
<%= icon "waves", size: "sm", class: "text-primary" %>
|
|
</div>
|
|
|
|
<div class="pl-1 text-sm flex-1">
|
|
<div class="flex items-center gap-2">
|
|
<%= tag.p kraken_item.institution_display_name, class: "font-medium text-primary" %>
|
|
<% if kraken_item.scheduled_for_deletion? %>
|
|
<p class="text-destructive text-sm animate-pulse"><%= t(".deletion_in_progress") %></p>
|
|
<% end %>
|
|
</div>
|
|
<p class="text-xs text-secondary"><%= t(".provider_name") %></p>
|
|
|
|
<% if kraken_item.syncing? %>
|
|
<div class="text-secondary flex items-center gap-1">
|
|
<%= icon "loader", size: "sm", class: "animate-spin" %>
|
|
<%= tag.span t(".syncing") %>
|
|
</div>
|
|
<% elsif kraken_item.requires_update? %>
|
|
<div class="text-warning flex items-center gap-1">
|
|
<%= icon "alert-triangle", size: "sm", color: "warning" %>
|
|
<%= tag.span t(".reconnect") %>
|
|
</div>
|
|
<% else %>
|
|
<p class="text-secondary">
|
|
<% if kraken_item.last_synced_at %>
|
|
<% if kraken_item.sync_status_summary %>
|
|
<%= t(".status_with_summary", timestamp: time_ago_in_words(kraken_item.last_synced_at), summary: kraken_item.sync_status_summary) %>
|
|
<% else %>
|
|
<%= t(".status", timestamp: time_ago_in_words(kraken_item.last_synced_at)) %>
|
|
<% end %>
|
|
<% else %>
|
|
<%= t(".status_never") %>
|
|
<% end %>
|
|
</p>
|
|
<% end %>
|
|
</div>
|
|
</summary>
|
|
|
|
<% if Current.user&.admin? %>
|
|
<div class="flex items-center justify-end gap-2 mt-2">
|
|
<%= icon(
|
|
"refresh-cw",
|
|
as_button: true,
|
|
href: sync_kraken_item_path(kraken_item),
|
|
disabled: kraken_item.syncing?
|
|
) %>
|
|
|
|
<%= render DS::Menu.new do |menu| %>
|
|
<% if unlinked_count.to_i > 0 %>
|
|
<% menu.with_item(
|
|
variant: "link",
|
|
text: t(".import_accounts_menu"),
|
|
icon: "plus",
|
|
href: setup_accounts_kraken_item_path(kraken_item),
|
|
frame: :modal
|
|
) %>
|
|
<% end %>
|
|
<% menu.with_item(
|
|
variant: "button",
|
|
text: t(".delete"),
|
|
icon: "trash-2",
|
|
href: kraken_item_path(kraken_item),
|
|
method: :delete,
|
|
confirm: CustomConfirm.for_resource_deletion(kraken_item.institution_display_name, high_severity: true)
|
|
) %>
|
|
<% end %>
|
|
</div>
|
|
<% end %>
|
|
|
|
<% unless kraken_item.scheduled_for_deletion? %>
|
|
<div class="space-y-4 mt-4">
|
|
<% if kraken_item.accounts.any? %>
|
|
<%= render "accounts/index/account_groups", accounts: kraken_item.accounts %>
|
|
<% kraken_item.stale_rate_accounts.each do |kraken_account| %>
|
|
<div class="flex items-center gap-2 text-xs text-warning px-1">
|
|
<span class="font-mono">~</span>
|
|
<%= icon "triangle-alert", size: "sm" %>
|
|
<span><%= t(".stale_rate_warning", date: kraken_account.extra.dig("kraken", "rate_target_date")) %></span>
|
|
</div>
|
|
<% end %>
|
|
<% end %>
|
|
|
|
<% stats = kraken_item.syncs.ordered.first&.sync_stats || {} %>
|
|
<%= render ProviderSyncSummary.new(stats: stats, provider_item: kraken_item) %>
|
|
|
|
<% if unlinked_count.to_i > 0 && kraken_item.accounts.empty? %>
|
|
<div class="p-4 flex flex-col gap-3 items-center justify-center">
|
|
<p class="text-primary font-medium text-sm"><%= t(".setup_needed") %></p>
|
|
<p class="text-secondary text-sm"><%= t(".setup_description") %></p>
|
|
<%= render DS::Link.new(
|
|
text: t(".setup_action"),
|
|
icon: "plus",
|
|
variant: "primary",
|
|
href: setup_accounts_kraken_item_path(kraken_item),
|
|
frame: :modal
|
|
) %>
|
|
</div>
|
|
<% elsif kraken_item.accounts.empty? && kraken_item.kraken_accounts.none? %>
|
|
<div class="p-4 flex flex-col gap-3 items-center justify-center">
|
|
<p class="text-primary font-medium text-sm"><%= t(".no_accounts_title") %></p>
|
|
<p class="text-secondary text-sm"><%= t(".no_accounts_message") %></p>
|
|
</div>
|
|
<% end %>
|
|
</div>
|
|
<% end %>
|
|
</details>
|
|
<% end %>
|