Repository navigation
fix(invoice-schedule): prefill the occurrence count with 1 when end after is picked - #1756
gabrielseco wants to merge 13 commits into
Conversation
A field with a schema default that becomes visible after the form mounts is filled with that default if it is still empty. Fields visible on first render, read-only and forced-value fields are left alone. Uses it for the invoice schedule occurrence count, which now starts at 1 once "End after a number of occurrences" is picked. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
📦 Bundle Size Report
Size Limits
Largest Files (Top 5)
View All Files (291 total)
✅ Bundle size check passed |
|
Deploy preview for adp-cost-calculator ready!
Deployed with vercel-action |
… revealed The form can render with no fields while its schema loads. The empty list was recorded as the baseline, so every field that then appeared with a default was filled in. The baseline now starts at the first render that has fields. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Deploy preview for remote-flows ready!
Deployed with vercel-action |
📊 Coverage Report✅ Coverage increased! 🎉
Detailed BreakdownLines Coverage
Statements Coverage
Functions Coverage
Branches Coverage
✅ Coverage check passed |
…ds instead of a form-wide hook The standalone flow builds its form before the schema loads, so a schema default was never read. It now runs the same initial-values helper the other flows use once its fields arrive, and fills only values that are still empty. The generic reveal-time hook is removed. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
| } | ||
| }, | ||
| ); | ||
| }, [fields, form]); |
There was a problem hiding this comment.
Reveal defaults only seed one flow
Medium Severity
Removing useApplyRevealDefaults from JSONSchemaFormFields drops the reveal-default behavior for every other consumer of the shared invoice-schedule schema. CreateInvoiceScheduleStep still has default: 1 on nr_occurrences but never writes it, so picking “End after a number of occurrences” in contractor onboarding leaves the count empty and required. Headless useInvoiceSchedule callers that build their own form miss it too.
Additional Locations (1)
Triggered by project rule: Code Review Guidelines
Reviewed by Cursor Bugbot for commit 9ce60f5. Configure here.
…m like the other flows The form was created in InvoiceScheduleFlow before the schema loaded, so schema defaults could not feed its initial values. InvoiceScheduleForm now mounts once the fields exist and builds its values with getInitialValues, as the onboarding and termination forms do. The flow keeps the bag, the form id and a ref the preview button reads the live values from. The one-off seeding effect is removed. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…eRefObject Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
There are 2 total unresolved issues (including 1 from previous review).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 4291211. Configure here.
…ecord reset The preview button now reads the latest values from the bag, which the form reports through checkFieldUpdates, so the form no longer registers itself in a ref. The flow is keyed by employmentId, so a different contractor starts from a fresh form. The frequency reset for a Contractor of Record is removed: the schema already rejects a frequency it no longer offers, and onboarding has no such reset. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…er from InvoiceScheduleFlow Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…nt wrapper from InvoiceScheduleFlow" Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…e them on the bag Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…form on isLoading like the other flows Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… already-cached contractor Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… bag members, tidy leftovers Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…alues Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>


Summary
Picking "End after a number of occurrences" on an invoice schedule now fills "Number of occurrences" with 1, the same as on the Remote platform.
Why
The count showed an empty field and a required error until the user typed a number. The schema can already carry a
default, and flows such as Contractor Onboarding apply it, but the standalone Invoice Schedule flow builds its form before the schema loads and never read it.What changed
Toggle details
nr_occurrencesgetsdefault: 1in the invoice schedule schema. Contractor Onboarding shares the schema and already applies defaults throughgetInitialValues, so it picks the value up with no change there.InvoiceScheduleFormnow creates the form itself instead of reading one from the context. Its starting values come from the bag'sinitialValues, which the hook builds withgetInitialValuesfrom the loaded fields and the flow'sdefaultValues, so a schemadefaultis applied the same way as in Contractor Onboarding. Before, the form was created inInvoiceScheduleFlowbefore the schema loaded. The form has to be mounted onceisLoadingis false, as in the README example: mounted earlier, it starts with no values.initialValuesandfieldValues(the latest values, fed by the form throughcheckFieldUpdates), and the preview button reads them from there.useInvoiceSchedulealso takes the flow'sdefaultValuesas an option.InvoiceScheduleFlowis keyed byemploymentId, so a different contractor starts from a fresh form.initialValuesandfieldValues, andUseInvoiceScheduleOptionsgains an optionaldefaultValues; all additive. Stacked on feat(invoice-schedule): choose how a recurring schedule ends #1744; retarget tomainonce it merges.Screenshots
Toggle screenshots
Before (#1744): the count is empty with a required error after picking "End after". After:
End after count defaults to 1
Related Resources
Testing
InvoiceScheduleFlow.test.tsxchecks the count is 1 after picking "End after". Bypassing `getInitialValues` makes it fail.example/app in a browser (sandbox, PRT contractor) count is 1 on first pick and a typed value survives toggling the radio🤖 Generated with Claude Code
Note
Medium Risk
Refactors form lifecycle and shared context for invoice schedules; behavior changes around mount timing, preview values, and CoR frequency handling without API changes.
Overview
Choosing End after a number of occurrences now shows Number of occurrences prefilled with 1, matching the Remote platform. The invoice schedule JSON schema adds
default: 1onnr_occurrences.The standalone flow no longer builds the form at the flow level before the schema loads.
InvoiceScheduleFormownsuseJSONSchemaFormand seeds it from the bag’sinitialValues, whichuseInvoiceSchedulebuilds withgetInitialValuesonce fields are ready (including flowdefaultValues). Consumers should mount the form only afterisLoadingis false; docs and tests follow that pattern.InvoiceScheduleFlowis keyed byemploymentIdso switching contractors remounts a clean form. Context drops the sharedforminstance; preview usesfieldValuesfromcheckFieldUpdates. The client-side effect that cleared recurring periodicity when Contractor of Record loaded is removed.Reviewed by Cursor Bugbot for commit 7872561. Bugbot is set up for automated code reviews on this repo. Configure here.