This repository was archived by the owner on Apr 16, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathFinancialInstitutionDetails.tsx
More file actions
98 lines (90 loc) · 3.49 KB
/
Copy pathFinancialInstitutionDetails.tsx
File metadata and controls
98 lines (90 loc) · 3.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/* eslint-disable react/require-default-props */
import Links from 'components/CommonLinks';
import { Link } from 'components/Link';
import SectionIntro from 'components/SectionIntro';
import { WellContainer } from 'design-system-react';
import type { ReactNode } from 'react';
import type {
DomainType as Domain,
InstitutionDetailsApiType,
} from 'types/formTypes';
import { valueOrNotavailable } from 'utils/formatting';
import { FormSectionWrapper } from '../../../components/FormSectionWrapper';
import InstitutionDataLabels from '../formHelpers';
import AddressStreetOptional from './AddressStreetOptional';
import { DisplayField, LAPSED, NOT_AVAILABLE } from './DisplayField';
export const formatDomains = (domains?: Domain[]): string => {
if (!domains || domains.length === 0) return NOT_AVAILABLE;
const domainList = domains
.map((domain: Domain) => domain.domain)
.filter(Boolean);
return valueOrNotavailable(domainList.join(', '));
};
const defaultDescription = (
<>
To update the email domains for your financial institution,{' '}
<Link href='mailto:SBLHelp@cfpb.gov?subject=[BETA] Update financial institution profile: Update email domain'>
email our support staff
</Link>
. To update any other data in this section, contact your Local Operating
Unit (LOU) or visit <Links.GetAnLEI /> to identify your LOU.
</>
);
export function FinancialInstitutionDetails({
data,
heading,
isDomainsVisible = true,
description = defaultDescription,
}: {
data: InstitutionDetailsApiType;
heading?: ReactNode;
isDomainsVisible?: boolean;
description?: ReactNode;
}): JSX.Element {
return (
<FormSectionWrapper className='u-mt60'>
<SectionIntro heading={heading}>{description}</SectionIntro>
<WellContainer className='u-mt30'>
<DisplayField
label={InstitutionDataLabels.fiName}
value={valueOrNotavailable(data.name)}
/>
<DisplayField
label={InstitutionDataLabels.hqAddress}
value={
<>
{valueOrNotavailable(data.hq_address_street_1)}
<br />
{/* @ts-expect-error Part of code cleanup for post-mvp see: https://github.com/cfpb/sbl-frontend/issues/717 */}
<AddressStreetOptional street={data.hq_address_street_2} />
{/* @ts-expect-error Part of code cleanup for post-mvp see: https://github.com/cfpb/sbl-frontend/issues/717 */}
<AddressStreetOptional street={data.hq_address_street_3} />
{/* @ts-expect-error Part of code cleanup for post-mvp see: https://github.com/cfpb/sbl-frontend/issues/717 */}
<AddressStreetOptional street={data.hq_address_street_4} />
{valueOrNotavailable(data.hq_address_city)},{' '}
{valueOrNotavailable(data.hq_address_state_code)}{' '}
{valueOrNotavailable(data.hq_address_zip)}
</>
}
/>
<DisplayField label={InstitutionDataLabels.lei} value={data.lei} />
<DisplayField
label={InstitutionDataLabels.leiStatus}
value={data.is_active ? 'Issued' : LAPSED}
/>
{isDomainsVisible ? (
<DisplayField
label={InstitutionDataLabels.emailDomains}
value={formatDomains(data.domains)}
/>
) : (
''
)}
</WellContainer>
</FormSectionWrapper>
);
}
FinancialInstitutionDetails.defaultProps = {
heading: 'Financial institution details',
};
export default FinancialInstitutionDetails;