mirror of
https://github.com/we-promise/sure.git
synced 2026-05-27 14:34:56 +00:00
* feat(sync): add Brex provider schema Adds Brex item and account tables with per-family credentials, scoped upstream account uniqueness, encrypted token storage, and sanitized provider payload columns. * feat(sync): add Brex provider core Adds Brex item/account models, provider client and adapter support, family connection helpers, and provider enum registration for read-only Brex cash and card data. * feat(sync): add Brex import pipeline Adds Brex account discovery, linked-account sync, cash/card balance processors, transaction import, sanitized metadata handling, and idempotent provider entry processing. * feat(sync): add Brex connection flows Adds Mercury-style Brex connection management, explicit item-scoped account selection and linking, settings provider UI, account index visibility, localized copy, and per-item cache handling. * test(sync): cover Brex provider workflows Adds targeted coverage for Brex provider requests, adapter config, item/account guards, importer behavior, entry processing, and Mercury-style controller flows. * fix(sync): align Brex API edge cases Tightens Brex account fetching against the official card-account response shape, sends transaction start filters as RFC3339 date-times, and keeps provider error bodies out of user-facing messages while expanding provider client guard coverage. * fix(sync): harden Brex provider integration Restrict Brex API base URLs to official hosts, tighten account-selection UI behavior, and add tests for invalid credentials, cache scoping, and provider setup edge cases. * test(sync): avoid Brex secret-shaped fixtures * refactor(sync): extract Brex account flows * fix(sync): address Brex provider review feedback * fix(sync): address Brex review follow-ups Move remaining Brex review cleanup into focused model behavior, tighten link/setup edge cases, localize summaries, and add regression coverage from CodeRabbit feedback. Also records the security-review pass as no-findings after diff-scoped inspection and Brakeman validation. * refactor(sync): split Brex account flow controllers Route Brex account selection and setup actions through small namespaced controllers while keeping existing URLs and helpers stable. Business flow remains in BrexItem::AccountFlow; the main Brex item controller now only handles connection CRUD, provider-panel rendering, destroy, and sync. * fix(sync): address Brex CodeRabbit review * fix(sync): address Brex follow-up review * fix(sync): address Brex review follow-ups * fix(sync): address Brex sync review findings * fix(sync): polish Brex review copy and errors * fix(sync): register Brex provider health * fix(sync): polish Brex bank sync presentation * fix(sync): address Brex review follow-ups * fix(sync): tighten Brex setup params * test(api): stabilize usage rate-limit window * fix(sync): polish Brex setup flow nits * fix(sync): harden Brex setup params * fix(sync): finalize Brex review cleanup --------- Signed-off-by: Juan José Mata <juanjo.mata@gmail.com> Co-authored-by: Juan José Mata <juanjo.mata@gmail.com>
107 lines
4.6 KiB
Plaintext
107 lines
4.6 KiB
Plaintext
<% content_for :title, t(".title") %>
|
|
|
|
<%= render DS::Dialog.new do |dialog| %>
|
|
<% dialog.with_header(title: t(".title")) do %>
|
|
<div class="flex items-center gap-2">
|
|
<%= icon "building-2", class: "text-primary" %>
|
|
<span class="text-primary"><%= t(".subtitle") %></span>
|
|
</div>
|
|
<% end %>
|
|
|
|
<% dialog.with_body do %>
|
|
<%= form_with url: complete_account_setup_brex_item_path(@brex_item),
|
|
method: :post,
|
|
local: true,
|
|
data: {
|
|
controller: "loading-button",
|
|
action: "submit->loading-button#showLoading",
|
|
loading_button_loading_text_value: t(".creating_accounts"),
|
|
turbo_frame: "_top"
|
|
},
|
|
class: "space-y-6" do |form| %>
|
|
|
|
<div class="space-y-4">
|
|
<% if @api_error.present? %>
|
|
<div class="p-8 flex flex-col gap-3 items-center justify-center text-center">
|
|
<%= icon "alert-circle", size: "lg", class: "text-destructive" %>
|
|
<p class="text-primary font-medium"><%= t(".fetch_failed") %></p>
|
|
<p class="text-destructive text-sm"><%= @api_error %></p>
|
|
</div>
|
|
<% elsif @brex_accounts.empty? %>
|
|
<div class="p-8 flex flex-col gap-3 items-center justify-center text-center">
|
|
<%= icon "check-circle", size: "lg", class: "text-success" %>
|
|
<p class="text-primary font-medium"><%= t(".no_accounts_to_setup") %></p>
|
|
<p class="text-secondary text-sm"><%= t(".all_accounts_linked") %></p>
|
|
</div>
|
|
<% else %>
|
|
<div class="bg-surface border border-primary p-4 rounded-lg">
|
|
<div class="flex items-start gap-3">
|
|
<%= icon "info", size: "sm", class: "text-primary mt-0.5 flex-shrink-0" %>
|
|
<div>
|
|
<p class="text-sm text-primary mb-2">
|
|
<strong><%= t(".choose_account_type") %></strong>
|
|
</p>
|
|
<ul class="text-xs text-secondary space-y-1 list-disc list-inside">
|
|
<% @displayable_account_type_options.each do |label, type| %>
|
|
<li><strong><%= label %></strong></li>
|
|
<% end %>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<% @brex_accounts.each do |brex_account| %>
|
|
<div class="border border-primary rounded-lg p-4">
|
|
<div class="flex items-center justify-between mb-3">
|
|
<div>
|
|
<h3 class="font-medium text-primary">
|
|
<%= brex_account.name %>
|
|
</h3>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="space-y-3" data-controller="account-type-selector" data-account-type-selector-account-id-value="<%= brex_account.id %>">
|
|
<div>
|
|
<%= label_tag "account_types[#{brex_account.id}]", t(".account_type_label"),
|
|
class: "block text-sm font-medium text-primary mb-2" %>
|
|
<% default_account_type = brex_account.card? ? "CreditCard" : "Depository" %>
|
|
<%= select_tag "account_types[#{brex_account.id}]",
|
|
options_for_select(@account_type_options, default_account_type),
|
|
{ class: "appearance-none bg-container border border-primary rounded-md px-3 py-2 text-sm leading-6 text-primary focus:border-primary focus:ring-1 focus:ring-primary focus:outline-none w-full",
|
|
data: {
|
|
action: "change->account-type-selector#updateSubtype"
|
|
} } %>
|
|
</div>
|
|
|
|
<!-- Subtype dropdowns (shown/hidden based on account type) -->
|
|
<div data-account-type-selector-target="subtypeContainer">
|
|
<% @subtype_options.each do |account_type, subtype_config| %>
|
|
<%= render "brex_items/subtype_select", account_type: account_type, subtype_config: subtype_config, brex_account: brex_account %>
|
|
<% end %>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<% end %>
|
|
<% end %>
|
|
</div>
|
|
|
|
<div class="flex gap-3">
|
|
<%= render DS::Button.new(
|
|
text: t(".create_accounts"),
|
|
variant: "primary",
|
|
icon: "plus",
|
|
type: "submit",
|
|
class: "flex-1",
|
|
disabled: @api_error.present? || @brex_accounts.empty?,
|
|
data: { loading_button_target: "button" }
|
|
) %>
|
|
<%= render DS::Link.new(
|
|
text: t(".cancel"),
|
|
variant: "secondary",
|
|
href: accounts_path
|
|
) %>
|
|
</div>
|
|
<% end %>
|
|
<% end %>
|
|
<% end %>
|