diff --git a/services/app-web/src/pages/SubmissionSummary/V2/SubmissionSummaryV2.test.tsx b/services/app-web/src/pages/SubmissionSummary/V2/SubmissionSummaryV2.test.tsx index 2406a842ab..40d5d8295a 100644 --- a/services/app-web/src/pages/SubmissionSummary/V2/SubmissionSummaryV2.test.tsx +++ b/services/app-web/src/pages/SubmissionSummary/V2/SubmissionSummaryV2.test.tsx @@ -34,9 +34,7 @@ describe('SubmissionSummary', () => { statusCode: 200, }), fetchContractMockSuccess({ - contract: { - id: 'test-abc-123', - }, + contract: mockContractPackageSubmitted(), }), fetchStateHealthPlanPackageWithQuestionsMockSuccess({ id: 'test-abc-123', @@ -51,7 +49,6 @@ describe('SubmissionSummary', () => { }, } ) - screen.debug() expect( await screen.findByRole('heading', { name: 'Contract details' }) ).toBeInTheDocument() @@ -461,9 +458,7 @@ describe('SubmissionSummary', () => { id: 'test-abc-123', }), fetchContractMockSuccess({ - contract: { - id: 'test-abc-123', - }, + contract: mockContractPackageSubmitted(), }), ], }, @@ -475,6 +470,7 @@ describe('SubmissionSummary', () => { }, } ) + screen.debug() expect( await screen.findByRole('heading', { name: 'Contract details', diff --git a/services/app-web/src/pages/SubmissionSummary/V2/SubmissionSummaryV2.tsx b/services/app-web/src/pages/SubmissionSummary/V2/SubmissionSummaryV2.tsx index cc1f0ac344..f1bfaaf8ea 100644 --- a/services/app-web/src/pages/SubmissionSummary/V2/SubmissionSummaryV2.tsx +++ b/services/app-web/src/pages/SubmissionSummary/V2/SubmissionSummaryV2.tsx @@ -8,7 +8,6 @@ import { import React, { useEffect, useRef, useState } from 'react' import { NavLink } from 'react-router-dom' import { useAuth } from '../../../contexts/AuthContext' -import { packageName } from '../../../common-code/healthPlanFormDataType' import { ContractDetailsSummarySectionV2 } from '../../StateSubmission/ReviewSubmit/V2/ReviewSubmit/ContractDetailsSummarySectionV2' import { ContactsSummarySection } from '../../StateSubmission/ReviewSubmit/V2/ReviewSubmit/ContactsSummarySectionV2' import { RateDetailsSummarySectionV2 } from '../../StateSubmission/ReviewSubmit/V2/ReviewSubmit/RateDetailsSummarySectionV2' @@ -61,13 +60,9 @@ export const SubmissionSummaryV2 = (): React.ReactElement => { // Page level state const { updateHeading } = usePage() const modalRef = useRef(null) - const [pkgName, setPkgName] = useState(undefined) const [documentError, setDocumentError] = useState(false) const { loggedInUser } = useAuth() - useEffect(() => { - updateHeading({ customHeading: pkgName }) - }, [pkgName, updateHeading]) const { id } = useRouteParams() const ldClient = useLDClient() @@ -87,16 +82,29 @@ export const SubmissionSummaryV2 = (): React.ReactElement => { contractID: id ?? 'unknown-contract', }, }, - fetchPolicy: 'network-only' + fetchPolicy: 'network-only', }) const contract = fetchContractData?.fetchContract.contract + const name = + contract && contract?.packageSubmissions.length > 0 + ? contract.packageSubmissions[0].contractRevision.contractName + : '' + useEffect(() => { + updateHeading({ + customHeading: name, + }) + }, [name, updateHeading]) if (fetchContractLoading) { return ( ) - } else if (fetchContractError || !contract) { + } else if ( + fetchContractError || + !contract || + contract.packageSubmissions.length === 0 + ) { //error handling for a state user that tries to access rates for a different state if ( fetchContractError?.graphQLErrors[0]?.extensions?.code === @@ -121,27 +129,15 @@ export const SubmissionSummaryV2 = (): React.ReactElement => { const submissionStatus = contract.status const statePrograms = contract.state.programs - const contractFormData = getVisibleLatestContractFormData(contract, isStateUser) + const contractFormData = getVisibleLatestContractFormData( + contract, + isStateUser + ) if (!contractFormData) { console.error('no form data inside submission summary') return } - const programIDs = contractFormData.programIDs - const programs = statePrograms.filter((program) => - programIDs.includes(program.id) - ) - // set the page heading - const name = packageName( - contract.stateCode, - contract.stateNumber, - contractFormData.programIDs, - programs - ) - if (pkgName !== name) { - setPkgName(name) - } - // Get the correct update info depending on the submission status let updateInfo: UpdateInformation | undefined = undefined if (submissionStatus === 'UNLOCKED' || submissionStatus === 'RESUBMITTED') {