Skip to content

feat(contractor): migrate PaymentMethod to useContractorPaymentMethodForm hook#2293

Draft
serikjensen wants to merge 2 commits into
mainfrom
feat/contractor-payment-method-hook
Draft

feat(contractor): migrate PaymentMethod to useContractorPaymentMethodForm hook#2293
serikjensen wants to merge 2 commits into
mainfrom
feat/contractor-payment-method-hook

Conversation

@serikjensen

Copy link
Copy Markdown
Member

Summary

Migrates the Contractor PaymentMethod component from its monolithic inline-form pattern to the hook-based architecture (following /migrate-sdk-component-to-hooks). Single screen, single hook.

  • Adds useContractorPaymentMethodForm — one headless hook for the combined payment-type + bank-account form. Uses a value-aware excludeFields function so the bank fields stay in requiredFieldsConfig (promotable) but are dropped from required validation when type === 'Check', mirroring the useContractorDetailsForm precedent.
  • Rewrites PaymentMethod.tsx to BaseBoundaries + thin Root + SDKFormProvider, preserving the event surface (contractor/bankAccount/created, contractor/paymentMethod/updated, contractor/paymentMethod/done) and the masked-account-number behavior.
  • Hardens pre-migration test coverage (PaymentMethod.test.tsx) and adds hook/schema unit tests.
  • Exports the hook, schema, error codes, and fields from src/index.ts.
  • Removes the now-unused PaymentTypeForm / BankAccountForm and the inline schema.

Notes

  • Faithfully preserves current behavior, including the original "Direct Deposit always POSTs a bank account on submit" sequence. A follow-up is open for discussion: aligning the Direct Deposit path with gws-flows (drop the redundant PUT /payment_method since the bank-account POST already updates the payment method) and optionally gating the POST on actual field changes.

Test plan

  • npm run test -- --run (full suite green)
  • npm run lint:check (0 errors)
  • Manual verification in the SDK dev app / Storybook

Made with Cursor

serikjensen and others added 2 commits June 26, 2026 15:19
…Form hook

Migrate the Contractor PaymentMethod component from its monolithic inline-form
pattern to the hook-based architecture.

- Add useContractorPaymentMethodForm: a single headless hook for the combined
  payment-type + bank-account form, with value-aware excludeFields (Check hides
  and de-requires the bank fields) per the useContractorDetailsForm precedent.
- Rewrite PaymentMethod.tsx to BaseBoundaries + thin Root + SDKFormProvider,
  preserving the event surface (CREATED / UPDATED / DONE) and masked-account
  behavior.
- Harden pre-migration test coverage and add hook unit tests.
- Export the hook, schema, error codes, and fields from src/index.ts.
- Remove the now-unused PaymentTypeForm/BankAccountForm and inline schema.

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant