feat(contractor)!: migrate ContractorProfile to useContractorDetailsForm#2261
Draft
serikjensen wants to merge 3 commits into
Draft
feat(contractor)!: migrate ContractorProfile to useContractorDetailsForm#2261serikjensen wants to merge 3 commits into
serikjensen wants to merge 3 commits into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Migrates
ContractorProfileto a new headlessuseContractorDetailsFormhook (mirroringuseEmployeeDetailsForm), powering individual/business + admin/self-onboarding flows from a single source. The legacyuseContractorProfileimplementation is removed.useContractorDetailsForm: supports all contractor create/update fields with conditional requiredness, redacted-PII handling (ssn/ein), the self-onboarding toggle, and a schema-drivenFieldssurface. BaserequiredFieldsConfigmirrors the API (create-required vs never), withemailrequired via a functional predicate when self-onboarding is on.getExcludedContractorFieldsarray 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 fromuseWatch.ContractorProfileintegration: consumes the hook, layering SDK-stricter requiredness via a staticoptionalFieldsToRequiresuperset for backwards compatibility.useContractorDetailsForm.mdand regenerated the public API report.Breaking change
ContractorProfile'sdefaultValuesprop shape changed:contractorType→type, andstartDateis now an ISO datestring(wasDate). See theBREAKING CHANGE:footer on commitd177311for the migration snippet.Commits
feat(contractor)!: migrate ContractorProfile to useContractorDetailsFormrefactor(contractor): simplify field exclusion to a single array helperTest plan
npm run test -- --run src/components/Contractor/Profile(61 passing locally)npx tsc --noEmitcleannpm run lint:check(no new errors)defaultValuesbreaking change + migration guidanceMade with Cursor