OUT-3609: bank account selector dropdown for invoice settings - #232
Conversation
…s UI - Add bank account dropdown in InvoiceDetail below bankDepositFeeFlag checkbox - Fetch QBO bank accounts via SWR (GET /api/quickbooks/setting/bank-account) - Include bankAccountRef in settingState for single-request save - Add click-outside-to-close, loading state, and amber warning when unselected - Pass bankAccounts, isBankAccountsLoading, selectBankAccount props via SettingAccordion Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…t bank account Block the Confirm/Update button when bankDepositFeeFlag is on but no bank account is selected. Without a bank account, the webhook deposit flow throws on every payment.succeeded event. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Greptile SummaryThis PR introduces Stripe absorbed-fees and bank-deposit settings to the Invoice Details section: two new checkboxes ( Two minor quality issues were noted: Confidence Score: 5/5Safe to merge; the two findings are P2 quality issues that do not block core functionality. All findings are P2 — a stale src/components/dashboard/settings/sections/invoice/InvoiceDetail.tsx — stale bankAccountRef on toggle-off Important Files Changed
Sequence DiagramsequenceDiagram
participant U as User
participant ID as InvoiceDetail (UI)
participant H as useInvoiceDetailSettings
participant SWR as SWR Cache
participant API as /api/quickbooks/setting
U->>ID: Toggle absorbedFeeFlag ON
ID->>H: changeSettings('absorbedFeeFlag', true)
H->>H: setSettingState(...)
U->>ID: Toggle bankDepositFeeFlag ON
ID->>H: changeSettings('bankDepositFeeFlag', true)
H->>SWR: fetch /api/quickbooks/setting/bank-account
SWR-->>H: bankAccounts[]
H-->>ID: render bank account dropdown
U->>ID: Select bank account
ID->>H: selectBankAccount(id)
H->>H: setSettingState({ bankAccountRef: id })
U->>ID: Click Update Setting
ID->>H: submitInvoiceSettings()
H->>API: POST { absorbedFeeFlag, bankDepositFeeFlag, bankAccountRef, ... }
API-->>H: success
H->>SWR: mutate(invoice settings key)
Note over ID,H: If absorbedFeeFlag toggled OFF,
Note over ID,H: bankDepositFeeFlag is reset but
Note over ID,H: bankAccountRef retains stale value
|
| const changeSettings = ( | ||
| flag: keyof InvoiceSettingType, | ||
| state: boolean, | ||
| state: boolean | string | null, | ||
| ) => { | ||
| setSettingState((prev) => ({ | ||
| ...prev, | ||
| [flag]: state, | ||
| })) | ||
| } |
There was a problem hiding this comment.
changeSettings prop type is narrower than the hook's implementation
InvoiceDetailProps.changeSettings is declared as (flag: keyof InvoiceSettingType, state: boolean) => void, but the hook's implementation accepts boolean | string | null. Because bankAccountRef is string | null in InvoiceSettingType, any future attempt to call changeSettings('bankAccountRef', ...) directly from InvoiceDetail will be rejected by TypeScript with the current prop type. Aligning the types avoids this footgun — update both the hook signature and the InvoiceDetailProps declaration to boolean | string | null.
0748e3d
into
feature/stripe-fees-and-deposit
|
Same changes as in PR which has been approved. |
Summary
bankDepositFeeFlagcheckbox)GET /api/quickbooks/setting/bank-account)bankAccountRefinsettingStatefor single-request saveSettingAccordion→InvoiceDetailFiles changed
src/hook/useSettings.ts—useInvoiceDetailSettingshook: bank account state, SWR fetch, single API call submitsrc/components/dashboard/settings/sections/invoice/InvoiceDetail.tsx— custom dropdown UIsrc/components/dashboard/settings/SettingAccordion.tsx— prop passthroughTest plan
absorbedFeeFlag→bankDepositFeeFlagcheckbox appearsbankDepositFeeFlag→ bank account dropdown appears, loads QBO accountsabsorbedFeeFlag→ dropdown and deposit checkbox disappear🤖 Generated with Claude Code