Skip to content

Commit

Permalink
add loading and error states
Browse files Browse the repository at this point in the history
  • Loading branch information
pearl-truss committed Apr 9, 2024
1 parent 5aee09a commit c6516bf
Showing 1 changed file with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ import {
SubmissionUpdatedBanner,
DocumentWarningBanner,
} from '../../../components'
import {
ErrorOrLoadingPage,
handleAndReturnErrorState,
} from '../../StateSubmission/ErrorOrLoadingPage'
import { usePage } from '../../../contexts/PageContext'
import {
useFetchContractQuery,
Expand Down Expand Up @@ -66,8 +70,8 @@ export const SubmissionSummaryV2 = (): React.ReactElement => {
// API requests
const {
data: fetchContractData,
// loading: fetchContractLoading,
// error: fetchContractError,
loading: fetchContractLoading,
error: fetchContractError,
} = useFetchContractQuery({
variables: {
input: {
Expand Down Expand Up @@ -100,6 +104,19 @@ export const SubmissionSummaryV2 = (): React.ReactElement => {
setPkgName(name)
}

// Display any full page interim state resulting from the initial fetch API requests
if (fetchContractLoading) {
return <ErrorOrLoadingPage state="LOADING" />
}

if (fetchContractError) {
return (
<ErrorOrLoadingPage
state={handleAndReturnErrorState(fetchContractError)}
/>
)
}

// Get the correct update info depending on the submission status
let updateInfo: UpdateInformation | undefined = undefined
if (submissionStatus === 'UNLOCKED' || submissionStatus === 'RESUBMITTED') {
Expand Down Expand Up @@ -229,7 +246,7 @@ export const SubmissionSummaryV2 = (): React.ReactElement => {
{contract && isContractActionAndRateCertification && (
<RateDetailsSummarySectionV2
documentDateLookupTable={documentDates}
contract={fetchContractData?.fetchContract.contract}
contract={contract}
submissionName={name}
isCMSUser={isCMSUser}
statePrograms={statePrograms}
Expand Down

0 comments on commit c6516bf

Please sign in to comment.