Skip to content

feat(contractor)!: migrate ContractorProfile to useContractorDetailsForm#2261

Draft
serikjensen wants to merge 3 commits into
mainfrom
feat/contractor-details-form-hook
Draft

feat(contractor)!: migrate ContractorProfile to useContractorDetailsForm#2261
serikjensen wants to merge 3 commits into
mainfrom
feat/contractor-details-form-hook

Conversation

@serikjensen

Copy link
Copy Markdown
Member

Summary

Migrates ContractorProfile to a new headless useContractorDetailsForm hook (mirroring useEmployeeDetailsForm), powering individual/business + admin/self-onboarding flows from a single source. The legacy useContractorProfile implementation is removed.

  • New hook useContractorDetailsForm: supports all contractor create/update fields with conditional requiredness, redacted-PII handling (ssn/ein), the self-onboarding toggle, and a schema-driven Fields surface. Base requiredFieldsConfig mirrors the API (create-required vs never), with email required via a functional predicate when self-onboarding is on.
  • Field exclusion: inapplicable fields are dropped from both validation and render via a single getExcludedContractorFields array helper, forked on individual vs business. Field visibility derives from "not excluded" (email is the lone exception). The resolver builds its per-validation schema from the submitted values, decoupling schema generation from useWatch.
  • ContractorProfile integration: consumes the hook, layering SDK-stricter requiredness via a static optionalFieldsToRequire superset for backwards compatibility.
  • Tests/docs: robust schema-level + hook + component tests; updated useContractorDetailsForm.md and regenerated the public API report.

Breaking change

ContractorProfile's defaultValues prop shape changed: contractorTypetype, and startDate is now an ISO date string (was Date). See the BREAKING CHANGE: footer on commit d177311 for the migration snippet.

Commits

  1. feat(contractor)!: migrate ContractorProfile to useContractorDetailsForm
  2. refactor(contractor): simplify field exclusion to a single array helper

Test plan

  • npm run test -- --run src/components/Contractor/Profile (61 passing locally)
  • npx tsc --noEmit clean
  • npm run lint:check (no new errors)
  • Manually inspect the diff for the defaultValues breaking change + migration guidance

Made with Cursor

serikjensen and others added 3 commits June 24, 2026 14:29
Replace the legacy useContractorProfile hook/form with the new headless
useContractorDetailsForm. ContractorProfile and the contractor OnboardingFlow
now compose the hook, with API-aligned requiredness plus the profile's existing
product requiredness layered on via optionalFieldsToRequire.

BREAKING CHANGE: The `defaultValues` of `ContractorProfile` (and the contractor
`OnboardingFlow` profile defaults), typed `ContractorProfileFormData`, changed shape:

- `contractorType` -> `type` (same `'Individual' | 'Business'` values)
- `startDate` is now an ISO date string (`'YYYY-MM-DD'`) instead of a `Date`

All other default-value keys are unchanged. Migrate by renaming the key and
passing a string date:

```tsx
// Before
<ContractorProfile
  defaultValues={{ contractorType: 'Individual', startDate: new Date('2024-02-15') }}
/>

// After
<ContractorProfile defaultValues={{ type: 'Individual', startDate: '2024-02-15' }} />
```

Co-authored-by: Cursor <cursoragent@cursor.com>
Replace the ContractorFieldApplicability interface and the 8-boolean
deriveContractorApplicability function with getExcludedContractorFields,
which returns just the excluded-field array forked on individual vs
business. Field visibility now derives from "not excluded" (email is the
sole exception, gated on self-onboarding), removing the duplicated logic
between the schema's excludeFields and the form's Fields gating.

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