diff --git a/services/app-web/src/hooks/useContractForm.ts b/services/app-web/src/hooks/useContractForm.ts index 6979af7689..491b8d0bc8 100644 --- a/services/app-web/src/hooks/useContractForm.ts +++ b/services/app-web/src/hooks/useContractForm.ts @@ -5,13 +5,10 @@ import { useFetchContractQuery, useCreateContractMutation, useUpdateContractDraftRevisionMutation, - ContractDraftRevisionFormDataInput, Contract, Rate, GenericDocument, GenericDocumentInput, - StateContact, - StateContactInput, UnlockedContract, UpdateContractDraftRevisionInput, ContractPackageSubmission @@ -28,7 +25,7 @@ type UseContractForm = { previousDocuments?: string[] updateDraft: ( input: UpdateContractDraftRevisionInput - ) => Promise + ) => Promise createDraft: (input: CreateContractInput) => Promise interimState?: InterimState } @@ -101,7 +98,7 @@ const useContractForm = (contractID?: string): UseContractForm => { const updateDraft: UseContractForm['updateDraft'] = async ( input: UpdateContractDraftRevisionInput - ): Promise => { + ): Promise => { setShowPageErrorMessage(false) if (input.formData.contractDocuments && input.formData.contractDocuments.length > 0) { @@ -242,5 +239,5 @@ const useContractForm = (contractID?: string): UseContractForm => { return {draftSubmission, previousDocuments, updateDraft, createDraft, interimState, showPageErrorMessage } } -export {useContractForm} -export type {UseContractForm} +export { useContractForm } +export type { UseContractForm } diff --git a/services/app-web/src/pages/StateSubmission/ContractDetails/ContractDetails.test.tsx b/services/app-web/src/pages/StateSubmission/ContractDetails/ContractDetails.test.tsx index 11da2593f1..3fdfd79a27 100644 --- a/services/app-web/src/pages/StateSubmission/ContractDetails/ContractDetails.test.tsx +++ b/services/app-web/src/pages/StateSubmission/ContractDetails/ContractDetails.test.tsx @@ -70,7 +70,7 @@ describe('ContractDetails', () => { screen.queryByText(/All fields are required/) ).not.toBeInTheDocument() const requiredLabels = await screen.findAllByText('Required') - expect(requiredLabels).toHaveLength(7) + expect(requiredLabels).toHaveLength(6) const optionalLabels = screen.queryAllByText('Optional') expect(optionalLabels).toHaveLength(0) }) diff --git a/services/app-web/src/pages/StateSubmission/ContractDetails/ContractDetails.tsx b/services/app-web/src/pages/StateSubmission/ContractDetails/ContractDetails.tsx index 23105dc9d4..7469f1f4ee 100644 --- a/services/app-web/src/pages/StateSubmission/ContractDetails/ContractDetails.tsx +++ b/services/app-web/src/pages/StateSubmission/ContractDetails/ContractDetails.tsx @@ -40,7 +40,7 @@ import { import { PageActions } from '../PageActions' import { activeFormPages, - type HealthPlanFormPageProps, + type ContractFormPageProps, } from '../StateSubmissionForm' import { formatYesNoForProto, @@ -155,7 +155,7 @@ export type FormError = export const ContractDetails = ({ showValidations = false, -}: HealthPlanFormPageProps): React.ReactElement => { +}: ContractFormPageProps): React.ReactElement => { const [shouldValidate, setShouldValidate] = React.useState(showValidations) const navigate = useNavigate() const ldClient = useLDClient() @@ -197,7 +197,6 @@ export const ContractDetails = ({ s3URL: undefined, status: 'UPLOAD_ERROR', sha256: doc.sha256, - dateAdded: doc.dateAdded, } } return { @@ -207,7 +206,6 @@ export const ContractDetails = ({ s3URL: doc.s3URL, status: 'UPLOAD_COMPLETE', sha256: doc.sha256, - dateAdded: doc.dateAdded, } }) diff --git a/services/app-web/src/pages/StateSubmission/StateSubmissionForm.tsx b/services/app-web/src/pages/StateSubmission/StateSubmissionForm.tsx index 36077bb0ba..912d2c1bac 100644 --- a/services/app-web/src/pages/StateSubmission/StateSubmissionForm.tsx +++ b/services/app-web/src/pages/StateSubmission/StateSubmissionForm.tsx @@ -112,3 +112,7 @@ const getRelativePathFromNestedRoute = (formRouteType: RouteT): string => export type HealthPlanFormPageProps = { showValidations?: boolean } + +export type ContractFormPageProps = { + showValidations?: boolean +} diff --git a/services/app-web/src/pages/StateSubmission/SubmissionType/SubmissionType.tsx b/services/app-web/src/pages/StateSubmission/SubmissionType/SubmissionType.tsx index 9dc3d8c790..7a0dd24b1e 100644 --- a/services/app-web/src/pages/StateSubmission/SubmissionType/SubmissionType.tsx +++ b/services/app-web/src/pages/StateSubmission/SubmissionType/SubmissionType.tsx @@ -16,9 +16,7 @@ import { PoliteErrorMessage, ReactRouterLinkWithLogging, } from '../../../components' -import { - isContractWithProvisions, -} from '../../../common-code/ContractType' +import { isContractWithProvisions } from '../../../common-code/ContractType' import { PopulationCoveredRecord, SubmissionTypeRecord, @@ -31,12 +29,15 @@ import { SubmissionType as SubmissionTypeT, CreateContractInput, ContractDraftRevisionFormDataInput, - UpdateContractDraftRevisionInput + UpdateContractDraftRevisionInput, } from '../../../gen/gqlClient' import { PageActions } from '../PageActions' import styles from '../StateSubmissionForm.module.scss' import { GenericApiErrorBanner, ProgramSelect } from '../../../components' -import { activeFormPages } from '../StateSubmissionForm' +import { + activeFormPages, + type ContractFormPageProps, +} from '../StateSubmissionForm' import { booleanAsYesNoFormValue, yesNoFormValueAsBoolean, @@ -64,13 +65,9 @@ export interface SubmissionTypeFormValues { type FormError = FormikErrors[keyof FormikErrors] -type SubmissionTypePageProps = { - showValidations?: boolean -} - export const SubmissionType = ({ showValidations = false, -}: SubmissionTypePageProps): React.ReactElement => { +}: ContractFormPageProps): React.ReactElement => { const { loggedInUser } = useAuth() const { currentRoute } = useCurrentRoute() const [shouldValidate, setShouldValidate] = useState(showValidations) @@ -199,10 +196,7 @@ export const SubmissionType = ({ setSubmitting(false) } } else { - if ( - draftSubmission === undefined || - !updateDraft - ) { + if (draftSubmission === undefined || !updateDraft) { console.info(draftSubmission, updateDraft) console.info( 'ERROR, SubmissionType for does not have props needed to update a draft.' @@ -210,73 +204,124 @@ export const SubmissionType = ({ return } // set new values - let updatedDraftSubmissionFormData: ContractDraftRevisionFormDataInput = { - contractExecutionStatus: draftSubmission.draftRevision.formData.contractExecutionStatus, - contractDateStart: draftSubmission.draftRevision.formData.contractDateStart, - contractDateEnd: draftSubmission.draftRevision.formData.contractDateEnd, - contractType: values.contractType as ContractType, - submissionDescription: values.submissionDescription, - riskBasedContract: yesNoFormValueAsBoolean( - values.riskBasedContract - ), - populationCovered: values.populationCovered, - submissionType: - values.submissionType as SubmissionTypeT, - programIDs: values.programIDs, - stateContacts: draftSubmission.draftRevision.formData.stateContacts || [], - supportingDocuments: draftSubmission.draftRevision.formData.supportingDocuments || [], - managedCareEntities: draftSubmission.draftRevision.formData.managedCareEntities, - federalAuthorities: draftSubmission.draftRevision.formData.federalAuthorities, - contractDocuments: draftSubmission.draftRevision.formData.contractDocuments, - statutoryRegulatoryAttestation: - draftSubmission.draftRevision.formData.statutoryRegulatoryAttestation, - // If contract is in compliance, we set the description to undefined. This clears out previous non-compliance description - statutoryRegulatoryAttestationDescription: draftSubmission.draftRevision.formData.statutoryRegulatoryAttestationDescription - } + const updatedDraftSubmissionFormData: ContractDraftRevisionFormDataInput = + { + contractExecutionStatus: + draftSubmission.draftRevision.formData + .contractExecutionStatus, + contractDateStart: + draftSubmission.draftRevision.formData + .contractDateStart, + contractDateEnd: + draftSubmission.draftRevision.formData.contractDateEnd, + contractType: values.contractType as ContractType, + submissionDescription: values.submissionDescription, + riskBasedContract: yesNoFormValueAsBoolean( + values.riskBasedContract + ), + populationCovered: values.populationCovered, + submissionType: values.submissionType as SubmissionTypeT, + programIDs: values.programIDs, + stateContacts: + draftSubmission.draftRevision.formData.stateContacts || + [], + supportingDocuments: + draftSubmission.draftRevision.formData + .supportingDocuments || [], + managedCareEntities: + draftSubmission.draftRevision.formData + .managedCareEntities, + federalAuthorities: + draftSubmission.draftRevision.formData + .federalAuthorities, + contractDocuments: + draftSubmission.draftRevision.formData + .contractDocuments, + statutoryRegulatoryAttestation: + draftSubmission.draftRevision.formData + .statutoryRegulatoryAttestation, + // If contract is in compliance, we set the description to undefined. This clears out previous non-compliance description + statutoryRegulatoryAttestationDescription: + draftSubmission.draftRevision.formData + .statutoryRegulatoryAttestationDescription, + } if (isContractWithProvisions(draftSubmission)) { - updatedDraftSubmissionFormData.inLieuServicesAndSettings = draftSubmission.draftRevision.formData.inLieuServicesAndSettings - updatedDraftSubmissionFormData.modifiedBenefitsProvided = draftSubmission.draftRevision.formData.modifiedBenefitsProvided - updatedDraftSubmissionFormData.modifiedGeoAreaServed = draftSubmission.draftRevision.formData.modifiedGeoAreaServed - updatedDraftSubmissionFormData.modifiedMedicaidBeneficiaries = draftSubmission.draftRevision.formData.modifiedMedicaidBeneficiaries - updatedDraftSubmissionFormData.modifiedRiskSharingStrategy = draftSubmission.draftRevision.formData.modifiedRiskSharingStrategy - updatedDraftSubmissionFormData.modifiedIncentiveArrangements = draftSubmission.draftRevision.formData.modifiedIncentiveArrangements - updatedDraftSubmissionFormData.modifiedWitholdAgreements = draftSubmission.draftRevision.formData.modifiedWitholdAgreements - updatedDraftSubmissionFormData.modifiedStateDirectedPayments = draftSubmission.draftRevision.formData.modifiedStateDirectedPayments - updatedDraftSubmissionFormData.modifiedPassThroughPayments = draftSubmission.draftRevision.formData.modifiedPassThroughPayments - updatedDraftSubmissionFormData.modifiedPaymentsForMentalDiseaseInstitutions = draftSubmission.draftRevision.formData.modifiedPaymentsForMentalDiseaseInstitutions - updatedDraftSubmissionFormData.modifiedMedicalLossRatioStandards = draftSubmission.draftRevision.formData.modifiedMedicalLossRatioStandards - updatedDraftSubmissionFormData.modifiedOtherFinancialPaymentIncentive = draftSubmission.draftRevision.formData.modifiedOtherFinancialPaymentIncentive - updatedDraftSubmissionFormData.modifiedEnrollmentProcess = draftSubmission.draftRevision.formData.modifiedEnrollmentProcess - updatedDraftSubmissionFormData.modifiedGrevienceAndAppeal = draftSubmission.draftRevision.formData.modifiedGrevienceAndAppeal - updatedDraftSubmissionFormData.modifiedNetworkAdequacyStandards = draftSubmission.draftRevision.formData.modifiedNetworkAdequacyStandards - updatedDraftSubmissionFormData.modifiedLengthOfContract = draftSubmission.draftRevision.formData.modifiedLengthOfContract - updatedDraftSubmissionFormData.modifiedNonRiskPaymentArrangements = draftSubmission.draftRevision.formData.modifiedNonRiskPaymentArrangements + updatedDraftSubmissionFormData.inLieuServicesAndSettings = + draftSubmission.draftRevision.formData.inLieuServicesAndSettings + updatedDraftSubmissionFormData.modifiedBenefitsProvided = + draftSubmission.draftRevision.formData.modifiedBenefitsProvided + updatedDraftSubmissionFormData.modifiedGeoAreaServed = + draftSubmission.draftRevision.formData.modifiedGeoAreaServed + updatedDraftSubmissionFormData.modifiedMedicaidBeneficiaries = + draftSubmission.draftRevision.formData.modifiedMedicaidBeneficiaries + updatedDraftSubmissionFormData.modifiedRiskSharingStrategy = + draftSubmission.draftRevision.formData.modifiedRiskSharingStrategy + updatedDraftSubmissionFormData.modifiedIncentiveArrangements = + draftSubmission.draftRevision.formData.modifiedIncentiveArrangements + updatedDraftSubmissionFormData.modifiedWitholdAgreements = + draftSubmission.draftRevision.formData.modifiedWitholdAgreements + updatedDraftSubmissionFormData.modifiedStateDirectedPayments = + draftSubmission.draftRevision.formData.modifiedStateDirectedPayments + updatedDraftSubmissionFormData.modifiedPassThroughPayments = + draftSubmission.draftRevision.formData.modifiedPassThroughPayments + updatedDraftSubmissionFormData.modifiedPaymentsForMentalDiseaseInstitutions = + draftSubmission.draftRevision.formData.modifiedPaymentsForMentalDiseaseInstitutions + updatedDraftSubmissionFormData.modifiedMedicalLossRatioStandards = + draftSubmission.draftRevision.formData.modifiedMedicalLossRatioStandards + updatedDraftSubmissionFormData.modifiedOtherFinancialPaymentIncentive = + draftSubmission.draftRevision.formData.modifiedOtherFinancialPaymentIncentive + updatedDraftSubmissionFormData.modifiedEnrollmentProcess = + draftSubmission.draftRevision.formData.modifiedEnrollmentProcess + updatedDraftSubmissionFormData.modifiedGrevienceAndAppeal = + draftSubmission.draftRevision.formData.modifiedGrevienceAndAppeal + updatedDraftSubmissionFormData.modifiedNetworkAdequacyStandards = + draftSubmission.draftRevision.formData.modifiedNetworkAdequacyStandards + updatedDraftSubmissionFormData.modifiedLengthOfContract = + draftSubmission.draftRevision.formData.modifiedLengthOfContract + updatedDraftSubmissionFormData.modifiedNonRiskPaymentArrangements = + draftSubmission.draftRevision.formData.modifiedNonRiskPaymentArrangements } else { - updatedDraftSubmissionFormData.inLieuServicesAndSettings = undefined - updatedDraftSubmissionFormData.modifiedBenefitsProvided = undefined + updatedDraftSubmissionFormData.inLieuServicesAndSettings = + undefined + updatedDraftSubmissionFormData.modifiedBenefitsProvided = + undefined updatedDraftSubmissionFormData.modifiedGeoAreaServed = undefined - updatedDraftSubmissionFormData.modifiedMedicaidBeneficiaries = undefined - updatedDraftSubmissionFormData.modifiedRiskSharingStrategy = undefined - updatedDraftSubmissionFormData.modifiedIncentiveArrangements = undefined - updatedDraftSubmissionFormData.modifiedWitholdAgreements = undefined - updatedDraftSubmissionFormData.modifiedStateDirectedPayments = undefined - updatedDraftSubmissionFormData.modifiedPassThroughPayments = undefined - updatedDraftSubmissionFormData.modifiedPaymentsForMentalDiseaseInstitutions = undefined - updatedDraftSubmissionFormData.modifiedMedicalLossRatioStandards = undefined - updatedDraftSubmissionFormData.modifiedOtherFinancialPaymentIncentive = undefined - updatedDraftSubmissionFormData.modifiedEnrollmentProcess = undefined - updatedDraftSubmissionFormData.modifiedGrevienceAndAppeal = undefined - updatedDraftSubmissionFormData.modifiedNetworkAdequacyStandards = undefined - updatedDraftSubmissionFormData.modifiedLengthOfContract = undefined - updatedDraftSubmissionFormData.modifiedNonRiskPaymentArrangements = undefined + updatedDraftSubmissionFormData.modifiedMedicaidBeneficiaries = + undefined + updatedDraftSubmissionFormData.modifiedRiskSharingStrategy = + undefined + updatedDraftSubmissionFormData.modifiedIncentiveArrangements = + undefined + updatedDraftSubmissionFormData.modifiedWitholdAgreements = + undefined + updatedDraftSubmissionFormData.modifiedStateDirectedPayments = + undefined + updatedDraftSubmissionFormData.modifiedPassThroughPayments = + undefined + updatedDraftSubmissionFormData.modifiedPaymentsForMentalDiseaseInstitutions = + undefined + updatedDraftSubmissionFormData.modifiedMedicalLossRatioStandards = + undefined + updatedDraftSubmissionFormData.modifiedOtherFinancialPaymentIncentive = + undefined + updatedDraftSubmissionFormData.modifiedEnrollmentProcess = + undefined + updatedDraftSubmissionFormData.modifiedGrevienceAndAppeal = + undefined + updatedDraftSubmissionFormData.modifiedNetworkAdequacyStandards = + undefined + updatedDraftSubmissionFormData.modifiedLengthOfContract = + undefined + updatedDraftSubmissionFormData.modifiedNonRiskPaymentArrangements = + undefined } try { const updatedContractInput: UpdateContractDraftRevisionInput = { formData: updatedDraftSubmissionFormData, contractID: draftSubmission.id, - lastSeenUpdatedAt: draftSubmission.draftRevision.updatedAt + lastSeenUpdatedAt: draftSubmission.draftRevision.updatedAt, } const updatedDraft = await updateDraft(updatedContractInput) if (updatedDraft instanceof Error) {