Repository navigation
feat(contract-document): render the contract details and create the contract document #1329
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
jordividaller
merged 17 commits into
main
from
feat/pbyr-4778-contract-document-details
Sep 23, 2026
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
e25098b
refactor(contract-documents): move the contract-details helpers to co…
244968e
feat(contract-document): render the contract details and create the c…
a21c314
fix(contract-document): restore entered contract details on back, rew…
fd25db1
fix(contract-document): attach field labels to submission errors
9041028
fix(contract-document): keep field metadata reachable from an in-flig…
8beaef6
chore(contractor-onboarding): drop the doc comments orphaned by the move
f0b021a
fix(contract-document): fail the contract-details schema query on an …
86b40d4
fix(contract-document): prefill the service start date with today
47b8245
fix(contract-document): drop the start-date mismatch note from the st…
3c28ec8
fix(contract-document): expose query errors on the bag and block subm…
c366b27
refactor(contract-document): drop the unused form values type
0be33c4
docs(contract-document): document the error key and the standard cont…
c728705
test(contract-document): assert the disclaimer shows for a standard c…
920800d
fix(contract-document): report a failed employment fetch and keep tod…
f1bf337
docs(contract-document): any edit clears the AI misclassification war…
da2fcad
refactor(contractor-onboarding): re-export the moved contract-details…
6135135
fix(contract-document): keep the flow usable when the contract docume…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
26 changes: 26 additions & 0 deletions
26
src/common/contract-documents/components/StatementOfWorkDisclaimer.tsx
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import { Statement } from '@/src/components/form/Statement'; | ||
| import { | ||
| contractorPlusProductIdentifier, | ||
| contractorStandardProductIdentifier, | ||
| } from '@/src/common/contract-documents/constants'; | ||
|
|
||
| const CSA_DISCLAIMER = { | ||
| [contractorStandardProductIdentifier]: | ||
| ' Remote provides its Contractor Services Agreement (CSA) “as is”; it does not constitute legal advice or create an attorney-client relationship with Remote. Remote is not liable for the content You enter herein and You are encouraged to seek independent legal advice tailored to the specific relationship between You and Your Contractor. By use of the CSA, You release Remote from liability for any claim for damages or losses which may arise related to Your use thereof.', | ||
| [contractorPlusProductIdentifier]: | ||
| 'Remote provides its Contractor Services Agreement (CSA) “as is”; it does not constitute legal advice or create an attorney-client relationship with Remote. Remote is not liable for the content You enter herein and You are encouraged to seek independent legal advice tailored to the specific relationship between You and Your Contractor.', | ||
| }; | ||
|
|
||
| export const StatementOfWorkDisclaimer = ({ | ||
| subscription, | ||
| }: { | ||
| subscription: string; | ||
| }) => { | ||
| return ( | ||
| <Statement | ||
| title='Contractor Services Agreement' | ||
| description={CSA_DISCLAIMER[subscription as keyof typeof CSA_DISCLAIMER]} | ||
| severity='info' | ||
| /> | ||
| ); | ||
| }; | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| export const contractorStandardProductIdentifier = | ||
| 'urn:remotecom:resource:product:contractor:standard:monthly'; | ||
| export const contractorPlusProductIdentifier = | ||
| 'urn:remotecom:resource:product:contractor:plus:monthly'; | ||
| export const corProductIdentifier = | ||
| 'urn:remotecom:resource:product:contractor:aor:monthly'; | ||
|
|
||
| export const REMOTE_AI_ERROR_SOURCE = 'REMOTE_AI'; | ||
|
|
||
| export const REMOTE_AI_SERVICES_AND_DELIVERABLES_ERROR_MESSAGE = | ||
| "You cannot control how a contractor completes the Services and Deliverables. This means, for example, that you can't specify their working hours or use of subcontractors. Please make sure this field includes only project names, descriptions, and deliverables. We do not allow hyperlinks."; | ||
|
|
||
| export const REMOTE_AI_SERVICES_AND_DELIVERABLES_COR_ERROR_MESSAGE = | ||
| 'The content You have entered may not be consistent with the Contractor of Record terms. You are responsible before proceeding for ensuring that the language entered herein accurately reflects those terms and your relationship with Subcontractors.'; |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,152 @@ | ||
| import { addYears, format } from 'date-fns'; | ||
| import { FieldValues } from 'react-hook-form'; | ||
| import { ChangeEvent } from 'react'; | ||
|
|
||
| import { parseLocalDate } from '@/src/common/dates'; | ||
| import { createStatementProperty } from '@/src/components/form/jsf-utils/createFields'; | ||
| import { | ||
| contractorStandardProductIdentifier, | ||
| REMOTE_AI_SERVICES_AND_DELIVERABLES_COR_ERROR_MESSAGE, | ||
| REMOTE_AI_SERVICES_AND_DELIVERABLES_ERROR_MESSAGE, | ||
| } from '@/src/common/contract-documents/constants'; | ||
| import { ContractorContractDetailsFormPayload } from '@/src/common/contract-documents/types'; | ||
| import { JSFModify } from '@/src/flows/types'; | ||
|
|
||
| const isStandardPricingPlan = (pricingPlan: string | undefined) => { | ||
| return pricingPlan === contractorStandardProductIdentifier; | ||
| }; | ||
|
|
||
| const showBackDateWarning = ( | ||
| isStandardPricingPlanSelected: boolean, | ||
| provisionalStartDate: string | undefined, | ||
| ) => { | ||
| const isStartDateBackdated = | ||
| provisionalStartDate && | ||
| // Compare full days omitting time of the day | ||
| provisionalStartDate < format(new Date(), 'yyyy-MM-dd'); | ||
|
|
||
| if (!isStandardPricingPlanSelected && isStartDateBackdated) { | ||
| return createStatementProperty({ | ||
| severity: 'warning', | ||
| description: | ||
| 'Backdating the service start date is not supported in the selected Contractor Management plan.', | ||
| }); | ||
| } | ||
|
|
||
| return undefined; | ||
| }; | ||
|
|
||
| /** | ||
| * Handles changes to the services_and_deliverables field to clear AI warning state | ||
| */ | ||
| function onServicesAndDeliverablesChange( | ||
| _event: ChangeEvent<HTMLTextAreaElement>, | ||
| values: ContractorContractDetailsFormPayload & { | ||
| services_and_deliverables_ai_warning: string; | ||
| services_and_deliverables_error_skippable: boolean; | ||
| }, | ||
| setValues: ( | ||
| formValues: Partial< | ||
| ContractorContractDetailsFormPayload & { | ||
| services_and_deliverables_ai_warning: string; | ||
| services_and_deliverables_error_skippable: boolean; | ||
| } | ||
| >, | ||
| ) => void, | ||
| ) { | ||
| setValues({ | ||
| ...values, | ||
| services_and_deliverables_ai_warning: '', | ||
| services_and_deliverables_error_skippable: false, | ||
| }); | ||
| } | ||
|
|
||
| /** | ||
| * Merges internal jsfModify modifications with user-provided options for contract_details step | ||
| * This abstracts the logic of applying internal field modifications (like dynamic descriptions) | ||
| * while preserving user customizations | ||
| */ | ||
| export const buildContractDetailsJsfModify = ( | ||
| userJsfModify: JSFModify | undefined, | ||
| provisionalStartDateDescription: string | undefined, | ||
| selectedPricingPlan: string | undefined, | ||
| fieldValues: FieldValues, | ||
| isContractorOfRecord: boolean, | ||
| ): JSFModify => { | ||
| const isStandardPricingPlanSelected = | ||
| isStandardPricingPlan(selectedPricingPlan); | ||
| const provisionalStartDate = | ||
| fieldValues?.service_duration?.provisional_start_date; | ||
| const statement = showBackDateWarning( | ||
| isStandardPricingPlanSelected, | ||
| provisionalStartDate, | ||
| ); | ||
| const AiStatementWarning = createStatementProperty({ | ||
| severity: 'warning', | ||
| title: 'Possible misclassification risk', | ||
| description: isContractorOfRecord | ||
| ? REMOTE_AI_SERVICES_AND_DELIVERABLES_COR_ERROR_MESSAGE | ||
| : REMOTE_AI_SERVICES_AND_DELIVERABLES_ERROR_MESSAGE, | ||
| }); | ||
| return { | ||
| ...userJsfModify, | ||
| create: { | ||
| ...userJsfModify?.create, | ||
| services_and_deliverables_ai_warning: { | ||
| type: 'string', | ||
| 'x-jsf-presentation': { | ||
| inputType: 'hidden', | ||
| }, | ||
| }, | ||
| services_and_deliverables_error_skippable: { | ||
| type: 'boolean', | ||
| 'x-jsf-presentation': { | ||
| inputType: 'hidden', | ||
| }, | ||
| }, | ||
| }, | ||
| fields: { | ||
| ...userJsfModify?.fields, | ||
| ...{ | ||
| 'service_duration.provisional_start_date': { | ||
| description: provisionalStartDateDescription, | ||
| 'x-jsf-presentation': { | ||
| minDate: !isStandardPricingPlanSelected | ||
| ? format(new Date(), 'yyyy-MM-dd') | ||
| : undefined, | ||
| ...statement, | ||
| }, | ||
| }, | ||
| 'service_duration.expiration_date': { | ||
| 'x-jsf-presentation': { | ||
| calculateDynamicProperties: (formValues: FieldValues) => { | ||
| const maxDate = | ||
| isContractorOfRecord && | ||
| formValues.service_duration?.provisional_start_date | ||
| ? addYears( | ||
| parseLocalDate( | ||
| formValues.service_duration.provisional_start_date, | ||
| ), | ||
| 1, | ||
| ) | ||
| : undefined; | ||
| return { | ||
| maxDate: maxDate ? format(maxDate, 'yyyy-MM-dd') : undefined, | ||
| }; | ||
| }, | ||
| }, | ||
| }, | ||
| services_and_deliverables: { | ||
| onChange: onServicesAndDeliverablesChange, | ||
| 'x-jsf-presentation': { | ||
| calculateDynamicProperties: (formValues: FieldValues) => ({ | ||
| statement: formValues.services_and_deliverables_ai_warning | ||
| ? AiStatementWarning.statement | ||
| : undefined, | ||
| }), | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| }; | ||
| }; |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.