Skip to content
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

[Institution profile] Page-level error for API issues #1031

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 22 additions & 12 deletions src/pages/Filing/ViewInstitutionProfile/index.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { useQuery } from '@tanstack/react-query';
import { fetchInstitutionDetails } from 'api/requests';
import useSblAuth from 'api/useSblAuth';
import CommonLinks from 'components/CommonLinks';
import CrumbTrail from 'components/CrumbTrail';
import FormHeaderWrapper from 'components/FormHeaderWrapper';
import FormWrapper from 'components/FormWrapper';
import { Link } from 'components/Link';
import { LoadingContent } from 'components/Loading';
import { Alert } from 'design-system-react';
import { useParams } from 'react-router-dom';
import { Error500 } from '../../Error/Error500';
import { AffiliateInformation } from './AffiliateInformation';
import { FinancialInstitutionDetails } from './FinancialInstitutionDetails';
import { IdentifyingInformation } from './IdentifyingInformation';
Expand All @@ -23,10 +24,25 @@ function InstitutionDetails(): JSX.Element | null {
);

if (isLoading) return <LoadingContent />;
if (isError)
return (
<Error500 error={{ message: 'Unable to fetch institution details.' }} />
);

const errorMessage = 'A problem occurred when trying to load your profile';

const content = isError ? (
<Alert status='error' message={errorMessage}>
Try again in a few minutes. If this issues persists,{' '}
<CommonLinks.EmailSupportStaff subject={`[Error] ${errorMessage}`} />.
</Alert>
) : (
<>
<FinancialInstitutionDetails data={data} />
<IdentifyingInformation data={data} />
<AffiliateInformation data={data} />
{/* TODO: include history of changes after MVP
https://github.com/cfpb/sbl-project/issues/39
<ChangeHistory />
*/}
</>
);

return (
<main id='main'>
Expand All @@ -39,13 +55,7 @@ function InstitutionDetails(): JSX.Element | null {
<FormHeaderWrapper>
<PageIntro />
</FormHeaderWrapper>
<FinancialInstitutionDetails data={data} />
<IdentifyingInformation data={data} />
<AffiliateInformation data={data} />
{/* TODO: include history of changes after MVP
https://github.com/cfpb/sbl-project/issues/39
<ChangeHistory />
*/}
{content}
</FormWrapper>
</main>
);
Expand Down
Loading