Skip to content

Commit

Permalink
Merge branch 'main' into 222-update-fi-profile-phase2-mail-api-integr…
Browse files Browse the repository at this point in the history
…ation
  • Loading branch information
meissadia authored Mar 19, 2024
2 parents 46cadc0 + e083993 commit 3a6fcfd
Show file tree
Hide file tree
Showing 20 changed files with 611 additions and 69 deletions.
1 change: 1 addition & 0 deletions ENV-GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ SBL_OIDC_AUTHORITY="http://localhost:8880/realms/regtech"
SBL_OIDC_CLIENT_ID="regtech-client"
SBL_OIDC_REDIRECT_URI="http://localhost:${SBL_DEV_PORT}/filing"
SBL_REGTECH_BASE_URL="http://localhost:8881"
SBL_FILING_BASE_URL="http://localhost:8882"
SBL_MAIL_BASE_URL="http://localhost:8765"
```

Expand Down
20 changes: 20 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ const PaperworkNotice = lazy(
async () => import('pages/Filing/PaperworkNotice'),
);
const Summary = lazy(async () => import('pages/Summary/Summary'));
const PointOfContact = lazy(async () => import('pages/PointOfContact'));
const TypesFinancialInstitutions = lazy(
async () => import('pages/TypesFinancialInstitutions'),
);

// allow developers to toggle routing in development
const isRoutingEnabled = getIsRoutingEnabled();
Expand Down Expand Up @@ -237,6 +241,22 @@ export default function App(): ReactElement {
</ProtectedRoute>
}
/>
<Route
path='/point-of-contact'
element={
<ProtectedRoute {...ProtectedRouteAuthorizations}>
<PointOfContact />
</ProtectedRoute>
}
/>
<Route
path='/types-financial-institutions'
element={
<ProtectedRoute {...ProtectedRouteAuthorizations}>
<TypesFinancialInstitutions />
</ProtectedRoute>
}
/>
<Route path='/privacy-act-notice' element={<PrivacyActNotice />} />
<Route
path='/paperwork-reduction-act-notice'
Expand Down
19 changes: 19 additions & 0 deletions src/api/requests/submitPointOfContact.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { request } from 'api/axiosService';
import type { SblAuthProperties } from 'api/useSblAuth';
import type { FormattedPointOfContactSchema } from 'types/formTypes';

const submitPointOfContact = async (
auth: SblAuthProperties,
userProfileObject: FormattedPointOfContactSchema,
): Promise<null> => {
return request<null>({
// This will eventually be `/v1/filing/institutions/{lei}/filings/{period_name}/contact-info`
// CURRENTLY HARDCODED
url: `/v1/filing/institutions/123456789TESTBANK123/filings/2024/contact-info`,
method: 'put',
body: userProfileObject,
headers: { Authorization: `Bearer ${auth.user?.access_token}` },
});
};

export default submitPointOfContact;
2 changes: 1 addition & 1 deletion src/components/FieldGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ interface FieldGroupProperties {

function FieldGroup({ children }: FieldGroupProperties): JSX.Element {
return (
<div className='field-group max-w-[48.125rem] !border !border-solid !border-cfpbBorderColor bg-[#F7F8F9] p-[1.875rem]'>
<div className='field-group box-border max-w-[48.125rem] !border !border-solid !border-cfpbBorderColor bg-[#F7F8F9] p-[1.875rem]'>
{children}
</div>
);
Expand Down
5 changes: 4 additions & 1 deletion src/components/FormErrorHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ function FormErrorHeader({
id,
}: FormErrorHeaderProperties): JSX.Element | null {
if (!errors || Object.keys(errors).length === 0) return null;

return (
<div className='mb-[2.8125rem] mt-[2.8125rem] w-full'>
<Element name={id} id={id}>
Expand Down Expand Up @@ -76,7 +77,9 @@ function FormErrorHeader({
{`${
formFieldsHeaderError[
keyUsed as keyof typeof formFieldsHeaderError
]
] ??
errors[keyUsed]?.message ??
'Missing entry'
}${
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
typeof keyIndex === 'number' ? ` (${keyIndex + 1})` : ''
Expand Down
18 changes: 18 additions & 0 deletions src/components/FormMain.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import type { ReactNode } from 'react';

interface FormProperties {
children: ReactNode;
}

/**
*
* @returns FormParagraph
*/
function FormMain({
children,
className = '',
}: FormProperties & React.ComponentPropsWithoutRef<'form'>): JSX.Element {
return <form className={`mb-[3.75rem] w-full ${className}`}>{children}</form>;
}

export default FormMain;
4 changes: 2 additions & 2 deletions src/components/FormWrapper.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { ReactNode } from 'react';

interface Properties {
interface FormWrapperProperties {
children: ReactNode;
}

function FormWrapper({ children }: Properties): JSX.Element {
function FormWrapper({ children }: FormWrapperProperties): JSX.Element {
return (
<div className='ml-5 mr-5 mt-[2.813rem]'>
<div className='mx-auto mb-12 max-w-[75rem]'>
Expand Down
5 changes: 3 additions & 2 deletions src/components/InputEntry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { forwardRef } from 'react';
import { Element } from 'react-scroll';

import InputErrorMessage from 'components/InputErrorMessage';
import LabelOptional from 'components/LabelOptional';
import { Heading, TextInput } from 'design-system-react';
import LabelOptional from './LabelOptional';

interface InputEntryProperties
extends PropsWithoutRef<JSX.IntrinsicElements['input']> {
Expand All @@ -23,6 +23,7 @@ interface InputEntryProperties
const InputEntry = forwardRef<HTMLInputElement, InputEntryProperties>(
(
{
className = '',
id,
errorMessage,
label,
Expand All @@ -38,7 +39,7 @@ const InputEntry = forwardRef<HTMLInputElement, InputEntryProperties>(
) => {
const handleError = Boolean(showError && errorMessage);
return (
<div className={`${isLast ? '' : 'mb-[0.9375rem]'}`}>
<div className={`${isLast ? '' : 'mb-[0.9375rem]'} ${className}`}>
<Element name={id}>
<label htmlFor={id}>
<div>
Expand Down
2 changes: 1 addition & 1 deletion src/components/SectionIntro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function SectionIntro({
children = '',
}: SectionIntroProperties): JSX.Element {
return (
<div className='mb-[1.625rem] max-w-[48.125rem]'>
<div className='mb-[1.875rem] box-border max-w-[41.875rem]'>
<Heading type='2'>{heading}</Heading>
<FormParagraph>{children}</FormParagraph>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import FieldGroup from 'components/FieldGroup';
import InputEntry from 'components/InputEntry';
import { Checkbox, Heading, List, ListItem } from 'design-system-react';
import type {
Control,
FieldErrors,
UseFormRegister,
UseFormSetValue,
} from 'react-hook-form';
import { Controller as FormController } from 'react-hook-form';
import { Zero } from 'utils/constants';
import type { CheckboxOption, UFPSchema } from './types';
import { checkboxOptions } from './types';

interface TypesFinancialInstitutionSectionProperties {
register: UseFormRegister<UFPSchema>;
setValue: UseFormSetValue<UFPSchema>;
formErrors: FieldErrors<UFPSchema>;
control: Control<UFPSchema>;
}

function TypesFinancialInstitutionSection({
register,
setValue,
formErrors,
control,
}: TypesFinancialInstitutionSectionProperties): JSX.Element {
// const typeOtherData = data.sbl_institution_types.find(item => {
// return item.sbl_type.id === sblInstitutionTypeMap.other;
// });
return (
<FieldGroup>
<Heading type='4'>Type(s) of financial institution</Heading>
<List isUnstyled>
{checkboxOptions.map((option: CheckboxOption): JSX.Element => {
const optionId = `sbl_institution_types.${option.id}`;

const onCheckboxChange = (
event: React.ChangeEvent<HTMLInputElement>,
): void => {
setValue(optionId, event.target.checked);
};

return (
<ListItem key={option.id}>
<FormController
render={({ field }) => {
return (
<Checkbox
id={option.id}
label={option.label}
{...register(optionId)}
checked={field.value}
onChange={onCheckboxChange}
/>
);
}}
control={control}
name={optionId}
/>
</ListItem>
);
})}
</List>
<InputEntry
label=''
id='institutionTypeOther'
{...register('sbl_institution_types_other', {
// value: typeOtherData?.details,
})}
errorMessage={formErrors[Zero]}
showError
/>
</FieldGroup>
);
}

export default TypesFinancialInstitutionSection;
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import CommonLinks from 'components/CommonLinks';
import FieldGroup from 'components/FieldGroup';
import FormMain from 'components/FormMain';
import SectionIntro from 'components/SectionIntro';

import {
Checkbox,
Heading,
Expand Down Expand Up @@ -109,9 +111,9 @@ function UpdateIdentifyingInformation({
If you wish to provide additional types of financial institutions add
them to “Other” and check the box.{' '}
</Paragraph>
<form>
<FormMain>
<FieldGroup>
<Heading type='4'>Type of financial institution</Heading>
<Heading type='4'>Types of financial institutions</Heading>
<List isUnstyled>
{checkboxOptions.map((option: CheckboxOption): JSX.Element => {
const optionId = `sbl_institution_types.${option.id}`;
Expand Down Expand Up @@ -153,7 +155,7 @@ function UpdateIdentifyingInformation({
showError
/>
</FieldGroup>
</form>
</FormMain>
</FormSectionWrapper>
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Filing/UpdateFinancialProfile/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,4 @@ export const ufpSchema = z.object({
sbl_institution_types: z.object(checkboxOptionsZod),
});

export type UFPSchema = z.infer<typeof ufpSchema>;
export type UFPSchema = z.infer<typeof ufpSchema>;
Loading

0 comments on commit 3a6fcfd

Please sign in to comment.