generated from cfpb/open-source-project-template
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Type of financial institution (Phase 1.5) (#465)
Closes #455 ## Changes - Integrates Type of FI form into the workflow - Updates Type of FI form content - Prevents creation of a Filing for the institution until they've clicked "Start filing" Co-authored-by: shindigira <[email protected]>
- Loading branch information
1 parent
2e398a6
commit 4bfca21
Showing
11 changed files
with
300 additions
and
61 deletions.
There are no files selected for viewing
This file contains 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 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,50 @@ | ||
import AlertApiUnavailable from 'components/AlertApiUnavailable'; | ||
import { LoadingContent } from 'components/Loading'; | ||
import { Button } from 'design-system-react'; | ||
import { useNavigate, useParams } from 'react-router-dom'; | ||
import { FILING_STATUS_CODE_FILING_EXISTS } from 'utils/constants'; | ||
import useCreateFiling from 'utils/useCreateFiling'; | ||
|
||
export function FilingCreate(): JSX.Element | null | undefined { | ||
const { lei, year } = useParams(); | ||
const navigate = useNavigate(); | ||
|
||
const { isLoading, error, data: filing } = useCreateFiling(lei, year); | ||
|
||
/** Missing required param, cannot continue */ | ||
if (!lei || !year) { | ||
navigate('/filing'); | ||
return null; | ||
} | ||
|
||
if (isLoading) return <LoadingContent message='Loading filing data...' />; | ||
|
||
/** Filing exists */ | ||
if ( | ||
filing ?? | ||
Number(error?.response?.status) === FILING_STATUS_CODE_FILING_EXISTS | ||
) { | ||
// Note: React was complaining about setState during render. This setTimeout seems to resolve the issue. | ||
setTimeout(() => navigate(`/filing/${year}/${lei}/upload`), 0); | ||
return <LoadingContent message='Loading filing data...' />; | ||
} | ||
|
||
const onReturnToFiling = (): void => navigate('/filing'); | ||
|
||
if (error) | ||
return ( | ||
<div className='u-mt45 u-mb45 mx-3'> | ||
<AlertApiUnavailable | ||
message={`Unable to create a ${year} Filing for ${lei}`} | ||
/> | ||
<div> | ||
<Button | ||
label='Return to Filing overview' | ||
onClick={onReturnToFiling} | ||
/> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
export default FilingCreate; |
This file contains 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 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 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 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
Oops, something went wrong.